BRABGameScene.js 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  1. let Global = require("Global");
  2. let TPGameBase = require("TPGameBase");
  3. let { CServerItem } = require("CServerItem");
  4. let ScenceManager = require("HNScenceManager");
  5. let GameManagerBase = require("GameManagerBase");
  6. let BaseDefine = require("BaseDefine");
  7. let BRTPSoundFun = require("BRABSoundFun");
  8. let topTipMsg = require("topTipMsg");
  9. const UIHelper = require("UIHelper");
  10. cc.Class({
  11. extends: TPGameBase,
  12. properties: {
  13. chipSprite: [cc.SpriteFrame],
  14. chipBmFont: [cc.BitmapFont],
  15. avatarsSpriteAtlas: cc.SpriteAtlas
  16. },
  17. onLoad() {
  18. this.GameStateEnum = {
  19. "Free": 0,
  20. "Start": 1,
  21. "End": 2,
  22. }
  23. this.GameState = null;
  24. this.baseType = "brab";
  25. this.menuOpenState = false;
  26. this.menuNode = UIHelper.pathGetNode(this.node, "TP_Base/menuNode");
  27. this.menuNode.scaleY = 0;
  28. this.initMenuBtn();
  29. this.initData();
  30. this._super();
  31. BRTPSoundFun.playBackMusic(BRTPSoundFun.GAME_BACKGRUAND);
  32. },
  33. /*------------------------------------------------ 数据初始化 -----------------------------------------------*/
  34. initMenuBtn() {
  35. UIHelper.addButtonListener(this.menuNode.getChildByName("img_cb_sz"), this.node, "BRABGameScene", "onBtnGameSettings");
  36. UIHelper.addButtonListener(this.menuNode.getChildByName("img_cb_gz"), this.node, "BRABGameScene", "onBtnRule");
  37. UIHelper.addButtonListener(this.menuNode.getChildByName("img_cb_tc"), this.node, "BRABGameScene", "onBtnExitToLobby");
  38. },
  39. initData() {
  40. this.animManager = this.node.getComponent("BRABAnimManager");
  41. this.layer_playControlButton_mode2 = UIHelper.pathGetNode(this.node, "TP_Base/layer_bottom/layer_playControlButton_mode2");
  42. this.tip_ring = UIHelper.pathGetNode(this.node, "TP_Base/layer_bottom/layer_playControlButton_mode2/tip_ring");
  43. this.layer_gameBg = UIHelper.pathGetNode(this.node, "layer_gameBg");
  44. this.button_andar = UIHelper.pathGetNode(this.node, "layer_gameBg/button_andar");
  45. this.button_bahar = UIHelper.pathGetNode(this.node, "layer_gameBg/button_bahar");
  46. this.layer_allChipTotle = UIHelper.pathGetNode(this.node, "layer_allChipTotle");
  47. this.label_allPoolA = UIHelper.pathGetNode(this.node, "layer_allChipTotle/label_allPoolA");
  48. this.label_allPoolB = UIHelper.pathGetNode(this.node, "layer_allChipTotle/label_allPoolB");
  49. this.layer_myChipTotle = UIHelper.pathGetNode(this.node, "layer_myChipTotle");
  50. this.label_myPoolA = UIHelper.pathGetNode(this.node, "layer_myChipTotle/label_myPoolA");
  51. this.label_myPoolB = UIHelper.pathGetNode(this.node, "layer_myChipTotle/label_myPoolB");
  52. this.layer_bank = UIHelper.pathGetNode(this.node, "layer_bank");
  53. this.layer_stateAnim = UIHelper.pathGetNode(this.node, "layer_stateAnim");
  54. this.ani_wait = UIHelper.pathGetNode(this.node, "layer_stateAnim/ani_wait");
  55. this.spine_jetonTip = UIHelper.pathGetNode(this.node, "layer_stateAnim/spine_jetonTip");
  56. this.layer_standPlayer = UIHelper.pathGetNode(this.node, "layer_standPlayer");
  57. this.button_playerCount = UIHelper.pathGetNode(this.node, "layer_standPlayer/button_playerCount");
  58. this.label_playerCount = UIHelper.pathGetNode(this.node, "layer_standPlayer/button_playerCount/label_playerCount");
  59. this.scroll_playerList = UIHelper.pathGetNode(this.node, "layer_standPlayer/scroll_playerList");
  60. this.copyNode_playerList = UIHelper.pathGetNode(this.node, "layer_standPlayer/scroll_playerList/copyNode_playerList");
  61. this.scroll_playerList_content = UIHelper.pathGetNode(this.node, "layer_standPlayer/scroll_playerList/view/scroll_playerList_content");
  62. this.layer_poker = UIHelper.pathGetNode(this.node, "layer_poker");
  63. this.layer_bankPoker = UIHelper.pathGetNode(this.node, "layer_poker/layer_bankPoker");
  64. this.layer_andarPoker = UIHelper.pathGetNode(this.node, "layer_poker/layer_andarPoker");
  65. this.layer_baharPoker = UIHelper.pathGetNode(this.node, "layer_poker/layer_baharPoker");
  66. this.layer_chipShow = UIHelper.pathGetNode(this.node, "layer_chipShow");
  67. this.layer_time = UIHelper.pathGetNode(this.node, "layer_time");
  68. this.sprite_timeMask = UIHelper.pathGetNode(this.node, "layer_time/sprite_timeMask");
  69. this.label_timeClock = UIHelper.pathGetNode(this.node, "layer_time/label_timeClock");
  70. this.label_timeState = UIHelper.pathGetNode(this.node, "layer_time/label_timeState");
  71. this.layer_winLine = UIHelper.pathGetNode(this.node, "layer_winLine");
  72. this.layer_panelLine = UIHelper.pathGetNode(this.node, "layer_winLine/layer_panelLine");
  73. this.sprite_lineA = UIHelper.pathGetNode(this.node, "layer_winLine/sprite_lineA");
  74. this.sprite_lineB = UIHelper.pathGetNode(this.node, "layer_winLine/sprite_lineB");
  75. this.layer_abWinAnim = UIHelper.pathGetNode(this.node, "layer_abWinAnim");
  76. this.sprite_animAndar = UIHelper.pathGetNode(this.node, "layer_abWinAnim/sprite_animAndar");
  77. this.sprite_animBahar = UIHelper.pathGetNode(this.node, "layer_abWinAnim/sprite_animBahar");
  78. this.sprite_kuangAnimAndar = UIHelper.pathGetNode(this.node, "layer_abWinAnim/sprite_kuangAnimAndar");
  79. this.sprite_kuangAnimBahar = UIHelper.pathGetNode(this.node, "layer_abWinAnim/sprite_kuangAnimBahar");
  80. this.sprite_kuangAnimBank = UIHelper.pathGetNode(this.node, "layer_abWinAnim/sprite_kuangAnimBank");
  81. this.spine_jetonTip_component = UIHelper.pathGetNode(this.node, "layer_stateAnim/spine_jetonTip", sp.Skeleton);
  82. this.Button_GoldAddAgain = UIHelper.pathGetNode(this.node, "TP_Base/layer_bottom/layer_playControlButton_mode2/Button_GoldAddAgain", cc.Button);
  83. this._notLockState = true;
  84. this._lockUserEnter = true;//初始化加入玩家锁
  85. this._standPlayerCount = 0;//站着的玩家总数
  86. this._choiceChipNumber = 0;//选择的筹码面值
  87. this._allInChip = 0;//可下注数
  88. this._nowInChip = 0;//已下注数
  89. this._allAreaInChip = {
  90. 0: 0,//A区
  91. 1: 0,//B区
  92. }//所有玩家总下注区域数
  93. this._myAreaInChip = {
  94. 0: 0,//A区
  95. 1: 0,//B区
  96. }//我的总下注区域数
  97. this._gameNum = -1; //游戏局数
  98. this._playGameNum = 0;//不玩游戏局数
  99. this._middleCard = 0;//中心牌ID
  100. this._andarCard = [];//安达牌
  101. this._baharCard = [];//巴哈牌
  102. this._playerJettonArr = [[], []];//本局座位玩家.自己.站着的所有玩家下注在A,B去记录
  103. this._chipCache = [];//自己所有下注的记录缓存
  104. this._gameWinRate = null;
  105. this._endCardList = [];
  106. this._gameWInLine = [];
  107. },
  108. initJettonAreaArr() {
  109. let playerCount = 6;
  110. let arae = 2;
  111. this._playerJettonArr = [];
  112. for (let i = 0; i < playerCount + 2; i += 1) {
  113. this._playerJettonArr[i] = [];
  114. for (let j = 0; j < arae; j += 1) {
  115. this._playerJettonArr[i][j] = [];
  116. }
  117. }
  118. },
  119. initScene(data) {
  120. this.initJettonAreaArr();
  121. this.initStateAnim();
  122. this.initPlayer(data);
  123. this.initChipPool(data);
  124. this.setGameState(data, data.cbStatus || 0, true);
  125. this.initDateGameRestrict(data);
  126. },
  127. initStateAnim() {
  128. for (let i = 0; i < this.layer_stateAnim.children.length; i += 1) {
  129. this.layer_stateAnim.children[i].active = false;
  130. }
  131. },
  132. initPlayer(data) {
  133. let wSeatUser = data.wSeatUser;
  134. let playerList = this.getGamePlayerList();
  135. let myChair = this.getSelfPlayer().getChairID();
  136. let ojb = {
  137. 0: 3,
  138. 1: 4,
  139. 2: 5,
  140. 3: 0,
  141. 4: 1,
  142. 5: 2
  143. };
  144. for (let i = 0; i < this.layer_chairPlayer.children.length - 1; i += 1) {
  145. this.layer_chairPlayer.children[i].active = false;
  146. // let node = this.layer_chairPlayer.children[i];
  147. // if (node.getChildByName("New Label")) {
  148. // let label = node.getChildByName("New Label").getComponent(cc.Label)
  149. // label.string = "0";
  150. // }
  151. }
  152. for (let i = 0; i < playerList.length; i += 1) {
  153. let node = null;
  154. let script = playerList[i];
  155. let chairID = playerList[i].getChairID();
  156. let index = wSeatUser.indexOf(chairID);
  157. if (index >= 0) {
  158. //其他桌上的玩家
  159. node = this.layer_chairPlayer.children[ojb[index]];
  160. this.initPlayerNode(node, script);
  161. } else {
  162. //在旁边站的玩家
  163. node = cc.instantiate(this.copyNode_playerList);
  164. node.name = script.getNickName() + Math.round(Math.random() * 999999999);
  165. node.parent = this.scroll_playerList_content;
  166. this._standPlayerCount += 1;
  167. this.initPlayerNode(node, script);
  168. } if (myChair == chairID) {
  169. //我自己
  170. let node2 = this.layer_chairPlayer.children[this.layer_chairPlayer.children.length - 1];
  171. this.initPlayerNode(node2, this.myselfScript);
  172. this.myselfScript.initMyself();
  173. }
  174. }
  175. this._lockUserEnter = false;
  176. this.updateStandPlayerCount();
  177. },
  178. initPlayerNode(player, scripts) {
  179. player.active = true;
  180. player._saveScript = scripts;
  181. scripts.inits(player);
  182. },
  183. initWinLine(data) {
  184. let line = [];
  185. let posArr = [cc.v2(-51, -3), cc.v2(-25, -3), cc.v2(1, -3), cc.v2(27, -3), cc.v2(53, -3)];
  186. for (let i = data.cbWinArea.length - 1; i >= 0; i -= 1) {
  187. line.push(data.cbWinArea[i]);
  188. if (line.length == 5) { break; }
  189. }
  190. while (this.layer_panelLine.children.length > 0) {
  191. let node = this.layer_panelLine.children[0];
  192. node.removeFromParent();
  193. node.destroy();
  194. }
  195. line.reverse();
  196. for (let i = 0; i < line.length; i += 1) {
  197. let number = line[i];
  198. let node = cc.instantiate(this["sprite_line" + (number == 0 ? "A" : "B")]);
  199. node.parent = this.layer_panelLine;
  200. node.active = true;
  201. node.position = posArr[i];
  202. }
  203. },
  204. initDataByState(data, bool) {
  205. if (this.GameState == this.GameStateEnum.Start) {
  206. this._allInChip = parseFloat(this.getSelfPlayer().getUserScore());
  207. this._nowInChip = 0;
  208. this._allAreaInChip = { 0: 0, 1: 0, };
  209. this._myAreaInChip = { 0: 0, 1: 0, };
  210. this._chipCache[this._gameNum += 1] = [[], [], new Date()];
  211. this.schedule(() => BRTPSoundFun.playEffectEX(BRTPSoundFun.EX_TIME), 1, 1, data.cbTimeLeave - 5);
  212. this.updateMiddleCard(data);
  213. this.updateReBatButton(true);
  214. this.stopPromises();
  215. } else if (this.GameState == this.GameStateEnum.End) {
  216. this._endCardIndex = 0;
  217. this._endCardList = [];
  218. this.updateAreaCardArray(data);
  219. this.updateReBatButton(false);
  220. this._baharCard.forEach((item, index) => { this._endCardList = this._endCardList.concat(item, this._andarCard[index]); })
  221. }
  222. },
  223. initSceneByState(data) {
  224. cc.log(data);
  225. if (this.GameState == this.GameStateEnum.Start || this.GameState == this.GameStateEnum.End) {
  226. let arr = [0, 0];
  227. let allPlayerAreachips = data.lSeatUserBetScore;
  228. let lAllJettonScore = data.lAllJettonScore;
  229. for (let i = 0; i < 6; i += 1) {
  230. arr[0] += allPlayerAreachips[i][0];
  231. arr[1] += allPlayerAreachips[i][1];
  232. this._playerJettonArr[i] = this.splitChips1(data, allPlayerAreachips[i]);
  233. };
  234. this._playerJettonArr[6] = this.splitChips1(data, this._playerJettonArr[6]);
  235. this._playerJettonArr[7] = this.splitChips1(data, [lAllJettonScore[0] - arr[0], lAllJettonScore[1] - arr[1]]);
  236. this._allAreaInChip = data.lAllJettonScore;
  237. this._myAreaInChip = data.lPlayerJettonScore;
  238. this._gameWInLine = [];
  239. this.updateMyChipTotle(true);
  240. this.updateAllChipTotle(true);
  241. this.stopPromises();
  242. } if (this.GameState == this.GameStateEnum.Start) {
  243. this.gameCardOnStart(data, true);
  244. this.updateMyJettonBtnInteractable(true);
  245. this.myselfScript.setScore(this.getSelfPlayer().getUserScore() - (data.lPlayerJettonScore[0] + data.lPlayerJettonScore[1]));
  246. this._nowInChip = data.lPlayerJettonScore[0] + data.lPlayerJettonScore[1];//已下注数
  247. this._allInChip = parseFloat(this.getSelfPlayer().getUserScore()) - this._nowInChip;//可下注数
  248. }
  249. else if (this.GameState == this.GameStateEnum.End) {
  250. this.gameCardOnEnd(data);
  251. this.updateMyJettonBtnInteractable(false);
  252. }
  253. },
  254. initDateGameRestrict(data) {
  255. if (data.nMinBetScore) {
  256. if (this._allInChip == 0) { this._allInChip = parseFloat(this.getSelfPlayer().getUserScore()) - this._nowInChip; }
  257. if (this._allInChip < data.nMinBetScore) {
  258. this._notLockState = false;
  259. UIHelper.pathGetNode(this.node, "TP_Base/layer_bottom/mask").active = true;
  260. UIHelper.pathGetNode(this.node, "TP_Base/layer_bottom/mask/label", cc.Label).string = Global.formatString2Score(data.nMinBetScore);
  261. this.updateMyJettonBtnInteractable(false);
  262. } else {
  263. this._notLockState = true;
  264. UIHelper.pathGetNode(this.node, "TP_Base/layer_bottom/mask").active = false;
  265. }
  266. }
  267. },
  268. splitChips1(data, arr) {
  269. let newArr = [];
  270. let chipsConfig = data.nChip;
  271. for (let i = 0; i < arr.length; i += 1) {
  272. let number = arr[i];
  273. newArr[i] = this.splitChips2(number, chipsConfig, i, []);
  274. }
  275. return newArr;
  276. },
  277. splitChips2(number, chipsConfig, area, arr) {
  278. if (number == 0) { return arr; }
  279. let index = 0;
  280. let randNumber = 0;
  281. for (let i = chipsConfig.length; i >= 0; i -= 1) {
  282. if (number >= chipsConfig[i]) {
  283. index = i;
  284. break;
  285. }
  286. }
  287. if (Math.random() < 0.3) {
  288. randNumber = chipsConfig[Math.floor(Math.random() * index)];
  289. } else {
  290. randNumber = chipsConfig[index];
  291. }
  292. let offsetX = -50 + Math.random() * 100;
  293. let offsetY = -50 + Math.random() * 100;
  294. let areaPos = area == 1 ? this.button_bahar.position : this.button_andar.position;
  295. // Global.print(randNumber)
  296. let chips = this.getChip(randNumber);
  297. chips.active = true;
  298. chips.parent = this.layer_chipShow.getChildByName(area == 1 ? "bahar" : "andar");
  299. chips.position = cc.v2(areaPos.x + offsetX, areaPos.y + offsetY);
  300. number -= randNumber;
  301. arr.push(randNumber);
  302. return this.splitChips2(number, chipsConfig, area, arr);
  303. },
  304. stopPromises() {
  305. this._reject && this._reject();
  306. this.animManager._reject && this.animManager._reject();
  307. this._reject = null;
  308. this.animManager._reject = null;
  309. },
  310. /*----------------------------------------------------------------------------------------------------------*/
  311. /*------------------------------------------------- 消息接收 ------------------------------------------------*/
  312. sceneMessage(gameStatus, typeCode, dataView) {
  313. let msg = null;
  314. switch (gameStatus) {
  315. case typeCode.GS_TK_END:
  316. case typeCode.GS_TK_CHIP:
  317. msg = ProtoAnalysis.analysisData(dataView, BRABProto.CMD_S_StatusPlay, BRABProto);
  318. this.initScene(msg);
  319. break;
  320. case typeCode.GS_TK_FREE:
  321. msg = ProtoAnalysis.analysisData(dataView, BRABProto.CMD_S_StatusFree, BRABProto);
  322. this.initScene(msg);
  323. break;
  324. default: Global.print("BRABGameSence onEventSceneMessage error "); break;
  325. };
  326. },
  327. GameMessage(msgHead, typeCode, dataView) {
  328. cc.log(msgHead, dataView);
  329. let msg = null;
  330. switch (msgHead.s) {
  331. case typeCode.SUB_S_SEND_CONTROL_INFO:
  332. msg = ProtoAnalysis.analysisData(dataView, BRABProto.CMD_S_ControlInfo, BRABProto);
  333. this.onSubSendControlInfo(msg);
  334. break;
  335. case typeCode.SUB_S_SEND_WINLOST:
  336. msg = ProtoAnalysis.analysisData(dataView, BRABProto.tagServerGameWinLost, BRABProto);
  337. this._gameWinRate = msg;
  338. break;
  339. case typeCode.SUB_S_SEND_RECORD:
  340. let data = { cbWinArea: [] };
  341. dataView.pos = 0;
  342. for (let i = 0; i < dataView.buffer.byteLength; i += 1) {
  343. data.cbWinArea.push(Global.GetInt8(dataView));
  344. }
  345. // msg = ProtoAnalysis.analysisData(dataView, BRABProto.tagServerGameRecord, BRABProto);
  346. // cc.log(msg);
  347. if (this._gameWInLine.length == 0) {
  348. this.initWinLine(data);
  349. }
  350. this._gameWInLine = data;
  351. break;
  352. case typeCode.SUB_S_PLACE_JETTON:
  353. case typeCode.SUB_S_OTHER_JETTON:
  354. msg = ProtoAnalysis.analysisData(dataView, BRABProto.CMD_S_PlaceJetton, BRABProto);
  355. this.playerJetton(msg);
  356. break;
  357. case typeCode.SUB_S_GAME_FREE:
  358. case typeCode.SUB_S_GAME_START:
  359. case typeCode.SUB_S_GAME_END:
  360. let cfg = {
  361. [typeCode.SUB_S_GAME_FREE]: { Func: "stateOnFree", CMD: "CMD_S_FreeState" },
  362. [typeCode.SUB_S_GAME_START]: { Func: "stateOnStart", CMD: "CMD_S_GameStart" },
  363. [typeCode.SUB_S_GAME_END]: { Func: "stateOnEnd", CMD: "CMD_S_GameEnd" },
  364. }[msgHead.s];
  365. this[cfg.Func](ProtoAnalysis.analysisData(dataView, BRABProto[cfg.CMD], BRABProto));
  366. break;
  367. case typeCode.SUB_S_PLACE_JETTON_FAIL:
  368. window.aaabbb = dataView;
  369. let dataList = {};
  370. dataView.pos = 0;
  371. dataList.szBuffer = Global.Read2Char(dataView, 64);
  372. if (dataList.szBuffer == "not bet time!") {
  373. dataList.szBuffer = "não aposta tempo";
  374. }
  375. topTipMsg.showTopTipMsg(dataList.szBuffer);
  376. // cc.log(Global.gbk2Utf8(dataList.szBuffer));
  377. break;
  378. default: Global.print("BRABGameSence onEventSceneMessage error "); break;
  379. };
  380. },
  381. /*----------------------------------------------------------------------------------------------------------*/
  382. /*------------------------------------------------- 状态控制 ------------------------------------------------*/
  383. setGameState(data, cbStatus, bool = false) {
  384. let time = data.cbTimeLeave;
  385. if (cbStatus == 0) {//等待开始
  386. this.GameState = this.GameStateEnum.Free;
  387. this.label_timeState.getComponent(cc.Label).string = "Preparando...";
  388. } else if (cbStatus == 1) {//下注状态
  389. this.GameState = this.GameStateEnum.Start;
  390. this.label_timeState.getComponent(cc.Label).string = "Tempo de aposta";
  391. } else if (cbStatus == 2) {//结算状态
  392. this.GameState = this.GameStateEnum.End;
  393. if (bool) {
  394. this.label_timeState.getComponent(cc.Label).string = "Preparando...";
  395. }
  396. } else {
  397. this.GameState = -1;
  398. this.label_timeState.getComponent(cc.Label).string = "";
  399. }
  400. this.timeFunc && this.unschedule(this.timeFunc);
  401. this.timeFunc = (dt) => {
  402. time -= dt;
  403. if (time > 0) {
  404. this.layer_time.active = true;
  405. this.label_timeClock.getComponent(cc.Label).string = Math.round(time);
  406. this.sprite_timeMask.getComponent(cc.Sprite).fillRange = time / data.cbTimeLeave * -1;
  407. } else {
  408. this.layer_time.active = false;
  409. this.unschedule(this.timeFunc);
  410. }
  411. }
  412. if (cbStatus != 2 || (cbStatus == 2 && bool)) {
  413. this.schedule(this.timeFunc, 0.1)
  414. } else {
  415. this.layer_time.active = false;
  416. }
  417. this.initDataByState(data);
  418. bool && this.initSceneByState(data);
  419. },
  420. stateOnFree(data) {
  421. // this.ani_wait.active = true;
  422. this.cleanRoom();//清理游戏桌面
  423. this.hideABAnim();
  424. this.initJettonAreaArr();
  425. this.setGameState(data, 0);
  426. this.updateMyChipTotle(false);
  427. this.updateAllChipTotle(false);
  428. this.updatePlayGameNum();
  429. },
  430. stateOnStart(data) {
  431. // this.ani_wait.active = false;
  432. this.spine_jetonTip.active = true;
  433. this.spine_jetonTip_component.setTrackCompleteListener(this.spine_jetonTip_component.setAnimation(0, "a1", false), () => {
  434. this.spine_jetonTip.active = false;
  435. this.updateMyJettonBtnInteractable(true);
  436. this.gameCardOnStart(data);
  437. });
  438. this.updateChiarPlayer(data);
  439. this.setGameState(data, 1);
  440. this.updateMyChipTotle(true);
  441. this.updateAllChipTotle(true);
  442. BRTPSoundFun.playEffectEX(BRTPSoundFun.EX_SENDCARD);
  443. },
  444. stateOnEnd(data) {
  445. this.spine_jetonTip.active = true;
  446. this.spine_jetonTip_component.setTrackCompleteListener(this.spine_jetonTip_component.setAnimation(0, "a2", false), () => {
  447. this.animManager.animTime1 = 0.3;
  448. this.animManager.animTime2 = 0.25;
  449. this.spine_jetonTip.active = false;
  450. this.gameEnd(data);
  451. });
  452. this.setGameState(data, 2);
  453. this.updateMyJettonBtnInteractable(false);
  454. BRTPSoundFun.playEffectEX(BRTPSoundFun.EX_SENDCARD);
  455. },
  456. gameCardOnStart(data, bool = false) {
  457. let pos = cc.v2(0, 290);
  458. let parent = this.layer_bankPoker;
  459. let node = this.getPoker(bool ? this._middleCard : 0, parent, true);
  460. node.position = pos;
  461. node.active = true;
  462. !bool && this.animManager.async_sendCardOnGameStart(pos, node, () => {
  463. this.animManager.rotaCard(pos, node, this.layer_bankPoker, this._middleCard);
  464. });
  465. },
  466. gameCardOnEnd(data) {
  467. let posArr = [cc.v2(0, 290), cc.v2(75, 85), cc.v2(-75, 85)];
  468. let index = 0;
  469. for (let i = 0; i < this._endCardList.length; i += 1) {
  470. let card1 = this.getCardNum(this._endCardList[i]);
  471. let card2 = this.getCardNum(data.cbMiddleCard);
  472. if (card1 == card2) {
  473. index = i;
  474. break;
  475. }
  476. }
  477. for (let i = 0; i < 3; i += 1) {
  478. if (this._endCardList[index]) {
  479. let node = null;
  480. let pos = posArr[i];
  481. if (i == 0) {
  482. node = this.getPoker(data.cbMiddleCard, this.layer_bankPoker, true);
  483. node.position = cc.v2(0, 290);
  484. } else {
  485. node = this.getPoker(this._endCardList[index], index % 2 == 0 ? this.layer_baharPoker : this.layer_andarPoker, true);
  486. node.position = cc.v2(index % 2 == 0 ? 75 : -75, 85);
  487. index -= 1;
  488. }
  489. node.active = true;
  490. }
  491. }
  492. // this.showWinAraeAnim(data, index + 1);
  493. },
  494. onUserEnter(clientUserItem) {
  495. if (this._lockUserEnter) { return; }
  496. let playerList = this.getGamePlayerList();
  497. let script = playerList.find((item) => { return item.getChairID() == clientUserItem.GetChairID(); })
  498. let node = cc.instantiate(this.copyNode_playerList);
  499. node.parent = this.scroll_playerList_content;
  500. this.initPlayerNode(node, script);
  501. this._standPlayerCount += 1;
  502. this.updateStandPlayerCount();
  503. },
  504. onUserLeave(clientUserItem, script) {
  505. if (this._lockUserEnter) { return; }
  506. let node = script.node;
  507. if (node.parent.name == "layer_chairPlayer") {
  508. // script.refreshHeadNode();
  509. } else if (node.parent.name == "scroll_playerList_content") {
  510. this._standPlayerCount -= 1;
  511. node.destroy();
  512. }
  513. this.updateStandPlayerCount();
  514. },
  515. /*----------------------------------------------------------------------------------------------------------*/
  516. /*------------------------------------------------- 下注控制 ------------------------------------------------*/
  517. playerJetton(data) {
  518. Global.print(data);
  519. let area = data.cbBetArea;
  520. let chair = data.wChairID;
  521. let score = data.lBetScore;
  522. let areaPos = area == 1 ? this.button_bahar.position : this.button_andar.position;
  523. let node = this.foundPlayerByChair(chair);
  524. let myChair = this.getSelfPlayer().getChairID();
  525. let chips = this.getChip(data.lBetScore);
  526. let nodePos = null;
  527. // if (node.getChildByName("New Label")) {
  528. // node.getChildByName("New Label").active = true;
  529. // let label = node.getChildByName("New Label").getComponent(cc.Label)
  530. // label.string = Number(label.string) + Number(Global.formatString2Score(score));
  531. // }
  532. if (myChair == chair) {
  533. node = this.myselfScript.node.getChildByName("sprite_playerHead");
  534. this.updateMyChipNumber(area, score);
  535. this.updateMyChipJetton();
  536. this.updateMyChipTotle(true);
  537. this.updateReBatButton(false);
  538. this.myselfScript.refreshMyself(score);
  539. nodePos = node.parent.position;
  540. } else if (node.parent.name == "layer_chairPlayer") {
  541. node = node.getChildByName("sprite_playerHead");
  542. nodePos = node.parent.position;
  543. } else if (node.parent.name == "scroll_playerList_content") {
  544. node = this.button_playerCount;
  545. nodePos = this.button_playerCount.position;
  546. }
  547. let [copyPos1] = [...nodePos];
  548. if (!node.originalPos) {
  549. node.originalPos = node.position;
  550. }
  551. let normalizeVec = areaPos.subtract(nodePos).normalize();
  552. this.animManager.jettonHeadMove(node, normalizeVec, node.originalPos);
  553. this.animManager.moveChips(data, chips, copyPos1);
  554. this.updateAllAreaInChip(area, score);
  555. this.updateAllChipTotle(true);
  556. this.updateJettonAreaArr(area, score, node.parent, myChair == chair);
  557. },
  558. foundPlayerByChair(chairID) {
  559. let playerList = this.getGamePlayerList();
  560. let script = playerList.find((item) => { return item.getChairID() == chairID; });
  561. return script.node;
  562. },
  563. /*-----------------------------------------------------------------------------------------------------------*/
  564. /*------------------------------------------------ 数据/界面刷新 ---------------------------------------------*/
  565. updateMiddleCard(data) {
  566. this._middleCard = data.cbMiddleCard;
  567. },
  568. updateAreaCardArray(data) {
  569. if (data.cbAreaCardArray) {
  570. this._andarCard = data.cbAreaCardArray[0];
  571. this._baharCard = data.cbAreaCardArray[1];
  572. }
  573. },
  574. updateStandPlayerCount() {
  575. this.label_playerCount.getComponent(cc.Label).string = this._standPlayerCount;
  576. },
  577. updateMyChipNumber(area, score) {
  578. this._nowInChip += score;
  579. this._allInChip -= score;
  580. this._myAreaInChip[area] += score;
  581. this._chipCache[this._gameNum][area].push(score);
  582. },
  583. updateMyChipJetton() {
  584. this.layer_playControlButton_mode2 = UIHelper.pathGetNode(this.node, "TP_Base/layer_bottom/layer_playControlButton_mode2");
  585. this.tip_ring.active = true;
  586. let reFind = this._allInChip < this._choiceChipNumber;
  587. Global.print(this._allInChip)
  588. for (let i = this.layer_playControlButton_mode2.children.length - 3; i >= 0; i -= 1) {
  589. let node = this.layer_playControlButton_mode2.children[i];
  590. let sprite = node.getComponent(cc.Sprite);
  591. let label = node.children[0].getComponent(cc.Label);
  592. if (this._allInChip >= node._chipCount) {
  593. node._canClick = true;
  594. sprite.spriteFrame = this.chipSprite[i];
  595. label.font = this.chipBmFont[i];
  596. if (reFind) {
  597. this.tip_ring.active = true;
  598. this.tip_ring.position = node.position;
  599. this._choiceChipNumber = node._chipCount;
  600. reFind = false;
  601. }
  602. } else {
  603. node._canClick = false;
  604. sprite.spriteFrame = this.chipSprite[6];
  605. label.font = this.chipBmFont[6];
  606. if (reFind && i == 0) {
  607. this.tip_ring.active = false;
  608. }
  609. }
  610. }
  611. },
  612. updateChiarPlayer(data) {
  613. this._standPlayerCount = 0;
  614. for (let i = 0; i < this.scroll_playerList_content.children.length; i += 1) {
  615. let node = this.scroll_playerList_content.children[i];
  616. let script = node._saveScript;
  617. if (script) {
  618. script.node = null;
  619. node._components = [];
  620. }
  621. node.destroy();
  622. }
  623. this.initPlayer(data);
  624. },
  625. updateMyJettonBtnInteractable(state) {
  626. if (state && this._notLockState) {
  627. this.updateMyChipJetton();
  628. } else {
  629. this.tip_ring.active = false;
  630. for (let i = 0; i < 6; i += 1) {
  631. let node = this.layer_playControlButton_mode2.children[i];
  632. node.getComponent(cc.Sprite).spriteFrame = this.chipSprite[6];
  633. node.children[0].getComponent(cc.Label).font = this.chipBmFont[6];
  634. }
  635. }
  636. },
  637. updateAllAreaInChip(area, score) {
  638. this._allAreaInChip[area] += score;
  639. },
  640. updateMyChipTotle(state) {
  641. this.label_myPoolA.getComponent(cc.Label).string = state ? Global.formatString2Score(this._myAreaInChip[0]) : 0;
  642. this.label_myPoolB.getComponent(cc.Label).string = state ? Global.formatString2Score(this._myAreaInChip[1]) : 0;
  643. },
  644. updateAllChipTotle(state) {
  645. this.label_allPoolA.getComponent(cc.Label).string = state ? Global.formatString2Score(this._allAreaInChip[0]) : 0;
  646. this.label_allPoolB.getComponent(cc.Label).string = state ? Global.formatString2Score(this._allAreaInChip[1]) : 0;
  647. },
  648. updatePlayGameNum() {
  649. if (this._playGameNum >= 5) {
  650. this.backHome();
  651. cc.vv.GetHallScript().LongTimeOutOfOperation("BRTP.time_out_exit_tip");
  652. }
  653. },
  654. updateJettonAreaArr(area, score, node, bool) {
  655. let order = node.orderIndex;
  656. let length = this._playerJettonArr.length - 1;
  657. if (bool) {
  658. this._playerJettonArr[length - 1][area].push(score);
  659. } else {
  660. this._playerJettonArr[order != null ? order : length][area].push(score);
  661. }
  662. },
  663. updateReBatButton(state) {
  664. if (state == false) {
  665. this.Button_GoldAddAgain.interactable = false;
  666. } else {
  667. let data = this._chipCache[this._gameNum - 1];
  668. if (data) {
  669. let area1 = data[0].length > 0 ? data[0].reduce((a, b) => { return a + b; }) : 0;
  670. let area2 = data[1].length > 0 ? data[1].reduce((a, b) => { return a + b; }) : 0;
  671. if (this._allInChip > (area1 + area2)) {
  672. this.Button_GoldAddAgain.interactable = data[0].length > 0 || data[1].length > 0;
  673. } else {
  674. this.Button_GoldAddAgain.interactable = false;
  675. }
  676. } else {
  677. this.Button_GoldAddAgain.interactable = false;
  678. }
  679. }
  680. },
  681. /*-----------------------------------------------------------------------------------------------------------*/
  682. /*------------------------------------------------- 游戏结束控制 ----------------------------------------------*/
  683. gameEnd(data) {
  684. if (this._endCardIndex >= this._endCardList.length) { return; }
  685. let id = this._endCardList[this._endCardIndex];
  686. let pos = this._endCardIndex % 2 == 0 ? cc.v2(75, 85) : cc.v2(-75, 85);
  687. let arae = this._endCardIndex % 2 == 0 ? this.layer_baharPoker : this.layer_andarPoker;
  688. let callFunc = () => {
  689. if (this.getCardNum(id) == this.getCardNum(this._middleCard)) {
  690. this.gameEndAnim(data);
  691. } else {
  692. this.gameEnd(data);
  693. }
  694. }
  695. let node = this.getPoker(id, arae, true);
  696. node.position = pos;
  697. this.animManager.async_sendCardOnGameStart(pos, node, callFunc);
  698. this._endCardIndex += 1;
  699. },
  700. async gameEndAnim(data) {
  701. this._endCardIndex -= 1;//由于异步原因_endCardIndex多加了1
  702. let index = this._endCardIndex;
  703. this.animManager.animTime1 = 1;
  704. this.animManager.animTime2 = 0.3;
  705. this.showWinLine(data, index);
  706. await this.showWinAraeAnim(data, index);
  707. await this.recoveryChips(data, index);
  708. await this.showWinerChipsMove1(data, index);
  709. await this.showWinerChipsMove2(data, index);
  710. await this.showWinerPlayerAnim(data, index);
  711. },
  712. showWinLine(data, index) {
  713. let number = index % 2 == 1 ? 0 : 1;
  714. let length = this.layer_panelLine.children.length;
  715. let posArr = [cc.v2(-51, -3), cc.v2(-25, -3), cc.v2(1, -3), cc.v2(27, -3), cc.v2(53, -3)];
  716. if (length == 5) {
  717. for (let i = 0; i < length; i += 1) {
  718. let node = this.layer_panelLine.children[i];
  719. if (i == 0) {
  720. node.runAction(cc.sequence(
  721. cc.spawn(
  722. cc.moveBy(0.3, cc.v2(-10, 0)),
  723. cc.scaleTo(0.3, 0)
  724. ),
  725. cc.callFunc(() => {
  726. node.destroy();
  727. })
  728. ))
  729. } else if (i != 0) {
  730. node.runAction(cc.moveTo(0.3, posArr[i - 1]));
  731. }
  732. }
  733. }
  734. let node = cc.instantiate(this["sprite_line" + (number == 0 ? "A" : "B")]);
  735. node.parent = this.layer_panelLine;
  736. node.active = true;
  737. node.setScale(0);
  738. node.position = posArr[length] ? posArr[length] : cc.v2(63, -3);
  739. node.runAction(cc.spawn(
  740. cc.moveTo(0.3, posArr[length - 1]),
  741. cc.scaleTo(0.3, 1),
  742. ));
  743. },
  744. async showWinAraeAnim(data, index) {
  745. return new Promise((resolve, reject) => {
  746. this._reject = reject;
  747. this.sprite_animAndar.active = index % 2 == 1;
  748. this.sprite_animBahar.active = index % 2 == 0;
  749. this.sprite_kuangAnimAndar.active = index % 2 == 1;
  750. this.sprite_kuangAnimBahar.active = index % 2 == 0;
  751. this.sprite_kuangAnimBank.active = true;
  752. setTimeout(resolve, 2000);
  753. });
  754. },
  755. async recoveryChips(data, index) {
  756. return new Promise((resolve, reject) => {
  757. this._reject = reject;
  758. let parent = this.layer_bank.getChildByName("sprite_playerHead");
  759. let targetNode = this.layer_chipShow.getChildByName(index % 2 == 0 ? "andar" : "bahar");
  760. for (let i = 0; i < targetNode.children.length; i += 1) {
  761. let node = targetNode.children[i];
  762. node.runAction(cc.sequence(
  763. cc.moveTo(0.2, parent.position),
  764. cc.callFunc(() => {
  765. this.putChip(node);
  766. }),
  767. ))
  768. }
  769. BRTPSoundFun.playEffectEX(BRTPSoundFun.EX_SCORE);
  770. setTimeout(resolve, 1000);
  771. });
  772. },
  773. async showWinerChipsMove1(data, index) {
  774. return new Promise((resolve, reject) => {
  775. this._reject = reject;
  776. this._chipAnim = [];
  777. let chipArr = [];
  778. let bank = this.layer_bank.getChildByName("sprite_playerHead");
  779. let winArae = this.layer_chipShow.getChildByName(index % 2 == 0 ? "bahar" : "andar");
  780. for (let i = 0; i < winArae.children.length; i += 1) {
  781. chipArr.push(winArae.children[i]);
  782. }
  783. for (let i = 0; i < this._playerJettonArr.length; i += 1) {
  784. this._chipAnim[i] = [];
  785. for (let k = 0; k < this._playerJettonArr[i][(index + 1) % 2].length; k += 1) {
  786. let num = this._playerJettonArr[i][(index + 1) % 2][k];
  787. let node1 = null;
  788. chipArr.find((item, itemIndex) => {
  789. if (item.name == num) {
  790. node1 = item;
  791. chipArr.splice(itemIndex, 1);
  792. return true;
  793. }
  794. return false;
  795. });
  796. let node2 = this.getChip(node1.name);
  797. this._chipAnim[i].push(node1, node2);
  798. this.animManager.moveChips({ cbBetArea: (index + 1) % 2 }, node2, bank.position);
  799. }
  800. }
  801. BRTPSoundFun.playEffectEX(BRTPSoundFun.EX_SCORE);
  802. setTimeout(resolve, 1000);
  803. });
  804. },
  805. async showWinerChipsMove2(data, index) {
  806. return new Promise((resolve, reject) => {
  807. this._reject = reject;
  808. let mySelfWinNumber = data.lPlayerWinScore;
  809. let chiarWinNumber = data.lSeatUserWinScore;
  810. let standWinNumber = data.lOtherPlayerWinScore;
  811. cc.log(mySelfWinNumber, chiarWinNumber, standWinNumber, "//////////////////////////////////////////");
  812. for (let i = 0; i < this._chipAnim.length; i += 1) {
  813. let node = null;
  814. if (i == this._chipAnim.length - 1) {
  815. node = this.button_playerCount;
  816. } else if (i == this._chipAnim.length - 2) {
  817. node = this.layer_chairPlayer.children[this.layer_chairPlayer.children.length - 1];
  818. } else {
  819. node = this.layer_chairPlayer.children[i];
  820. let script = node._saveScript;
  821. if (!script) {
  822. node = this.layer_chairPlayer.children[this.layer_chairPlayer.children.length - 1];
  823. }
  824. }
  825. for (let j = 0; j < this._chipAnim[i].length; j += 1) {
  826. let chip = this._chipAnim[i][j];
  827. chip.runAction(cc.sequence(
  828. cc.delayTime(0.5),
  829. cc.moveTo(0.3, node.position),
  830. cc.callFunc(() => {
  831. this.putChip(chip);
  832. })
  833. ))
  834. }
  835. }
  836. BRTPSoundFun.playEffectEX(BRTPSoundFun.EX_SCORE);
  837. setTimeout(resolve, 1000);
  838. });
  839. },
  840. showWinerPlayerAnim(data, index) {
  841. console.error(data.lSeatUserWinScore);
  842. this._reject = null;
  843. let mySelfWinNumber = data.lPlayerWinScore;
  844. let chiarWinNumber = data.lSeatUserWinScore;
  845. let standWinNumber = data.lOtherPlayerWinScore;
  846. let node1 = this.button_playerCount.getChildByName("spine_playerWin");
  847. let node2 = this.button_playerCount.getChildByName("sprite_playerWin");
  848. let node3 = this.button_playerCount.getChildByName("sprite_playerFail");
  849. let ojb = {
  850. 0: 3,
  851. 1: 4,
  852. 2: 5,
  853. 3: 0,
  854. 4: 1,
  855. 5: 2
  856. };
  857. for (let i = 0; i < 6; i += 1) {
  858. let script = this.layer_chairPlayer.children[i]._saveScript;
  859. if (script && this.getSelfPlayer().getChairID() == script.getChairID()) { continue; }
  860. script && script.endGameAnim(chiarWinNumber[ojb[i]]);
  861. }
  862. this._chipCache[this._gameNum][3] = mySelfWinNumber;
  863. this.myselfScript.setScore(data.lPlayerRestScore);
  864. this.myselfScript.endGameAnim(mySelfWinNumber);
  865. this.animManager.endGameAnim(node1, node2, node3, standWinNumber);
  866. if (data.lPlayerRestScore > 0) {
  867. this._playGameNum = 0;
  868. BRTPSoundFun.playEffectEX(BRTPSoundFun.EX_GAME_WIN);
  869. } else if (data.lPlayerRestScore == 0) {
  870. this._playGameNum += 1;
  871. } else {
  872. this._playGameNum = 0;
  873. }
  874. },
  875. /*-----------------------------------------------------------------------------------------------------------*/
  876. cleanRoom() {
  877. let cleanArr = [this.layer_bankPoker, this.layer_andarPoker, this.layer_baharPoker];
  878. for (let i = 0; i < 3; i += 1) {
  879. let parent = cleanArr[i];
  880. while (parent.children.length > 0) {
  881. let node = parent.children[0];
  882. node.active = false;
  883. node.parent = this.pool_card;
  884. }
  885. }
  886. for (let i = 0; i < this.layer_chipShow.children.length; i += 1) {
  887. let parent = this.layer_chipShow.children[i];
  888. while (parent.children.length > 0) {
  889. let node = parent.children[0];
  890. node.active = false;
  891. node.parent = this.pool_card;
  892. }
  893. }
  894. },
  895. hideABAnim() {
  896. this.sprite_animAndar.active = false;
  897. this.sprite_animBahar.active = false;
  898. this.sprite_kuangAnimAndar.active = false;
  899. this.sprite_kuangAnimBahar.active = false;
  900. this.sprite_kuangAnimBank.active = false;
  901. },
  902. hideMenu() {
  903. let menuNode = this.menuNode;
  904. this.menuOpenState = false;
  905. let menuBtn = UIHelper.pathGetNode(this.node, "TP_Base/layer_top/btn_menu");
  906. menuBtn.stopAllActions();
  907. cc.tween(menuBtn)
  908. .to(0.1, { angle: 0 })
  909. .start()
  910. menuNode.stopAllActions();
  911. cc.tween(menuNode)
  912. .to(0.1, { scaleY: 0 })
  913. .start()
  914. },
  915. exitToLobby() {
  916. let menuNode = this.menuNode;
  917. this.menuOpenState = !this.menuOpenState;
  918. let menuBtn = UIHelper.pathGetNode(this.node, "TP_Base/layer_top/btn_menu");
  919. menuBtn.stopAllActions();
  920. cc.tween(menuBtn)
  921. .to(0.1, { angle: this.menuOpenState ? 90 : 0 })
  922. .start()
  923. menuNode.stopAllActions();
  924. cc.tween(menuNode)
  925. .to(0.1, { scaleY: this.menuOpenState ? 1 : 0 })
  926. .delay(8)
  927. .call(() => {
  928. if (this.menuOpenState) {
  929. this.hideMenu();
  930. }
  931. })
  932. .start()
  933. },
  934. onBtnRule() {
  935. this.layer_help = UIHelper.pathGetNode(this.node, "layer_help");
  936. this.layer_help.active = !this.layer_help.active;
  937. },
  938. onBtnExitToLobby() {
  939. UIHelper.playButtonEffect("open");
  940. ScenceManager.Instance().getGameComponent().exitGameWhenPlaying();
  941. },
  942. exitGameWhenPlaying() {
  943. this.backHome();
  944. },
  945. LackOfGoldWillExitGame() {
  946. ScenceManager.Instance().gameBackScence();
  947. GameManagerBase.Instance().setInGameServerID(-1);
  948. CServerItem.get().PerformStandUpAction(1);
  949. this.exitGame();
  950. UIHelper.nodeMAP = new Map();
  951. cc.vv.GetHallScript().showShortage(GameManagerBase.Instance().getGameServerItem());
  952. },
  953. //返回大厅
  954. backHome() {
  955. if (this.GameState == 1 && this._nowInChip > 0) {
  956. topTipMsg.showTopTipMsg("BRTP.exit_tip");
  957. } else {
  958. ScenceManager.Instance().gameBackScence();
  959. GameManagerBase.Instance().setInGameServerID(-1);
  960. CServerItem.get().PerformStandUpAction(1);
  961. this.exitGame();
  962. UIHelper.nodeMAP = new Map();
  963. }
  964. },
  965. onSubSendControlInfo(data) {
  966. if (BaseDefine.LOCALTEST) {
  967. this.node.getChildByName("ControlInfo").active = true;
  968. this._controlInfo = [data];
  969. this.showControlInfo();
  970. }
  971. },
  972. showControlInfo() {
  973. const infoNode = cc.find("ControlInfo/info", this.node);
  974. if (!infoNode.active) return;
  975. const areaType = ["----", "----", "----", "----"];
  976. let cbControlArea = this._controlInfo[0].cbControlArea;
  977. let txt = `<b>`
  978. + `<color=#ffffff>\t\t\t\t\t\t房间杀率:${parseFloat(this._controlInfo[0].RoomSha / 100.0).toFixed(2)}%</c> `
  979. + `<color=#ffffff>触发系统赢:\n\t\t\t\t\t\t${parseFloat(this._controlInfo[0].RoomWin / 100.0).toFixed(2)}%</c> `
  980. + `<color=#ffffff>触发系统输:${parseFloat(this._controlInfo[0].RoomLost / 100.0).toFixed(2)}%</c>`
  981. + `<color=#ffffff>触发系统输:${cbControlArea == 255 ? "不控制" : cbControlArea == 0 ? "控A区" : "控B区"}</c >\n`;
  982. for (let i = 0; i < this._controlInfo.length; ++i) {
  983. let data = this._controlInfo[i];
  984. txt += `< color=#ffffff > ${areaType[i]}: </c > `
  985. + (
  986. (!!data.IsDanKong) ? (
  987. `< color=#ffffff > 单控有</c > `
  988. + `< color=#ffffff > 单控玩家${(data.DanType == 1) ? "输" : ((data.DanType == 2) ? "赢" : "无")}</c > `
  989. + `< color=#ffffff > 随到${data.RoomSuiRate} %</c > `
  990. + `< color=#ffffff > 玩家: ${data.szNickName}</c > `
  991. + `< color=#ffffff > 门槛: ${data.DanMinBet}</c > `
  992. ) : (
  993. (!!data.QunState) ? (
  994. `< color=#ffffff > 群控${(data.RoomResult == 1) ? "系统赢" : ((data.RoomResult == 2) ? "系统输" : "无控制")}</c > `
  995. + `< color=#ffffff > 随到概率${parseFloat(data.RoomSuiRate / 100.0).toFixed(2)}%</c >\t`
  996. ) : (
  997. `< color=#ffffff > 单控无, 群控无</c > `
  998. )
  999. )
  1000. )
  1001. + `\n`;
  1002. }
  1003. txt += `</b > `;
  1004. infoNode.getChildByName("label").getComponent(cc.RichText).string = txt;
  1005. },
  1006. hideControlInfo() {
  1007. this.node.getChildByName("ControlInfo").getChildByName("info").active = !this.node.getChildByName("ControlInfo").getChildByName("info").active;
  1008. },
  1009. onBtnGameSettings() {
  1010. UIHelper.playButtonEffect("open");
  1011. var self = this;
  1012. UIHelper.showWaitNode("loadResSingle", "");
  1013. cc.resources.load("GamePrefabs/homescence/set", cc.Prefab, function (err, prefab) {
  1014. UIHelper.hideWaitNode();
  1015. if (!self._set) {
  1016. self._set = cc.instantiate(prefab);
  1017. self._set.parent = self.node;
  1018. self._set.zIndex = (100);
  1019. }
  1020. self._set.getComponent("homeSet").showSet();
  1021. self._set.getComponent("homeSet").hideNode();
  1022. });
  1023. },
  1024. });