FruitGameSence.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. var GameBase = require("LBGameBase");
  2. var ProtocolGameServer = require("ProtocolGameServer");
  3. var GameProtocol = require("FruitGameProtocol");
  4. var AnalyzeXieYi = require("AnalyzeFruitXieYi");
  5. var MakeXieYi = require("MakeFruitXieYi");
  6. var Global = require("Global");
  7. var topTipMsg = require("topTipMsg");
  8. var UIHelper = require("UIHelper");
  9. var BaseDefine = require("BaseDefine");
  10. import { CServerItem } from 'CServerItem'
  11. import GameManagerBase from 'GameManagerBase'
  12. import ScenceManager from 'HNScenceManager'
  13. // const GAME_FREE = 0; //无
  14. // const GAME_PLAYING = 1; //游戏中
  15. // const GAME_END = 2; //游戏结束
  16. // const GAME_PLAYSCOREING = 3; //表现分数增加中
  17. // const GAME_GAMEEND = 4; //游戏真正结束
  18. cc.Class({
  19. extends: GameBase,
  20. editor: {
  21. menu: 'Game/Fruit/GameSence'
  22. },
  23. properties: {
  24. // rollNode: cc.Node,
  25. // playerScore: cc.Label,
  26. // recordPanel: cc.Node,
  27. // recordContent: cc.Node,
  28. // recordClone: cc.Node,
  29. // backPanel: cc.Node,
  30. // setPanel: cc.Node,
  31. // resultNode: cc.Node,
  32. // guideNode: cc.Node,
  33. freeLeftNode: cc.Node,
  34. winSpineData: [sp.SkeletonData],
  35. // _gameEnd: true,
  36. // _bQuickGame: false,
  37. // _bAutoGame: false,
  38. // _bFreeGame: false,
  39. // _nAutoCount: 0,
  40. // _nFreeCount: 0,
  41. // _nFreeTotal: 0,
  42. // _bFreeState: 0,
  43. // _nFreeWin: 0,
  44. // _currentScore: 0,
  45. // _lastScore: 0,
  46. // _nowBet: 0,
  47. // _playingAudioID: -1,
  48. // _bFirstIn: true,
  49. },
  50. onLoad () {
  51. this._super();
  52. this.LG_PATH_SC = "LB-Fruit/";
  53. this.homeBtn.active = !cc.vv.config.ReviewApk;
  54. },
  55. getRandomValue(i) {
  56. if(i == 0) {
  57. return this.rollPanel.getRandomValue();
  58. }
  59. let ddd = Math.floor(Math.random()*100);
  60. if(ddd > 90) {
  61. return 11;
  62. }
  63. return ddd % 8;
  64. },
  65. onEventSceneMessage(gameStatus,lookonUser,data) {
  66. Global.print("GameSence onEventSceneMessage 场景消息 ");
  67. var arr = new DataView(data.slice(0, 8));
  68. var dataView = new DataView(data.slice(8));
  69. var msgHead = { m: arr.getUint16(4, true), s: arr.getUint16(6, true), d: null };
  70. arr = null;
  71. this.gameConfig = AnalyzeXieYi.analyze_GameConfig(dataView);
  72. Global.print(this.gameConfig);
  73. this.bets = this.gameConfig.nJetton;
  74. this.refrushBet();
  75. },
  76. onEventGameMessage(data) {
  77. var arr = new DataView(data.slice(0, 8));
  78. var dataView = new DataView(data.slice(8));
  79. var msgHead = { m: arr.getUint16(4, true), s: arr.getUint16(6, true), d: null };
  80. arr = null;
  81. // Global.print(msgHead)
  82. var msg = AnalyzeXieYi.analyzeData(msgHead.m, msgHead.s, dataView);
  83. switch (msgHead.s) {
  84. case GameProtocol.SUB_S_REBACK_LOTTERY: { // 操作记录
  85. Global.print("SGLB::结果");
  86. this.onRollEndInfo(msg);
  87. }
  88. break;
  89. case GameProtocol.SUB_S_JACKPOT_RESET: { // 操作记录
  90. Global.print("JACKPOT");
  91. // this.showOperateRecordPanel(msg);
  92. }
  93. break;
  94. case GameProtocol.SUB_S_SEND_CONTROL_INFO: {
  95. Global.print("SUB_S_SEND_CONTROL_INFO");
  96. this.onSubSendControlInfo(msg);
  97. }
  98. break;
  99. default: {
  100. Global.print("SGLBGameSence onEventGameMessage error ");
  101. }
  102. break;
  103. }
  104. },
  105. showDebugRewardInfo() {
  106. let count = this.gameEndData.m_line_count;
  107. let lineid = this.gameEndData.m_line_id;
  108. let str = "中奖信息:" + count + "条线[";
  109. for(let i = 0; i < count; ++i) {
  110. str += (lineid[i]+1) + ',';
  111. }
  112. str += ']';
  113. str += this.gameEndData.m_kongming == 1 ? "\n中免费次数" : "";
  114. const infoNode = cc.find("ControlInfo/info", this.node);
  115. infoNode.getChildByName("reward").getComponent(cc.RichText).string = str;
  116. },
  117. onEventGameRecord(data) {
  118. let dd = AnalyzeXieYi.analyze_Record(data);
  119. this._gameRecords.push(dd);
  120. this.addOneRecord(dd);
  121. // if(this._gameRecords.length >= 60) {
  122. // this.showRecordsPanel();
  123. // }
  124. },
  125. backHome: function() {
  126. if (CServerItem.get()) {
  127. CServerItem.get().PerformStandUpAction(1);
  128. } else {
  129. this.exitGame();
  130. }
  131. this._backHome = true;
  132. ScenceManager.Instance().gameBackScence();
  133. GameManagerBase.Instance().setInGameServerID(-1);
  134. },
  135. onClickHome() {
  136. if(!this._gameEnd || this._nFreeCount > 0) {
  137. this.showBackTips();
  138. return;
  139. }
  140. this.backHome();
  141. this.exitGame();
  142. },
  143. onClickGoldBuy() {
  144. if(cc.vv.config.ReviewApk) return;
  145. // let FirstPay10State = cc.vv.GetHallScript().GetFirstPay10State();
  146. // let FirstPayState = cc.vv.GetHallScript().GetFirstPayState();
  147. // if(FirstPay10State){
  148. // cc.vv.GetHallScript().onClickFirstPay_10(null,true);
  149. // }else if(FirstPayState){
  150. // cc.vv.GetHallScript().onClickFirstPay(null,true);
  151. // }else{
  152. cc.vv.GetHallScript().showBuyGold();
  153. // }
  154. this.hideGuideNode();
  155. },
  156. showBackTips() {
  157. this.backPanel.active = true;
  158. },
  159. hideBackTips() {
  160. this.playEffect("button");
  161. this.backPanel.active = false;
  162. },
  163. onRollEndInfo(data) {
  164. Global.print(data);
  165. if(!this._bQuickGame)
  166. this.changeBtnState(true);
  167. this.gameEndData = data;
  168. if(this._nFreeCount > 0) {
  169. this.upFreeCount();
  170. }
  171. let endSp = data.cbFreeTime > 0;
  172. this._bFreeEnd = false;
  173. if(this._bSpecialGame || endSp) {
  174. this._bSpecialGame = endSp;
  175. this._nFreeWin += data.m_lottery_size;
  176. this._bFreeEnd = data.cbFreeTime == 0;
  177. }
  178. this._nFreeCount = data.cbFreeTime;
  179. this._nFreeTotal += data.cbFreeAdd;
  180. this._bFreeState = data.m_kongming;
  181. this._winTimes = Math.floor(data.m_lottery_size*5000 / data.m_chip_size);
  182. // setTimeout(()=>{
  183. this.rollPanel.setRollDatas(data);
  184. // this.rollPanel.openPrize(false, this._bQuickGame);
  185. this.rollPanel.openPrizes(false, this._bQuickGame);
  186. // }, 2000)
  187. // this.rollPanel.setRollDatas(data);
  188. // // this.rollPanel.openPrize(false, this._bQuickGame);
  189. // this.rollPanel.openPrizes(false, this._bQuickGame);
  190. this.showDebugRewardInfo();
  191. },
  192. makeXieYi(m,s,data) {
  193. if(m == ProtocolGameServer.MDM_GF_FRAME) {
  194. return //new DataView(arrayBuffer)
  195. }
  196. return MakeXieYi.makeRoll(data);
  197. },
  198. onClickRecord() {
  199. this.recordContent.removeAllChildren();
  200. this._gameRecords.splice(0);
  201. this.recordPanel.active = true;
  202. this.getGameRecord();
  203. },
  204. onSendRoll() {
  205. let t = {};
  206. t.nJetton = this.gameConfig.nJetton[this.curBetIndex];
  207. // Global.print(t);
  208. this.SendGameSocketData(GameProtocol.SUB_C_LOTTERY, t);
  209. },
  210. upLeftCount() {
  211. this.freeLeftNode.active = this._bSpecialGame;
  212. if(this._bSpecialGame) {
  213. this.freeLeftNode.getChildByName("left").getComponent(cc.Label).string = this._nFreeCount + '/' + this._nFreeTotal;
  214. }else{
  215. this._super();
  216. }
  217. },
  218. upFreeCount() {
  219. let funcNode = this.node.getChildByName("FuncBtnNode");
  220. let left = funcNode.getChildByName("btn_left");
  221. left.active = this._nFreeCount > 0;
  222. left.getChildByName("left").getComponent(cc.Label).string = (this._nFreeCount-1) + '/' + this._nFreeTotal;
  223. // this.upBtnInteractable(funcNode.getChildByName("btn_auto"), false);
  224. },
  225. // judgeAuto() {
  226. // let funcNode = this.node.getChildByName("FuncBtnNode");
  227. // if(this._nAutoCount == 0) {
  228. // this._bAutoGame = false;
  229. // }else{
  230. // this._bAutoGame = true;
  231. // }
  232. // funcNode.getChildByName("btn_left").active = this._bAutoGame;
  233. // let left = funcNode.getChildByName("btn_left");
  234. // left.active = this._bAutoGame;
  235. // left.getChildByName("left").active = this._nAutoCount > 0;
  236. // left.getChildByName("left2").active = this._nAutoCount < 0;
  237. // left.getChildByName("left").getComponent(cc.Label).string = this._nAutoCount;
  238. // },
  239. // onStartRoll() {
  240. // if(!this._gameEnd) return;
  241. // this.node.stopAllActions();
  242. // this.resetGameView();
  243. // cc.vv.audioMgr.stopSFX(this._playingAudioID);
  244. // //是否可以开始游戏
  245. // if(!this.judgeCannotRollGame()) {
  246. // return;
  247. // }
  248. // this._gameEnd = false;
  249. // this.changeGameState(1);
  250. // if(!cc.vv.audioMgr.resumeBackMusic()) {
  251. // cc.vv.audioMgr.playBGM(this.LG_PATH_SC + "bgm");
  252. // }
  253. // this.upLeftCount();
  254. // this.onSendRoll();
  255. // // this.testResult();
  256. // this.showCenterNormal();
  257. // this.onGameStart();
  258. // this.rollPanel.startRollActions();
  259. // },
  260. // resetGameView() {
  261. // this._super();
  262. // this.hideFreeWin();
  263. // },
  264. showGameEnd() {
  265. this._super();
  266. //获得免费次数
  267. if(this._bFreeState == 1) {
  268. cc.vv.audioMgr.pauseBackMusic();
  269. this.showGetFreeTimes(this.gameEndData.cbFreeAdd);
  270. }else if(this._bFreeEnd){
  271. //免费次数结束,自动游戏在其他地方判断
  272. }else if(this.winAniIdx < 0 || this._bSpecialGame){
  273. this.delayStartNextRoll(1);
  274. }
  275. },
  276. onClickSkip() {
  277. this.playButtonEffect();
  278. let scoreNode = this.resultNode.getChildByName("mask").getChildByName("scoreNode");
  279. this.skipScoreAdd(scoreNode.getChildByName("score").getComponent(cc.Label),scoreNode.getChildByName("score2").getComponent(cc.Label))
  280. },
  281. showResultPanel() {
  282. let ssNodeY = [-44,-103,-103,-150,-150];
  283. this.changeGameState(3);
  284. this.resultNode.active = true;
  285. let node = this.resultNode.getChildByName("mask");
  286. let goldNode = node.getChildByName("goldani");
  287. let ssNode = node.getChildByName("scoreNode");
  288. let sNode = ssNode.getChildByName("score");
  289. let sNode2 = ssNode.getChildByName("score2");
  290. let sLabel = sNode.getComponent(cc.Label);
  291. let sLabel2 = sNode2.getComponent(cc.Label);
  292. let aniNode1 = node.getChildByName("wani");
  293. aniNode1.active = true;
  294. goldNode.active = true;
  295. ssNode.active = false;
  296. let anii = aniNode1.getComponent(sp.Skeleton);
  297. anii.skeletonData = this.winSpineData[this.winAniIdx];
  298. if(this.winAniIdx > 0) {
  299. //金币动画
  300. let gAni = goldNode.getComponent(sp.Skeleton);
  301. gAni.clearTracks();
  302. gAni.setAnimation(0, 'a'+this.winAniIdx, true);
  303. }else{
  304. goldNode.active = false;
  305. }
  306. //win动画
  307. anii.clearTracks();
  308. anii.setAnimation(0, "a1", false);
  309. anii.addAnimation(0, "a2", true);
  310. this.resultNode.stopAllActions();
  311. cc.tween(this.resultNode)
  312. .delay(0.3)
  313. .call(()=>{
  314. if(this.winAniIdx>=0 && this.winAniIdx<ssNodeY.length)
  315. ssNode.y = ssNodeY[this.winAniIdx];
  316. ssNode.active = true;
  317. sLabel.string = '0';
  318. sLabel2.string = '.00';
  319. this.playScoreAddAni(sLabel, sLabel2);
  320. this.changeSkipBtnState(true);
  321. })
  322. .start()
  323. },
  324. hideResultPanel() {
  325. this.resultNode.active = false;
  326. },
  327. showGameWinScore() {
  328. this.winAniIdx = -1;
  329. this.needPlayinfScore = this.gameEndData.m_lottery_size;
  330. let score = this.gameEndData.m_lottery_size;
  331. //免费游戏中
  332. if(this._bSpecialGame) {
  333. if(this._bFreeState) {
  334. this.playEffect("freestart");
  335. }
  336. let nnode = this.node.getChildByName("RoomInfoNode").getChildByName("img_1");
  337. nnode.getChildByName("normalNode").active = false;
  338. nnode.getChildByName("winNode").active = true;
  339. nnode.getChildByName("winNode").getChildByName("score").getComponent(cc.Label).string = Global.formatString2Score(this._nFreeWin);
  340. return;
  341. }
  342. //免费游戏结束
  343. if(this.gameEndData.m_chip_size == 0) {
  344. cc.vv.audioMgr.playBGM("bgm");
  345. this.needPlayinfScore = this._nFreeWin;
  346. let timers = Math.floor(this._nFreeWin * 50 / this.gameConfig.nJetton[this.curBetIndex]);
  347. this._currentScore = this._lastScore;
  348. this.upPlayerScore(this._currentScore);
  349. // this.playSoundByTimes(timers);
  350. let nnode = this.node.getChildByName("RoomInfoNode").getChildByName("img_1");
  351. nnode.getChildByName("normalNode").active = false;
  352. nnode.getChildByName("winNode").active = true;
  353. nnode.getChildByName("winNode").getChildByName("score").getComponent(cc.Label).string = Global.formatString2Score(this._nFreeWin);
  354. this.showFreeWin();
  355. return;
  356. }
  357. let timers = Math.floor(score * 50 / this.gameConfig.nJetton[this.curBetIndex]);
  358. this._currentScore = this._lastScore;
  359. this.upPlayerScore(this._currentScore);
  360. if(score <= 0){
  361. return;
  362. }
  363. this.playSoundByTimes(timers);
  364. let nnode = this.node.getChildByName("RoomInfoNode").getChildByName("img_1");
  365. nnode.getChildByName("normalNode").active = false;
  366. nnode.getChildByName("winNode").active = true;
  367. nnode.getChildByName("winNode").getChildByName("score").getComponent(cc.Label).string = Global.formatString2Score(score);
  368. if(this.winAniIdx >= 0) {
  369. this.showResultPanel();
  370. }
  371. },
  372. delayStartNextRoll(delayTime) {
  373. if(!this._bSpecialGame) {
  374. this._nFreeTotal = 0;
  375. this.freeLeftNode.active = false;
  376. }
  377. this._super(delayTime);
  378. },
  379. showGetFreeTimes(times) {
  380. let freeNode = this.node.getChildByName("freeNode");
  381. let aniNode = freeNode.getChildByName("mask");
  382. // let ani = aniNode.getComponent(sp.Skeleton);
  383. // ani.clearTracks();
  384. // ani.setAnimation(0, "a1", false);
  385. freeNode.active = true;
  386. this._bSpecialGame = true;
  387. let sstr = aniNode.getChildByName("s");
  388. sstr.getComponent(cc.Label).string = times;
  389. sstr.stopAllActions();
  390. sstr.angle = 0;
  391. sstr.active = false;
  392. aniNode.stopAllActions();
  393. cc.tween(aniNode)
  394. .delay(0.4)
  395. .call(()=>{
  396. sstr.active = true;
  397. })
  398. .delay(0.2)
  399. .call(()=>{
  400. cc.tween(sstr)
  401. .to(1.4, {angle: -60})
  402. .start()
  403. })
  404. .delay(1.4)
  405. .call(()=>{
  406. freeNode.active = false;
  407. cc.vv.audioMgr.playBGM("freebgm");
  408. this.delayStartNextRoll(0.5);
  409. })
  410. .start()
  411. // cc.tween(freeNode.getChildByName("mark"))
  412. // .hide()
  413. // .delay(1+5)
  414. // .show()
  415. // .start()
  416. },
  417. showFreeWin() {
  418. if(this.gameEndData.m_kongming == 0) {
  419. this._nFreeWin = 0;
  420. }
  421. this.playEffect("freeend");
  422. let winNode = this.node.getChildByName("freeWin");
  423. winNode.active = true;
  424. let node = winNode.getChildByName("mask");
  425. let startBtn = node.getChildByName("btn_start");
  426. startBtn.active = false;
  427. let scoreNode = node.getChildByName("score1");
  428. scoreNode.stopAllActions();
  429. scoreNode.scale = 1;
  430. scoreNode.active = false;
  431. let ani = node.getComponent(sp.Skeleton);
  432. ani.clearTracks();
  433. ani.setAnimation(0, "b1", false);
  434. ani.setCompleteListener(()=>{
  435. ani.setCompleteListener(()=>{})
  436. ani.setAnimation(0, "b2", true);
  437. scoreNode.active = true;
  438. this.changeFreeWinBtn(true);
  439. this.playFreeWinAddAni(scoreNode.getComponent(cc.Label));
  440. })
  441. // winNode.stopAllActions();
  442. // cc.tween(winNode)
  443. // .delay(0.4)
  444. // .call(()=>{
  445. // // scoreNode.active = true;
  446. // // scoreNode.scale = 2;
  447. // // scoreNode.stopAllActions();
  448. // // cc.tween(scoreNode)
  449. // // .to(0.3, {scale: 1})
  450. // // .start()
  451. // })
  452. // .delay(2)
  453. // .call(()=>{
  454. // this.delayStartNextRoll(1);
  455. // })
  456. // .start()
  457. },
  458. hideFreeWin() {
  459. this.playButtonEffect();
  460. let winNode = this.node.getChildByName("freeWin");
  461. winNode.stopAllActions();
  462. if(!winNode.active){
  463. this.onStartRoll();
  464. return;
  465. }
  466. let node = winNode.getChildByName("mask");
  467. let ani = node.getComponent(sp.Skeleton);
  468. ani.clearTracks();
  469. ani.setAnimation(0, "b3", false);
  470. ani.setCompleteListener(()=>{
  471. ani.setCompleteListener(()=>{})
  472. winNode.active = false;
  473. this.onStartRoll();
  474. })
  475. },
  476. onClickSkipFreeWin() {
  477. this.playButtonEffect();
  478. let winNode = this.node.getChildByName("freeWin").getChildByName("mask");
  479. this.skipFreeWinAdd(winNode.getChildByName("score1").getComponent(cc.Label));
  480. },
  481. onClickFreeWinStart() {
  482. },
  483. playFreeWinAddAni(sLabel) {
  484. let start = 0;
  485. let bet = this.gameConfig.nJetton[this.curBetIndex];
  486. let endScore = Global.formatString2Score(this.needPlayinfScore);
  487. let add = parseFloat(bet/100/this.MAX_LINE);
  488. this.upFreeWinLabel = ()=>{
  489. start += add;
  490. if(start >= endScore) {
  491. this.skipFreeWinAdd(sLabel);
  492. }else{
  493. sLabel.string = parseFloat(start).toFixed(2);
  494. }
  495. }
  496. if(this.upFreeWinLabel) {
  497. this.unschedule(this.upFreeWinLabel);
  498. }
  499. this.schedule(this.upFreeWinLabel, 0.01);
  500. },
  501. skipFreeWinAdd(sLabel) {
  502. if(this.upFreeWinLabel) {
  503. this.unschedule(this.upFreeWinLabel);
  504. }
  505. let score = this.needPlayinfScore;
  506. sLabel.string = Global.formatString2Score(score);
  507. sLabel.node.stopAllActions();
  508. cc.tween(sLabel.node)
  509. .sequence(
  510. cc.tween().to(0.25, {scale: 0.9}),
  511. cc.tween().to(0.25, {scale: 1})
  512. )
  513. .repeatForever()
  514. .start()
  515. this.changeFreeWinBtn(false);
  516. let node = this.node.getChildByName("freeWin");
  517. node.stopAllActions();
  518. cc.tween(node)
  519. .delay(0.5)
  520. .call(()=>{
  521. if(this._bAutoGame)
  522. this.hideFreeWin();
  523. })
  524. .start()
  525. },
  526. changeFreeWinBtn(bSkip) {
  527. let winNode = this.node.getChildByName("freeWin").getChildByName("mask");
  528. winNode.getChildByName("btn_start").active = !bSkip;
  529. winNode.getChildByName("btn_skip").active = bSkip;
  530. },
  531. addOneRecord(info) {
  532. let item = cc.instantiate(this.recordClone);
  533. item.getChildByName("time").getComponent(cc.Label).string = Global.formatDate(new Date(info.nTime*1000));
  534. item.getChildByName("bet").getComponent(cc.Label).string = Global.formatString2Score(info.nBet);
  535. let win = info.nBet+info.nWinLost;
  536. // let col = new cc.Color(232, 232, 232);
  537. // if(win > 0) {
  538. // col = new cc.Color(248, 201, 39);
  539. // }
  540. // item.getChildByName("win").color = col;
  541. item.getChildByName("win").getComponent(cc.Label).string = Global.formatString2Score(win);
  542. item.active = true;
  543. item.parent = this.recordContent;
  544. },
  545. showRecordsPanel() {
  546. this.recordContent.removeAllChildren();
  547. for(let i = 0; i < this._gameRecords.length; ++i) {
  548. let info = this._gameRecords[i];
  549. let item = cc.instantiate(this.recordClone);
  550. item.getChildByName("time").getComponent(cc.Label).string = Global.formatDate(new Date(info.nTime*1000));
  551. item.getChildByName("bet").getComponent(cc.Label).string = Global.formatString2Score(info.nBet);
  552. let win = info.nBet+info.nWinLost;
  553. // let col = new cc.Color(232, 232, 232);
  554. // if(win > 0) {
  555. // col = new cc.Color(248, 201, 39);
  556. // }
  557. // item.getChildByName("win").color = col;
  558. item.getChildByName("win").getComponent(cc.Label).string = Global.formatString2Score(win);
  559. item.active = true;
  560. item.parent = this.recordContent;
  561. }
  562. this.recordPanel.active = true;
  563. },
  564. onClickSet() {
  565. this.playButtonEffect();
  566. this.setPanel.active = true;
  567. this.changeAudioBtnState();
  568. },
  569. showCenterNormal() {
  570. if(this._bSpecialGame) return;
  571. this.node.getChildByName("RoomInfoNode").getChildByName("img_1").getChildByName("normalNode").active = true;
  572. this.node.getChildByName("RoomInfoNode").getChildByName("img_1").getChildByName("winNode").active = false;
  573. },
  574. onClickRule() {
  575. this.playButtonEffect();
  576. UIHelper.loadRes('resourcesPrefab/ruleNode', cc.Prefab, (prefab)=>{
  577. if (!this._ruleNode) {
  578. this._ruleNode = cc.instantiate(prefab);
  579. this._ruleNode.parent = this.node;
  580. }
  581. this._ruleNode.getComponent("FruitRule").show();
  582. })
  583. },
  584. playSoundByTimes(_times) {
  585. if(_times <= 0) return;
  586. let id = 1;
  587. if(_times > 3000){
  588. id = 15;
  589. this.winAniIdx = 3;
  590. }else if(_times > 2500){
  591. id = 14;
  592. this.winAniIdx = 3;
  593. }else if(_times > 2000){
  594. id = 13;
  595. this.winAniIdx = 3;
  596. }else if(_times > 1600){
  597. id = 12;
  598. this.winAniIdx = 3;
  599. }else if(_times > 1200){
  600. id = 11;
  601. this.winAniIdx = 3;
  602. }else if(_times > 800){
  603. id = 10;
  604. this.winAniIdx = 3;
  605. }else if(_times > 500){
  606. id = 9;
  607. this.winAniIdx = 3;
  608. }else if(_times > 300){
  609. id = 8;
  610. this.winAniIdx = 2;
  611. }else if(_times > 200){
  612. id = 5;
  613. this.winAniIdx = 1;
  614. }else if(_times > 100){
  615. id = 4;
  616. this.winAniIdx = 0;
  617. }else if(_times > 50){
  618. id = 3;
  619. this.winAniIdx = -1;
  620. }else if(_times > 25){
  621. id = 2;
  622. this.winAniIdx = -1;
  623. }
  624. this.playEffect("Level"+id);
  625. },
  626. playButtonEffect(){
  627. this.playEffect("button");
  628. },
  629. });