GameScene.ts 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. import { _decorator, Button, Component, EventTouch, find, native, Label, math, Node, Prefab, sp, Sprite, SpriteAtlas, Tween, tween, Vec3 } from 'cc';
  2. import { GameRollNode } from './GameRollNode';
  3. import { GameConstant } from './GameConstant';
  4. import { ResourceLoader } from './ResourceLoader';
  5. import { Player } from './Player';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('GameScene')
  8. export class GameScene extends Component {
  9. @property(Node)
  10. bgNode: Node = null;
  11. @property(Node)
  12. slotRectNode: Node = null;
  13. @property(Node)
  14. rollNode: Node = null;
  15. @property(Node)
  16. btnStart: Node = null;
  17. @property(Node)
  18. btnStop: Node = null;
  19. @property(Node)
  20. btnStopAuto: Node = null;
  21. @property(Node)
  22. btnBetSub: Node = null;
  23. @property(Node)
  24. btnBetAdd: Node = null;
  25. @property(Node)
  26. btnAuto: Node = null;
  27. @property(Node)
  28. autoNode: Node = null;
  29. @property(Node)
  30. betScoreNode: Node = null;
  31. @property(Node)
  32. winTitle: Node = null;
  33. @property(Node)
  34. winScore: Node = null;
  35. @property(Node)
  36. playerScore: Node = null;
  37. @property(Node)
  38. hintTitle: Node = null;
  39. @property(Node)
  40. freeCountNode: Node = null;
  41. @property(Node)
  42. buyFreeNode: Node = null;
  43. @property(Node)
  44. buyFreeWindow: Node = null;
  45. @property(Node)
  46. transitionSpine: Node = null;
  47. @property(Node)
  48. resultNode: Node = null;
  49. @property(Node)
  50. freeWindowNode: Node = null;
  51. public bSpecialGame = false;
  52. public bQuickGame = false;
  53. public bAutoGame = false;
  54. public nAutoCount = 0;
  55. public autoIndex = -1;
  56. public curBetIndex = 0;
  57. public isGameEnd = true;
  58. public gameEndData = {
  59. "m_desk_data": [[1,4,7,6,2,10],[9,10,9,11,12,12],[6,3,11,11,8,12],[8,9,2,10,4,6]],//[[12,11,11,8,2,12],[12,11,9,8,8,4],[8,0,5,12,10,11],[8,12,1,12,10,9]],
  60. "m_wildTimes_data": [[1,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0]],//[[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0]],
  61. "m_isSpecialGame": 0,
  62. "m_freeCount": 0,
  63. "m_freeCountAdd": 0,
  64. "m_betIndex": 0,
  65. "m_lottery_size": 5000,
  66. "m_lCurScore":0,
  67. "m_line_icon": [],
  68. "m_line_size": [],
  69. "m_line_icon_active": [],
  70. "m_line_times": [],
  71. "m_line_index": [],
  72. "totalFreeCount": 0
  73. }
  74. public gameConfig = {
  75. "nJetton": [100,200,300,400,500],
  76. }
  77. public winAniIdx = -1;
  78. public allWinScore = 0;
  79. public currentScore = 0;
  80. public lastScore = 0;
  81. public isPlayingScoreAddAni = false;
  82. public upScoreLabel = undefined;
  83. public bFreeState = 0;
  84. public freeCount = 0;
  85. public freeCountAdd = 0;
  86. public isShowTransitionSpine = false;
  87. public isShowReverse = false;
  88. public gameResults =
  89. {
  90. "results": [],
  91. "totalFreeCount": 0,
  92. };
  93. public gameCounts = 0;
  94. public filePath = "";
  95. private httpRetryCount: number = 0;
  96. private maxRetries: number = 3;
  97. private hasHttpResponse: boolean = false;
  98. start() {
  99. this.upBetAddOrDelState();
  100. this.changeBtnState(false);
  101. this.gameConfig.nJetton = Player.getInstance().betConfig;
  102. this.playerScore.getComponent(Label).string = GameConstant.formatNumber(Player.getInstance().score);
  103. this.betScoreNode.getComponent(Label).string = GameConstant.formatNumber(this.gameConfig.nJetton[this.curBetIndex]);
  104. this.lastScore = Player.getInstance().score;
  105. }
  106. // onClick函数块------------------------------------------------------------------------
  107. onClickStart() {
  108. this.onStartRoll();
  109. }
  110. onClickStop() {
  111. this.onStopRoll();
  112. }
  113. onClickSkip() {
  114. // this.rollNode.getComponent(GameRollNode).showPrizes();
  115. // this.showGameWinScore();
  116. // this.showFreeWindow(0, false);
  117. this.showTransitionSpine(this.gameCounts++ % 2, ()=>{});
  118. }
  119. onClickBetSub() {
  120. this.curBetIndex--;
  121. // this.playButtonEffect();
  122. this.refreshBet();
  123. }
  124. onClickBetAdd() {
  125. this.curBetIndex++;
  126. // this.playButtonEffect();
  127. this.refreshBet();
  128. }
  129. onClickMax() {
  130. this.curBetIndex = this.gameConfig.nJetton.length-1;
  131. // this.playButtonEffect();
  132. this.refreshBet();
  133. }
  134. onClickAuto() {
  135. this.autoNode.active = true;
  136. }
  137. onClickAutoNumber(event: EventTouch, customData: string) {
  138. this.autoNode.active = false;
  139. this.nAutoCount = GameConstant.AUTO_TYPE_COUNT[parseInt(customData)];
  140. this.bAutoGame = true;
  141. // this.showStartAndStopButton(false);
  142. this.onStartRoll();
  143. }
  144. onClickStopAuto() {
  145. this.onCancelAutoRoll();
  146. }
  147. onCancelAutoRoll() {
  148. this.bAutoGame = false;
  149. this.nAutoCount = 0;
  150. // if(this._gameState == GAME_FREE) {
  151. // this.resetAllBtn();
  152. // }
  153. this.btnStopAuto.active = false;
  154. }
  155. onClickGameRule() {
  156. //
  157. }
  158. onClickBuyFree() {
  159. this.buyFreeWindow.active = true;
  160. }
  161. onClickBuyFreeWindowClose() {
  162. this.buyFreeWindow.active = false;
  163. }
  164. onClickBuyFreeWindowSure() {
  165. this.buyFreeWindow.active = false;
  166. }
  167. onClickResultMask() {
  168. // console.log("onClickResultMask this.isPlayingScoreAddAni = " + this.isPlayingScoreAddAni);
  169. if(this.isPlayingScoreAddAni) {
  170. this.skipScoreAdd(this.resultNode.getChildByName("scoreNode").getChildByName("scoreBg").getChildByName("score"));
  171. }else{
  172. // this.hideResultPanel();
  173. }
  174. }
  175. onClickFreeWindowMask() {
  176. this.freeWindowNode.active = false;
  177. if (this.isShowTransitionSpine) {
  178. this.showTransitionSpine(this.isShowReverse, ()=>{this.delayStartNextRoll(1);});
  179. } else {
  180. this.delayStartNextRoll(1);
  181. }
  182. this.isShowTransitionSpine = false;
  183. this.isShowReverse = false;
  184. Tween.stopAllByTarget(this.freeWindowNode);
  185. }
  186. onClickAutoMask() {
  187. this.autoNode.active = false;
  188. }
  189. // onClick函数块------------------------------------------------------------------------
  190. // UI刷新模块---------------------------------------------------------------------------
  191. refreshBet() {
  192. this.upBetAddOrDelState();
  193. let bet = this.gameConfig.nJetton[this.curBetIndex];
  194. this.betScoreNode.getComponent(Label).string = GameConstant.formatNumber(bet);
  195. }
  196. upBetAddOrDelState() {
  197. this.upBtnInteractable(this.btnBetSub, this.curBetIndex>0);
  198. this.upBtnInteractable(this.btnBetAdd, this.curBetIndex<this.gameConfig.nJetton.length-1);
  199. }
  200. upBtnInteractable(btn, state) {
  201. btn.getComponent(Button).interactable = state;
  202. }
  203. resetAllBtn() {
  204. if(this.bAutoGame || this.bSpecialGame) return;
  205. this.upBtnInteractable(this.btnStart, true);
  206. this.upBtnInteractable(this.btnStop, true);
  207. this.upBtnInteractable(this.btnAuto, true);
  208. // this.upBtnInteractable(this.maxBtn, true);
  209. this.upBetAddOrDelState();
  210. }
  211. onStartRoll() {
  212. if(!this.isGameEnd) return;
  213. Tween.stopAllByTarget(this.node);
  214. //是否可以开始游戏
  215. if(!this.judgeCannotRollGame()) {
  216. this.showStartAndStopButton(true);
  217. return;
  218. }
  219. this.isGameEnd = false;
  220. this.upLeftCount();
  221. this.onSendRoll();
  222. this.showCenterNormal();
  223. this.onGameStart();
  224. this.rollNode.getComponent(GameRollNode).startRollActions();
  225. }
  226. onStopRoll() {
  227. if(this.isGameEnd) {
  228. return;
  229. }
  230. this.rollNode.getComponent(GameRollNode).openPrizes(true, this.bQuickGame);
  231. this.onGameEnd();
  232. }
  233. upLeftCount() {
  234. if (this.bSpecialGame) {
  235. this.freeCount--;
  236. this.freeCountNode.active = true;
  237. this.freeCountNode.getChildByName("count").getComponent(Label).string = this.freeCount.toString();
  238. return;
  239. }
  240. if(!this.bAutoGame) return;
  241. this.nAutoCount--;
  242. this.bAutoGame = this.nAutoCount != 0;
  243. this.btnStopAuto.active = this.bAutoGame;
  244. let left = this.btnStopAuto.getChildByName("Label");
  245. left.active = true;
  246. if (this.nAutoCount > 0)
  247. left.getComponent(Label).string = this.nAutoCount.toString();
  248. else if (this.nAutoCount < 0)
  249. left.getComponent(Label).string = "∞";
  250. }
  251. showCenterNormal() {
  252. // console.log("enter showCenterNormal");
  253. if(this.bSpecialGame) return;
  254. this.winScore.getComponent(Label).string = "$" + '0';
  255. this.winScore.active = false;
  256. this.winTitle.active = false;
  257. this.hintTitle.active = true;
  258. this.hintTitle.getComponent(Label).string = "GOOD LUCK!";
  259. }
  260. showWinScoreTitle(score) {
  261. // console.log("enter showWinScoreTitle");
  262. this.winScore.getComponent(Label).string = GameConstant.formatNumber(score);
  263. this.winScore.active = true;
  264. this.winTitle.active = true;
  265. this.hintTitle.getComponent(Label).string = "GOOD LUCK!";
  266. this.hintTitle.active = false;
  267. }
  268. onGameStart() {
  269. this.upBtnInteractable(this.btnStart, false);
  270. this.upBtnInteractable(this.btnBetAdd, false);
  271. this.upBtnInteractable(this.btnBetSub, false);
  272. this.upBtnInteractable(this.btnAuto, false);
  273. }
  274. onGameEnd() {
  275. this.changeBtnState(false);
  276. }
  277. showGameEnd() {
  278. this.isGameEnd = true;
  279. //获得免费次数
  280. if (this.freeCountAdd > 0) {
  281. this.showFreeWindow(this.freeCountAdd, true);
  282. } else if(this.bFreeState == 1) {
  283. this.showFreeWindow(this.freeCount, false);
  284. } else if(this.winAniIdx < 0 || this.bSpecialGame){
  285. this.delayStartNextRoll(0.5);
  286. }
  287. }
  288. showGameWinScore() {
  289. this.winAniIdx = -1;
  290. //所有赢钱
  291. this.allWinScore += this.gameEndData.m_lottery_size;
  292. let score = this.gameEndData.m_lottery_size;
  293. console.log("showGameWinScore this.bSpecialGame = " + this.bSpecialGame + ", this.gameResults.results.length = " + this.gameResults.results.length + ", this.gameCounts = " + this.gameCounts);
  294. //免费游戏中
  295. if(this.bSpecialGame) {
  296. // if(this.bFreeState) {
  297. // this.playEffect("freestart");
  298. // }
  299. // let nnode = this.node.getChildByName("FuncBtnNode").getChildByName("betInfoBg").getChildByName("img_1");
  300. // nnode.getChildByName("normalNode").active = false;
  301. // nnode.getChildByName("winNode").active = true;
  302. this.showWinScoreTitle(this.allWinScore);
  303. return;
  304. }
  305. //免费游戏结束
  306. if(this.gameResults.results.length > 1 && this.gameCounts == 1) {
  307. // this.nowPlayBgm = "bgm";
  308. // cc.vv.audioMgr.playBGM("bgm");
  309. // this.needPlayinfScore = this.allWinScore;
  310. this.lastScore = this.currentScore + this.allWinScore;
  311. this.currentScore = this.lastScore;
  312. this.upPlayerScore(this.currentScore);
  313. this.showWinScoreTitle(this.allWinScore);
  314. this.showFreeWin();
  315. return;
  316. }
  317. this.lastScore = this.currentScore + this.allWinScore;
  318. let timers = Math.floor(score / this.gameConfig.nJetton[this.curBetIndex]);
  319. this.currentScore = this.lastScore;
  320. this.upPlayerScore(this.currentScore);
  321. if(score <= 0){
  322. return;
  323. }
  324. if (timers >= 50)
  325. this.winAniIdx = 3;
  326. else if (timers >= 35)
  327. this.winAniIdx = 2;
  328. else if (timers >= 20)
  329. this.winAniIdx = 1;
  330. else if (timers >= 5)
  331. this.winAniIdx = 0;
  332. else
  333. this.showWinScoreTitle(this.allWinScore);
  334. if(this.winAniIdx >= 0) {
  335. this.showResultPanel();
  336. }
  337. }
  338. hideResultPanel() {
  339. this.resultNode.active = false;
  340. let title = this.resultNode.getChildByName("scoreNode").getChildByName("title");
  341. Tween.stopAllByTarget(title);
  342. this.showWinScoreTitle(this.allWinScore);
  343. }
  344. showResultPanel() {
  345. this.resultNode.active = true;
  346. let goldAni = this.resultNode.getChildByName("goldAni");
  347. let title = this.resultNode.getChildByName("scoreNode").getChildByName("title");
  348. let winScore = this.resultNode.getChildByName("scoreNode").getChildByName("scoreBg").getChildByName("score");
  349. winScore.getComponent(Label).string = "$0";
  350. this.isPlayingScoreAddAni = true;
  351. // console.log("showResultPanel this.isPlayingScoreAddAni = " + this.isPlayingScoreAddAni);
  352. goldAni.active = this.winAniIdx > 0;
  353. goldAni.getComponent(sp.Skeleton).setAnimation(0, "a" + this.winAniIdx, true);
  354. let spriteFrameName = GameConstant.RESULT_TITLE[this.winAniIdx];
  355. title.getComponent(Sprite).spriteFrame = ResourceLoader.instance.getResource<SpriteAtlas>("atlas_BigWinCustom").getSpriteFrame(spriteFrameName);
  356. tween(title)
  357. .sequence(
  358. tween().to(0.5, {scale: new Vec3(1.2, 1.2, 1.2)}),
  359. tween().to(0.5, {scale: new Vec3(1, 1, 1)})
  360. )
  361. .repeatForever()
  362. .start()
  363. this.playScoreAddAni(winScore);
  364. // tween(this.resultNode)
  365. // .delay(0.3)
  366. // .call(()=>{
  367. // winScore.active = true;
  368. // this.playScoreAddAni(winScore);
  369. // })
  370. // .start()
  371. }
  372. playScoreAddAni(sLabel) {
  373. let start = 0;
  374. let bet = this.gameConfig.nJetton[this.curBetIndex];
  375. let endScore = this.allWinScore;
  376. let add = 0.01;
  377. Tween.stopAllByTarget(sLabel);
  378. this.upScoreLabel = ()=>{
  379. start += add;
  380. if(start >= endScore) {
  381. this.skipScoreAdd(sLabel);
  382. }else{
  383. sLabel.getComponent(Label).string = "$" + start.toFixed(2);
  384. }
  385. }
  386. if(this.upScoreLabel) {
  387. this.unschedule(this.upScoreLabel);
  388. }
  389. this.schedule(this.upScoreLabel, 0.01);
  390. }
  391. skipScoreAdd(sLabel) {
  392. if(this.upScoreLabel) {
  393. this.unschedule(this.upScoreLabel);
  394. }
  395. let score = this.allWinScore;
  396. sLabel.getComponent(Label).string = GameConstant.formatNumber(score);
  397. tween(sLabel)
  398. .repeat(
  399. 3,
  400. tween()
  401. .to(0.2, { scale: new Vec3(1.2,1.2,1.2) })
  402. .to(0.2, { scale: new Vec3(1.0,1.0,1.0) })
  403. )
  404. .call(()=>{
  405. this.hideResultPanel();
  406. this.delayStartNextRoll(1);
  407. })
  408. .start();
  409. this.isPlayingScoreAddAni = false;
  410. // console.log("skipScoreAdd this.isPlayingScoreAddAni = " + this.isPlayingScoreAddAni);
  411. }
  412. changeBtnState(bEnd) {
  413. if (this.bAutoGame) return;
  414. this.btnStop.active = bEnd;
  415. this.btnStart.active = !bEnd;
  416. }
  417. showStartAndStopButton(isShow) {
  418. this.btnStop.active = isShow;
  419. this.btnStart.active = isShow;
  420. }
  421. delayStartNextRoll(delayTime) {
  422. this.resetAllBtn();
  423. Tween.stopAllByTarget(this.node);
  424. tween(this.node)
  425. .delay(delayTime)
  426. .call(()=>{
  427. if(this.bAutoGame || this.bSpecialGame){ //自动游戏时
  428. this.onStartRoll();
  429. }
  430. })
  431. .start()
  432. }
  433. showFreeWindow(freeCount, isAdd) {
  434. console.log(freeCount, isAdd);
  435. this.isShowTransitionSpine = !isAdd;
  436. this.freeWindowNode.active = true;
  437. this.freeWindowNode.getChildByName("bg").getChildByName("freeCountsNode").active = false;
  438. this.freeWindowNode.getChildByName("bg").getChildByName("freeSpins").active = true;
  439. let freeCountLabel = this.freeWindowNode.getChildByName("bg").getChildByName("scoreBg").getChildByName("freeCount").getComponent(Label);
  440. freeCountLabel.string = (isAdd ? "+" : "") + freeCount.toString();
  441. this.freeCountNode.active = true;
  442. this.freeCountNode.getChildByName("count").getComponent(Label).string = this.freeCount.toString();
  443. tween(this.freeWindowNode)
  444. .delay(2)
  445. .call(()=>{ this.onClickFreeWindowMask(); })
  446. .start();
  447. }
  448. showFreeWin() {
  449. this.isShowTransitionSpine = true;
  450. this.isShowReverse = true;
  451. this.freeWindowNode.active = true;
  452. this.freeWindowNode.getChildByName("bg").getChildByName("freeCountsNode").active = true;
  453. this.freeWindowNode.getChildByName("bg").getChildByName("freeSpins").active = false;
  454. let freeCountLabel = this.freeWindowNode.getChildByName("bg").getChildByName("scoreBg").getChildByName("freeCount").getComponent(Label);
  455. freeCountLabel.string = GameConstant.formatNumber(this.allWinScore);
  456. find("bg/freeCountsNode/freeCount", this.freeWindowNode).getComponent(Label).string = "" + this.gameResults.totalFreeCount;
  457. this.freeCountNode.active = false;
  458. tween(this.freeWindowNode)
  459. .delay(2)
  460. .call(()=>{ this.onClickFreeWindowMask(); })
  461. .start();
  462. }
  463. // UI刷新模块---------------------------------------------------------------------------
  464. judgeCannotRollGame() {
  465. //下注配置为空
  466. if(!this.gameConfig || !this.gameConfig.nJetton || this.curBetIndex == null) {
  467. return false;
  468. }
  469. if(this.freeCount > 0) {
  470. return true;
  471. }
  472. //检测钱是否够用
  473. if(this.lastScore < this.gameConfig.nJetton[this.curBetIndex]) {
  474. // this.showLowLackMoney();
  475. return false;
  476. }
  477. this.currentScore = this.lastScore - this.gameConfig.nJetton[this.curBetIndex];
  478. this.upPlayerScore(this.currentScore);
  479. return true;
  480. }
  481. showTransitionSpine(isReverse, callback) {
  482. this.transitionSpine.active = true;
  483. this.transitionSpine.getComponent(sp.Skeleton).setAnimation(0, isReverse ? "transition_reverse" : "transition", false);
  484. this.transitionSpine.getComponent(sp.Skeleton).setCompleteListener((event)=>{
  485. this.transitionSpine.getComponent(sp.Skeleton).setCompleteListener(null)
  486. let bgFs = ResourceLoader.instance.getResource<SpriteAtlas>("bg_opaque_fs_landscape").getSpriteFrame("landscape");
  487. let bgNormal = ResourceLoader.instance.getResource<SpriteAtlas>("bg_opaque_normal_landscape").getSpriteFrame("bg_normal_landscape");
  488. let slotBgFs = ResourceLoader.instance.getResource<SpriteAtlas>("playfield_common").getSpriteFrame("playfield_frame_fs");
  489. let slotBgNormal = ResourceLoader.instance.getResource<SpriteAtlas>("playfield_common").getSpriteFrame("playfield_frame");
  490. this.bgNode.getComponent(Sprite).spriteFrame = event.animation.name == "transition" ? bgFs : bgNormal;
  491. this.slotRectNode.getComponent(Sprite).spriteFrame = event.animation.name == "transition" ? slotBgFs : slotBgNormal;
  492. callback();
  493. this.transitionSpine.active = false;
  494. });
  495. }
  496. /**
  497. * 发送游戏信息请求,失败会重试三次
  498. */
  499. sendHttpRequest() {
  500. const url = GameConstant.HTTP_HOST + "game-api/" + GameConstant.GAMEID + "/v2/spin";
  501. console.log("请求游戏信息:", url);
  502. GameConstant.httpRequest("POST", url, {cs: this.gameConfig.nJetton[this.curBetIndex], ml: 1}, false)
  503. .then((res: any) => {
  504. console.log("HTTP 回包成功:", res);
  505. this.hasHttpResponse = true;
  506. if (res.dt) {
  507. if (res.dt.si) {
  508. this.gameResults = res.dt.si;
  509. } else {
  510. this.gameResults = res.dt;
  511. }
  512. this.gameEndData = this.gameResults.results[0];
  513. this.gameCounts = this.gameResults.results.length;
  514. this.onRollEndInfo(this.gameEndData);
  515. }
  516. })
  517. .catch((err: any) => {
  518. this.httpRetryCount++;
  519. console.error(`HTTP 请求失败 (第 ${this.httpRetryCount} 次):`, err);
  520. if (this.httpRetryCount < this.maxRetries) {
  521. this.scheduleOnce(() => this.sendHttpRequest(), 0.5);
  522. } else {
  523. // TODO: 弹出提示框,提示用户重试或退出游戏
  524. console.error("三次重试失败,停止请求。");
  525. }
  526. });
  527. }
  528. onSendRoll() {
  529. if (this.gameResults.results.length > 1 && this.gameCounts > 1) {
  530. this.gameCounts--;
  531. this.gameEndData = this.gameResults.results[this.gameResults.results.length - this.gameCounts];
  532. this.scheduleOnce(()=>{
  533. this.onRollEndInfo(this.gameEndData);
  534. }, 0.5);
  535. } else {
  536. // spin请求
  537. this.sendHttpRequest();
  538. // this.scheduleOnce(()=>{
  539. // let results = GameConstant.playRound(this.gameConfig.nJetton[this.curBetIndex]);
  540. // console.log(results);
  541. // this.gameResults = results;
  542. // this.gameEndData = results.results[0];
  543. // this.gameCounts = results.results.length;
  544. // this.onRollEndInfo(this.gameEndData);
  545. // }, 0.5);
  546. }
  547. }
  548. onRollEndInfo(data) {
  549. if(!this.bQuickGame)
  550. this.changeBtnState(true);
  551. this.gameEndData = data;
  552. if(this.gameResults.results.length > 1) {
  553. // this.upFreeCount();
  554. }else{
  555. this.allWinScore = 0;
  556. this.freeCountAdd = 0;
  557. }
  558. this.bFreeState = data.m_isSpecialGame;
  559. this.freeCount = data.m_curTotalFreeCount;
  560. this.freeCountAdd = data.m_freeCountAdd
  561. this.bSpecialGame = data.m_curTotalFreeCount > 0;
  562. // 转动层数值传递
  563. this.rollNode.getComponent(GameRollNode).setRollDatas(data, this.bSpecialGame);
  564. this.rollNode.getComponent(GameRollNode).openPrizes(false, this.bQuickGame);
  565. }
  566. getSingleLineBet() {
  567. return this.gameConfig.nJetton[0];
  568. }
  569. upPlayerScore(score) {
  570. // cc.vv.globalUserInfo.setUserScore(score);
  571. this.playerScore.getComponent(Label).string = GameConstant.formatNumber(score);
  572. }
  573. }