LBGameBase.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. var GameBase = require("GameBase");
  2. var Global = require("Global");
  3. var topTipMsg = require("topTipMsg");
  4. var UIHelper = require("UIHelper");
  5. var BaseDefine = require("BaseDefine");
  6. var popScence = require("popScence");
  7. var ProtocolLoginServer = require("ProtocolLoginServer");
  8. const GAME_FREE = 0; //无
  9. const GAME_PLAYING = 1; //游戏中
  10. const GAME_END = 2; //游戏结束
  11. const GAME_PLAYSCOREING = 3; //表现分数增加中
  12. const GAME_GAMEEND = 4; //游戏真正结束
  13. cc.Class({
  14. extends: GameBase,
  15. properties: {
  16. //场景节点
  17. rollNode: cc.Node,
  18. playerScore: cc.Label,
  19. recordPanel: cc.Node,
  20. recordContent: cc.Node,
  21. recordClone: cc.Node,
  22. backPanel: cc.Node,
  23. setPanel: cc.Node,
  24. resultNode: cc.Node,
  25. guideNode: cc.Node,
  26. autoSelectNode: cc.Node,
  27. betNode: cc.Node,
  28. //功能按钮
  29. startBtn: cc.Node,
  30. stopBtn: cc.Node,
  31. skipBtn: cc.Node,
  32. addBtn: cc.Node,
  33. delBtn: cc.Node,
  34. maxBtn: cc.Node,
  35. stopAutoBtn: cc.Node,
  36. quickBtn: cc.Node,
  37. homeBtn: cc.Node,
  38. ruleBtn: cc.Node,
  39. recordBtn: cc.Node,
  40. setBtn: cc.Node,
  41. goldBtn: cc.Node,
  42. LG_PATH_SC: "",
  43. LP_PATH_SC: "LB-Public/",
  44. //其余游戏数据
  45. MAX_LINE: 50,
  46. _gameEnd: true,
  47. _backHome: false,
  48. _gameState: GAME_FREE,
  49. _bQuickGame: false,
  50. _bAutoGame: false,
  51. _bSpecialGame: false,
  52. _nAutoCount: 0,
  53. _bFreeGame: false,
  54. _nFreeCount: 0,
  55. _nFreeTotal: 0,
  56. _bFreeState: 0,
  57. _nFreeWin: 0,
  58. _currentScore: 0,
  59. _lastScore: 0,
  60. _nowBet: 0,
  61. _playingAudioID: -1,
  62. _startTouchStart: 0,
  63. _bFirstIn: true,
  64. _showControl: true,
  65. },
  66. // LIFE-CYCLE CALLBACKS:
  67. onLoad () {
  68. this.rollPanel = this.rollNode.getComponent("LBRollPanel");
  69. this.gameConfig = {};
  70. this.autoCount = [30, 50, 100, 500, -1];
  71. this.bets = [];
  72. this.addSetBtnListener();
  73. //向服务器请求游戏配置
  74. cc.vv.netSocket.registerEvent(ProtocolLoginServer.CMD_C2S_Game_Config,this.onGameRoomInfo,this);
  75. let kindID = cc.vv.serverListData.getCurRoomData().KindID;
  76. let roomID = cc.vv.serverListData.getCurRoomData().ServerID;
  77. let _data = {'CMD':ProtocolLoginServer.CMD_C2S_Game_Config, 'GameID':kindID, 'RoomID': roomID};
  78. cc.vv.netSocket.send(JSON.stringify(_data));
  79. },
  80. start () {
  81. this.node.parent = cc.director.getScene().getChildByName("Canvas");
  82. this.node.setPosition(0,0);
  83. // popScence.createPopScenceNode();
  84. cc.vv.audioMgr.stopBackMusic();
  85. this._gameEnd = true;
  86. this._backHome = false;
  87. this.changeGameState(GAME_FREE);
  88. this._bFirstIn = true;
  89. this._gameRecords = [];
  90. this.changeBtnState(false);
  91. this._lastScore = cc.vv.globalUserInfo.getUserScore();
  92. this.upPlayerScore(this._lastScore);
  93. this.curBetIndex = 0;
  94. this._playingAudioID = -1;
  95. this.upBetAddOrDelState();
  96. this.addNormalButtonListener();
  97. this.initStartTouchEvent();
  98. this._showControl = true;
  99. },
  100. // 服务器传来的格式和之前的不一样, 转换成之前的格式.
  101. conversionTable(tId){
  102. let table = {
  103. '1':0, '2': 10, '3': 20,
  104. '4':1, '5': 11, '6': 21,
  105. '7':2, '8': 12, '9': 22,
  106. '10':3, '11': 13, '12': 23,
  107. '13':4, '14': 14, '15': 24
  108. };
  109. for(let key in table){
  110. if(key == tId)
  111. return table[ Number(key)];
  112. }
  113. return '没有找到对应的值';
  114. },
  115. onGameRoomInfo(data){
  116. let lineMap = data.LineMap;
  117. this.rollPanel.linesArr = [];
  118. for(let key in lineMap){
  119. this.rollPanel.linesArr.push(lineMap[key].Line);
  120. }
  121. for(let i=0; i< this.rollPanel.linesArr.length; i++){
  122. for(let j=0; j < this.rollPanel.linesArr[i].length; j++){
  123. this.rollPanel.linesArr[i][j] = this.conversionTable(this.rollPanel.linesArr[i][j]);
  124. }
  125. }
  126. cc.vv.netSocket.removeEvent(ProtocolLoginServer.CMD_C2S_Game_Config,this.onGameRoomInfo,this);
  127. },
  128. testResult() {
  129. let data = {};
  130. data.cbFreeAdd = 0;
  131. data.cbFreeTime = 0;
  132. data.m_berserk_data1 = [];
  133. data.m_berserk_data2 = [];
  134. data.m_chair_id = 0;
  135. data.m_chip_size = this.bets[this.curBetIndex];
  136. data.m_deposit_lotttery = 0;
  137. data.m_is_berserk = 0;
  138. data.m_kongming = 0;
  139. data.m_ruyi = 0;
  140. data.m_lottery_size = 0;
  141. data.lCurScore = this._currentScore;
  142. data.m_line_count = 0;
  143. data.m_line_icon = [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, 0, 0, 0];
  144. data.m_line_id = [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, 0, 0, 0];
  145. data.m_line_size = [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, 0, 0, 0];
  146. data.m_line_times = [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, 0, 0, 0];
  147. data.m_desk_data = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]];
  148. for(let i = 0; i < 3; ++i) {
  149. for(let j = 0; j < 5; ++j) {
  150. data.m_desk_data[i][j] = this.getRandomValue(j);
  151. }
  152. }
  153. let iconTimes = [
  154. [0,0,5,10,25],
  155. [0,0,5,10,25],
  156. [0,0,5,10,25],
  157. [0,0,5,15,30],
  158. [0,0,5,15,30],
  159. [0,0,10,20,40],
  160. [0,0,10,20,40],
  161. [0,0,10,20,50],
  162. [0,0,10,25,70],
  163. [0,0,10,25,80]
  164. ]
  165. let linesArr = this.rollPanel.linesArr;
  166. let win = 0;
  167. for(let i = 0; i < 50; ++i) {
  168. let lineArr = linesArr[i];
  169. let count = 1;
  170. let startV = -1;
  171. for(let j = 0; j < lineArr.length; ++j) {
  172. let idx = lineArr[j];
  173. let x = idx % 10;
  174. let y = Math.floor(idx/10);
  175. // Global.print("x:"+x+" y:"+y)
  176. let value = data.m_desk_data[y][x];
  177. if(j == 0) {
  178. startV = value;
  179. }else{
  180. if(value == 11 || value == startV) {
  181. count++;
  182. }else{
  183. break;
  184. }
  185. }
  186. }
  187. if(count >= 3) {
  188. data.m_line_id[data.m_line_count] = i;
  189. data.m_line_size[data.m_line_count] = count;
  190. data.m_line_icon[data.m_line_count] = startV;
  191. data.m_line_times[data.m_line_count] = iconTimes[startV][count-1];
  192. win += data.m_line_times[data.m_line_count];
  193. data.m_line_count++;
  194. }
  195. }
  196. data.m_lottery_size = Global.unify(win*data.m_chip_size/50);
  197. data.lCurScore = this._currentScore + data.m_lottery_size;
  198. this._lastScore = data.lCurScore;
  199. cc.vv.globalUserInfo.setUserScore(this._lastScore*100);
  200. setTimeout(()=>{
  201. this.onRollEndInfo(data);
  202. }, 300);
  203. },
  204. getRandomValue(i) {
  205. if(i == 0) {
  206. return this.rollPanel.getRandomValue();
  207. }
  208. let ddd = Math.floor(Math.random()*100);
  209. if(ddd > 90) {
  210. return 11;
  211. }
  212. return ddd % 10;
  213. },
  214. //添加按钮事件
  215. addNormalButtonListener() {
  216. // UIHelper.addButtonListener(this.startBtn, this.node, "LBGameBase", "onClickStart");
  217. UIHelper.addButtonListener(this.stopBtn, this.node, "LBGameBase", "onClickStop");
  218. UIHelper.addButtonListener(this.skipBtn, this.node, "LBGameBase", "onClickSkip");
  219. UIHelper.addButtonListener(this.quickBtn, this.node, "LBGameBase", "onClickQuick");
  220. UIHelper.addButtonListener(this.addBtn, this.node, "LBGameBase", "onClickAdd");
  221. UIHelper.addButtonListener(this.delBtn, this.node, "LBGameBase", "onClickDel");
  222. UIHelper.addButtonListener(this.maxBtn, this.node, "LBGameBase", "onClickMax");
  223. UIHelper.addButtonListener(this.stopAutoBtn, this.node, "LBGameBase", "onClickStopAuto");
  224. UIHelper.addButtonListener(this.homeBtn, this.node, "LBGameBase", "onClickHome");
  225. UIHelper.addButtonListener(this.ruleBtn, this.node, "LBGameBase", "onClickRule");
  226. UIHelper.addButtonListener(this.recordBtn, this.node, "LBGameBase", "onClickRecord");
  227. UIHelper.addButtonListener(this.setBtn, this.node, "LBGameBase", "onClickSet");
  228. UIHelper.addButtonListener(this.goldBtn, this.node, "LBGameBase", "onClickGoldBuy");
  229. for(let i = 1; i < 6; ++i) {
  230. let btn = this.autoSelectNode.getChildByName("auto"+i);
  231. if(btn) {
  232. UIHelper.addButtonListener(btn, this.node, "LBGameBase", "onClickAuto", i-1);
  233. }
  234. }
  235. },
  236. initStartTouchEvent() {
  237. this.isShowAuto = false;
  238. this.clickSuccess = false;
  239. this.delayStartTouchShowAuto = ()=>{
  240. this.unschedule(this.delayStartTouchShowAuto);
  241. this.isShowAuto = true;
  242. this.onShowAuto();
  243. }
  244. this.unschedule(this.delayStartTouchShowAuto);
  245. this.startBtn.on(cc.Node.EventType.TOUCH_START, (event)=> {
  246. // cc.log("This is a callback after the trigger event");
  247. // this._startTouchStart = new Date().getTime();
  248. this.isShowAuto = false;
  249. this.clickSuccess = false;
  250. if(!this._gameEnd) {
  251. return false;
  252. }
  253. if(this.delayStartTouchShowAuto){
  254. this.unschedule(this.delayStartTouchShowAuto);
  255. }
  256. if(!this._bAutoGame && !this._bSpecialGame && this._gameEnd)
  257. this.schedule(this.delayStartTouchShowAuto, 1.5);
  258. this.clickSuccess = true;
  259. return true;
  260. });
  261. // this.startBtn.on(cc.Node.EventType.TOUCH_MOVE, (event)=> {
  262. // Global.print("MOVE");
  263. // Global.print(event);
  264. // });
  265. this.startBtn.on(cc.Node.EventType.TOUCH_END, (event)=> {
  266. // cc.log("TOUCH_END");
  267. if(this.delayStartTouchShowAuto){
  268. this.unschedule(this.delayStartTouchShowAuto);
  269. }
  270. if(this.isShowAuto) {
  271. this.isShowAuto = false;
  272. return;
  273. }
  274. if(this.autoSelectNode.scaleY >= 1) {
  275. this.onHideAuto();
  276. return;
  277. }
  278. if(!this.clickSuccess) return;
  279. this.onClickStart();
  280. });
  281. // this.startBtn.on(cc.Node.EventType.TOUCH_CANCEL, (event)=> {
  282. // Global.print("TOUCH_CANCEL");
  283. // Global.print(event);
  284. // });
  285. },
  286. refrushBet() {
  287. this.upBetAddOrDelState();
  288. let bet = this.bets[this.curBetIndex];
  289. this.betNode.getChildByName("allbet").getComponent(cc.Label).string = Global.formatString2Score(bet);
  290. this.betNode.getChildByName("bet").getComponent(cc.Label).string = ""+this.MAX_LINE+" x "+Global.formatString2Score(bet/this.MAX_LINE);
  291. },
  292. onClickCloseControlInfo() {
  293. this._showControl = false;
  294. this.node.getChildByName("ControlInfo").active = false;
  295. },
  296. // 控制数据
  297. onSubSendControlInfo(data) {
  298. // return;
  299. if(BaseDefine.LOCALTEST && this._showControl) {
  300. Global.print(data);
  301. this.node.getChildByName("ControlInfo").active = true;
  302. this._controlInfo = data;
  303. this.showControlInfo();
  304. }
  305. },
  306. showControlInfo() {
  307. const infoNode = cc.find("ControlInfo/info", this.node);
  308. if(!infoNode.active) return;
  309. let data = this._controlInfo;
  310. let txt = `<b>`
  311. + `<color=#ffffff>房间杀率:${parseFloat(data.RoomSha/100.0).toFixed(2)}%</c> `
  312. + `<color=#ffffff>触发系统赢:${parseFloat(data.RoomWin/100.0).toFixed(2)}%</c> `
  313. + `<color=#ffffff>触发系统输:${parseFloat(data.RoomLost/100.0).toFixed(2)}%</c>\n`
  314. + (
  315. (!!data.IsDanKong) ? (
  316. `<color=#ffffff>单控有</c> `
  317. + `<color=#ffffff>单控玩家${(data.DanType==1)? "输" : ((data.DanType==2)? "赢": "无")}</c> `
  318. + `<color=#ffffff>随到${data.RoomSuiRate}%</c> `
  319. + `<color=#ffffff>玩家: ${data.szNickName}</c> `
  320. + `<color=#ffffff>门槛: ${data.DanMinBet}</c>`
  321. ): (
  322. (!!data.QunState) ? (
  323. `<color=#ffffff>群控${(data.RoomResult==1)? "系统赢" : ((data.RoomResult==2)? "系统输": "无控制")}</c>`
  324. + `<color=#ffffff>随到概率${parseFloat(data.RoomSuiRate/100.0).toFixed(2)}%</c>\t`
  325. ): (
  326. `<color=#ffffff>单控无, 群控无</c>`
  327. )
  328. )
  329. )
  330. + `<color=#ffffff> 控制值${data.cbControlValue}</c>`
  331. infoNode.getChildByName("label").getComponent(cc.RichText).string = txt;
  332. },
  333. onSocketUpdateUniqueCode(data){
  334. Global.print(`收到唯一对局码: (${data.strUniqueCode})`);
  335. if(!data.strUniqueCode) {return;}
  336. // let roomNumNode = cc.find("RoomInfoNode/num", this.node);
  337. // roomNumNode.active = true;
  338. // roomNumNode.getComponent(cc.Label).string = data.strUniqueCode;
  339. },
  340. judgeCannotRollGame() {
  341. //下注配置为空
  342. if(!this.bets || !this.gameConfig || !this.gameConfig.nJetton || this.curBetIndex == null) {
  343. return false;
  344. }
  345. if(this._nFreeCount > 0) {
  346. return true;
  347. }
  348. //检测钱是否够用
  349. if(this._lastScore < Global.unify(this.bets[this.curBetIndex])) {
  350. // this.ShowGuideNode();
  351. this.showLowLackMoney();
  352. return false;
  353. }
  354. this._currentScore = this._lastScore - Global.unify(this.bets[this.curBetIndex]);
  355. this.upPlayerScore(this._currentScore);
  356. return true;
  357. },
  358. onStartRoll() {
  359. if(!this._gameEnd) return;
  360. this.node.stopAllActions();
  361. this.resetGameView();
  362. cc.vv.audioMgr.stopAllEffects();
  363. //是否可以开始游戏
  364. if(!this.judgeCannotRollGame()) {
  365. return;
  366. }
  367. this._gameEnd = false;
  368. this.changeGameState(GAME_PLAYING);
  369. if(!cc.vv.audioMgr.resumeBackMusic()) {
  370. cc.vv.audioMgr.playBGM("bgm");
  371. }
  372. this.upLeftCount();
  373. this.onSendRoll();
  374. this.showCenterNormal();
  375. this.onGameStart();
  376. this.rollPanel.startRollActions();
  377. },
  378. onStopRoll() {
  379. if(this._gameEnd) {
  380. return;
  381. }
  382. // this.rollPanel.openPrize(true, this._bQuickGame);
  383. this.rollPanel.openPrizes(true, this._bQuickGame);
  384. this.onGameEnd();
  385. },
  386. onRollEndInfo(data) {
  387. if(!this._bQuickGame)
  388. this.changeBtnState(true);
  389. this.gameEndData = data;
  390. this.rollPanel.setRollDatas(data);
  391. this.rollPanel.openPrizes(false, this._bQuickGame);
  392. },
  393. onCancelAutoRoll() {
  394. this._bAutoGame = false;
  395. this._nAutoCount = 0;
  396. if(this._gameState == GAME_FREE) {
  397. this.resetAllBtn();
  398. }
  399. this.stopAutoBtn.active = false;
  400. },
  401. onStartAutoRoll(autoC) {
  402. this._nAutoCount = autoC;
  403. this._bAutoGame = true;
  404. this.stopAutoBtn.active = true;
  405. this.onStartRoll();
  406. },
  407. upLeftCount() {
  408. if(!this._bAutoGame) return;
  409. this._nAutoCount--;
  410. this._bAutoGame = this._nAutoCount != 0;
  411. this.stopAutoBtn.active = this._bAutoGame;
  412. let left = this.stopAutoBtn.getChildByName("l");
  413. left.active = this._nAutoCount > 0;
  414. left.getComponent(cc.Label).string = this._nAutoCount;
  415. this.stopAutoBtn.getChildByName("ll").active = this._nAutoCount < 0;
  416. },
  417. resetGameView() {
  418. this.hideResultPanel();
  419. this.hideGuideNode();
  420. },
  421. resetAllBtn() {
  422. if(this._bAutoGame || this._bSpecialGame) return;
  423. this.upBtnInteractable(this.startBtn, true);
  424. this.upBtnInteractable(this.stopBtn, true);
  425. this.upBtnInteractable(this.maxBtn, true);
  426. this.upBetAddOrDelState();
  427. },
  428. onGameStart() {
  429. this.upBtnInteractable(this.startBtn, false);
  430. this.upBtnInteractable(this.addBtn, false);
  431. this.upBtnInteractable(this.delBtn, false);
  432. this.upBtnInteractable(this.maxBtn, false);
  433. },
  434. onGameEnd() {
  435. this.changeBtnState(false);
  436. },
  437. showGameEnd() {
  438. this._gameEnd = true;
  439. this.changeGameState(GAME_END);
  440. setTimeout(()=>{
  441. // Global.print("pauseBackMusic")
  442. if(this._gameEnd && !this._backHome) {
  443. // Global.print(this.node);
  444. cc.vv.audioMgr.pauseBackMusic();
  445. }
  446. }, 3000);
  447. },
  448. playScoreAddAni(sLabel, sLabel2) {
  449. let start = 0;
  450. let bet = this.gameConfig.nJetton[this.curBetIndex];
  451. let endScore = Global.formatString2Score(this.needPlayinfScore);
  452. let add = parseFloat(bet/10/this.MAX_LINE);
  453. this.upScoreLabel = ()=>{
  454. start += add;
  455. if(start >= endScore) {
  456. this.skipScoreAdd(sLabel, sLabel2);
  457. }else{
  458. sLabel.string = Math.floor(start);
  459. sLabel2.string = ((parseFloat(start - Math.floor(start)).toFixed(2)).toString()).slice(1);
  460. }
  461. }
  462. if(this.upScoreLabel) {
  463. this.unschedule(this.upScoreLabel);
  464. }
  465. this.schedule(this.upScoreLabel, 0.01);
  466. },
  467. skipScoreAdd(sLabel, sLabel2) {
  468. if(this.upScoreLabel) {
  469. this.unschedule(this.upScoreLabel);
  470. }
  471. let score = Global.formatString2Score(this.needPlayinfScore);
  472. sLabel.string = Math.floor(score);
  473. sLabel2.string = ((parseFloat(score - Math.floor(score)).toFixed(2)).toString()).slice(1);
  474. this.changeSkipBtnState(false);
  475. this.delayStartNextRoll(1);
  476. },
  477. delayStartNextRoll(delayTime) {
  478. this.changeGameState(GAME_FREE);
  479. this.resetAllBtn();
  480. this.node.stopAllActions();
  481. cc.tween(this.node)
  482. .delay(delayTime)
  483. .call(()=>{
  484. if(this._bAutoGame || this._bSpecialGame){ //自动游戏时
  485. this.onStartRoll();
  486. }
  487. })
  488. .start()
  489. },
  490. onShowAuto() {
  491. this.autoSelectNode.stopAllActions();
  492. cc.tween(this.autoSelectNode)
  493. .to(0.1, {scaleY: 1})
  494. .start()
  495. },
  496. onHideAuto() {
  497. this.autoSelectNode.stopAllActions();
  498. cc.tween(this.autoSelectNode)
  499. .to(0.1, {scaleY: 0})
  500. .start()
  501. },
  502. ShowGuideNode(){
  503. if(cc.vv.config.ReviewApk) return;
  504. this.guideNode.active = true;
  505. },
  506. hideRecordsPanel() {
  507. this.playButtonEffect();
  508. this.recordPanel.active = false;
  509. },
  510. hideGuideNode() {
  511. this.guideNode.active = false;
  512. },
  513. addSetBtnListener() {
  514. let node = this.setPanel.getChildByName("mask");
  515. UIHelper.addButtonListener(node.getChildByName("music_off"), this.node, "LBGameBase", "onClickSetAudio", 1);
  516. UIHelper.addButtonListener(node.getChildByName("music_on"), this.node, "LBGameBase", "onClickSetAudio", 2);
  517. UIHelper.addButtonListener(node.getChildByName("effect_off"), this.node, "LBGameBase", "onClickSetAudio", 3);
  518. UIHelper.addButtonListener(node.getChildByName("effect_on"), this.node, "LBGameBase", "onClickSetAudio", 4);
  519. UIHelper.addButtonListener(node.getChildByName("btn-gb"), this.node, "LBGameBase", "hideSetNode");
  520. },
  521. hideSetNode() {
  522. this.playButtonEffect();
  523. this.setPanel.active = false;
  524. },
  525. onClickSetAudio(event, data) {
  526. if(data == '1') {
  527. cc.vv.audioMgr.setBGMVolume(1, false, true);
  528. }else if(data == '2') {
  529. cc.vv.audioMgr.setBGMVolume(0, false, true);
  530. }else if(data == '3') {
  531. cc.vv.audioMgr.setSFXVolume(1);
  532. }else if(data == '4') {
  533. cc.vv.audioMgr.setSFXVolume(0);
  534. }
  535. this.changeAudioBtnState();
  536. },
  537. changeAudioBtnState() {
  538. let sfxVolume = cc.vv.audioMgr.sfxVolume;
  539. let bgmVolume = cc.vv.audioMgr.bgmVolume;
  540. let node = this.setPanel.getChildByName("mask");
  541. node.getChildByName("music_off").active = bgmVolume == 0;
  542. node.getChildByName("music_on").active = bgmVolume != 0;
  543. node.getChildByName("effect_off").active = sfxVolume == 0;
  544. node.getChildByName("effect_on").active = sfxVolume != 0;
  545. },
  546. changeGameState(state) {
  547. this._gameState = state;
  548. },
  549. changeSkipBtnState(bShow) {
  550. this.skipBtn.active = bShow;
  551. },
  552. changeBtnState(bEnd) {
  553. this.stopBtn.active = bEnd;
  554. this.startBtn.active = !bEnd;
  555. },
  556. upBetAddOrDelState() {
  557. this.upBtnInteractable(this.delBtn, this.curBetIndex>0);
  558. this.upBtnInteractable(this.addBtn, this.curBetIndex<this.bets.length-1);
  559. },
  560. upBtnInteractable(btn, state) {
  561. btn.getComponent(cc.Button).interactable = state;
  562. },
  563. /**
  564. * 快速:开启的话 默认无跳过,全部一起停止
  565. * @param {*} bQuick
  566. */
  567. onChangeQuick(bQuick) {
  568. this._bQuickGame = bQuick;
  569. },
  570. getQuickState() {
  571. return this._bQuickGame;
  572. },
  573. upPlayerScore(score) {
  574. this.playerScore.string = Global.formatString2Score(score);
  575. },
  576. onUserEnter(clientUserItem) {
  577. this._currentScore = clientUserItem.GetUserScore();
  578. this._lastScore = this._currentScore;
  579. this.upPlayerScore(this._lastScore);
  580. },
  581. upPlayerInfo(clientUserItem) {
  582. this._lastScore = clientUserItem.GetUserScore();
  583. },
  584. //按钮监听
  585. onClickStart() {
  586. this.playButtonEffect();
  587. this.onStartRoll();
  588. },
  589. onClickStop() {
  590. this.playButtonEffect();
  591. this.onStopRoll();
  592. },
  593. onClickSkip() {
  594. },
  595. onClickAdd() {
  596. this.curBetIndex++;
  597. this.playButtonEffect();
  598. this.refrushBet();
  599. },
  600. onClickDel() {
  601. this.curBetIndex--;
  602. this.playButtonEffect();
  603. this.refrushBet();
  604. },
  605. onClickMax() {
  606. this.curBetIndex = this.bets.length-1;
  607. this.playButtonEffect();
  608. this.refrushBet();
  609. },
  610. onClickStopAuto() {
  611. this.playButtonEffect();
  612. this.onCancelAutoRoll();
  613. },
  614. onClickAuto(event, eventdata) {
  615. if(eventdata >= this.autoCount.length) {
  616. return;
  617. }
  618. this.playButtonEffect();
  619. this.onHideAuto();
  620. this.onStartAutoRoll(this.autoCount[eventdata]);
  621. },
  622. onClickQuick(event) {
  623. this.playButtonEffect();
  624. this.onChangeQuick(!event.target.getComponent(cc.Toggle).isChecked);
  625. },
  626. onClickHome() {
  627. },
  628. onClickRule() {
  629. },
  630. onClickRecord() {
  631. },
  632. onClickSet() {
  633. },
  634. onClickGoldBuy() {
  635. },
  636. playButtonEffect() {
  637. },
  638. //播放音效
  639. playEffect(effName, needStop = false) {
  640. if(needStop)
  641. cc.vv.audioMgr.stopAllEffects();
  642. cc.vv.audioMgr.playSFX(effName);
  643. },
  644. //播放通用音效
  645. playLPEffect(effName, needStop = false) {
  646. if(needStop)
  647. cc.vv.audioMgr.stopAllEffects();
  648. cc.vv.audioMgr.playSFX(effName);
  649. },
  650. // update (dt) {
  651. // if(this.stopBackMusicTimes > 0) {
  652. // this.stopBackMusicTimes -= dt;
  653. // if(this.stopBackMusicTimes <= 0) {
  654. // cc.vv.audioMgr.pauseBackMusic();
  655. // }
  656. // }
  657. // },
  658. });