RaioGameSence.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258
  1. var GameBase = require("GameBase");
  2. var ProtocolGameServer = require("ProtocolGameServer");
  3. var GameProtocol = require("RaioGameProtocol");
  4. var AnalyzeXieYi = require("AnalyzeRaioXieYi");
  5. var MakeXieYi = require("MakeRaioXieYi");
  6. var Global = require("Global");
  7. var topTipMsg = require("topTipMsg");
  8. var UIHelper = require("UIHelper");
  9. var BaseDefine = require("BaseDefine");
  10. var GameConstant = require("GameConstant");
  11. const LanguageKey = require("LanguageKey");
  12. import { CServerItem } from 'CServerItem'
  13. import GameManagerBase from 'GameManagerBase'
  14. import ScenceManager from 'HNScenceManager'
  15. const GAME_FREE = 0; //无
  16. const GAME_PLAYING = 1; //游戏中
  17. const GAME_END = 2; //游戏结束
  18. const GAME_PLAYSCOREING = 3; //表现分数增加中
  19. const GAME_GAMEEND = 4; //游戏真正结束
  20. const ShowNextJackpotTime = 10;
  21. const CASH_TIMES = [0,0,0,2,3,4,5,6,7,8,10,15,25,42,72,125,250,500,1000,2000,5000];
  22. cc.Class({
  23. extends: GameBase,
  24. editor: {
  25. menu: 'Game/Raio/GameSence'
  26. },
  27. properties: {
  28. //场景节点
  29. rollNode: cc.Node,
  30. playerScore: cc.Label,
  31. resultNode: cc.Node,
  32. cashWinNode: cc.Node,
  33. lackMoneyNode: cc.Node,
  34. enterAni: cc.Node,
  35. winScoreNode: cc.Node,
  36. betNode: cc.Node,
  37. //功能按钮
  38. startBtn: cc.Node,
  39. stopBtn: cc.Node,
  40. addBtn: cc.Node,
  41. delBtn: cc.Node,
  42. autoBtn: cc.Node,
  43. menuBtn: cc.Node,
  44. homeBtn: cc.Node,
  45. LG_PATH_SC: "",
  46. LP_PATH_SC: "LB-Public/",
  47. //其余游戏数据
  48. MAX_LINE: 50,
  49. _gameEnd: true,
  50. _backHome: false,
  51. _gameState: GAME_FREE,
  52. _bAutoGame: false,
  53. _currentScore: 0,
  54. _lastScore: 0,
  55. _nowBet: 0,
  56. _playingAudioID: -1,
  57. _startTouchStart: 0,
  58. _bFirstIn: true,
  59. _showControl: true,
  60. ruleNode: cc.Node,
  61. winSpineData: [sp.SkeletonData],
  62. audioArr: [cc.AudioClip],
  63. // noticeNode: cc.Node,
  64. // noticeLabel: cc.Node,
  65. rightJackpotNode: cc.Node,
  66. rightJackpotPlayer1: cc.Node,
  67. rightJackpotPlayer2: cc.Node,
  68. rightJackpotPanel: cc.Node,
  69. rightJackPotClone: cc.Node,
  70. rightJackPotShowNode: cc.Node,
  71. rightJackPotContent: cc.Node,
  72. normalBGM: [cc.AudioClip],
  73. specialBGM: [cc.AudioClip],
  74. _normalBGMID: -1,
  75. _specialBGMID: -1,
  76. _nowIdx: -1,
  77. },
  78. playLightAni(){
  79. this.enterAni.active = true;
  80. let ani = this.enterAni.getComponent(sp.Skeleton);
  81. ani.clearTracks();
  82. ani.setAnimation(0, 'a1', false);
  83. ani.setCompleteListener(()=>{
  84. ani.setCompleteListener(null);
  85. this.enterAni.active = false;
  86. })
  87. },
  88. stopBgm() {
  89. if(this._normalBGMID != -1) {
  90. cc.audioEngine.stop(this._normalBGMID);
  91. this._normalBGMID = -1;
  92. }
  93. if(this._specialBGMID != -1) {
  94. cc.audioEngine.stop(this._specialBGMID);
  95. this._specialBGMID = -1;
  96. }
  97. },
  98. resumeBGM() {
  99. if(this._nowIdx < 0) {return;}
  100. if(this._nowIdx == 3) {
  101. this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[2], true, cc.vv.audioMgr.bgmVolume);
  102. this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[2], true, cc.vv.audioMgr.bgmVolume);
  103. }else if(this._nowIdx == 2) {
  104. this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[1], true, cc.vv.audioMgr.bgmVolume);
  105. this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[1], true, cc.vv.audioMgr.bgmVolume);
  106. }else{
  107. this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[0], true, cc.vv.audioMgr.bgmVolume);
  108. if(this._nowIdx == 1) {
  109. this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[0], true, cc.vv.audioMgr.bgmVolume);
  110. }
  111. }
  112. },
  113. changeBGM(cashCnt) {
  114. // cc.error(cashCnt);
  115. if(cashCnt <= 10) {
  116. if(cashCnt >= 3) {
  117. if(this._nowIdx == 1) {
  118. return;
  119. }
  120. }else{
  121. if(this._nowIdx == 0) {
  122. return;
  123. }
  124. }
  125. }else if(cashCnt <= 15) {
  126. if(this._nowIdx == 2) {
  127. return;
  128. }
  129. }else{
  130. if(this._nowIdx == 3) {
  131. return;
  132. }
  133. }
  134. this.stopBgm();
  135. if(cashCnt <= 10) {
  136. // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[0], true, cc.vv.audioMgr.bgmVolume);
  137. this._nowIdx = 0;
  138. if(cashCnt >= 3) {
  139. // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[0], true, cc.vv.audioMgr.bgmVolume);
  140. this._nowIdx = 1;
  141. }
  142. }else if(cashCnt <= 15) {
  143. // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[1], true, cc.vv.audioMgr.bgmVolume);
  144. // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[1], true, cc.vv.audioMgr.bgmVolume);
  145. this._nowIdx = 2;
  146. }else{
  147. // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[2], true, cc.vv.audioMgr.bgmVolume);
  148. // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[2], true, cc.vv.audioMgr.bgmVolume);
  149. this._nowIdx = 3;
  150. }
  151. if(cc.vv.audioMgr.bgmVolume <= 0) {
  152. return;
  153. }
  154. this.resumeBGM();
  155. // if(cashCnt <= 10) {
  156. // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[0], true, cc.vv.audioMgr.bgmVolume);
  157. // this._nowIdx = 0;
  158. // if(cashCnt >= 3) {
  159. // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[0], true, cc.vv.audioMgr.bgmVolume);
  160. // this._nowIdx = 1;
  161. // }
  162. // }else if(cashCnt <= 15) {
  163. // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[1], true, cc.vv.audioMgr.bgmVolume);
  164. // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[1], true, cc.vv.audioMgr.bgmVolume);
  165. // this._nowIdx = 2;
  166. // }else{
  167. // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[2], true, cc.vv.audioMgr.bgmVolume);
  168. // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[2], true, cc.vv.audioMgr.bgmVolume);
  169. // this._nowIdx = 3;
  170. // }
  171. },
  172. update(dt) {
  173. if(this.delayNextTime <= 0) {
  174. this.jumpNextJackpot();
  175. }else{
  176. this.delayNextTime -= dt;
  177. }
  178. },
  179. getItemSpineData(id) {
  180. if(this.rollPanel) {
  181. return this.rollPanel.getItemSpineData(id);
  182. }
  183. },
  184. onLoad () {
  185. this.rollPanel = this.rollNode.getComponent("RaioRollPanel");
  186. this.gameConfig = {};
  187. this.bets = [];
  188. this.LG_PATH_SC = "";
  189. this.judgeFuncArr = [];
  190. this.jackpotRecord = [];
  191. this.deskCashCnts = [];
  192. this.deskRecords = [];
  193. },
  194. start () {
  195. this.node.parent = cc.director.getScene().getChildByName("Canvas");
  196. this.node.setPosition(0,0);
  197. let player = this.getSelfPlayer();
  198. if(player)
  199. this._lastScore = player.getUserScore();
  200. this.upPlayerScore(this._lastScore);
  201. this._gameEnd = true;
  202. this._backHome = false;
  203. this.changeGameState(GAME_FREE);
  204. this._bFirstIn = true;
  205. this._gameRecords = [];
  206. this.changeBtnState(false);
  207. this.curBetIndex = 0;
  208. this._playingAudioID = -1;
  209. this.upBetAddOrDelState();
  210. this.addNormalButtonListener();
  211. this.nowShowIdx = 0;
  212. this.delayNextTime = ShowNextJackpotTime;
  213. this.jackpotRecord = [];
  214. this.getJackpotRecord();
  215. this.stopBtn.active = false;
  216. this.playLightAni();
  217. this.changeBGM(0);
  218. },
  219. //添加按钮事件
  220. addNormalButtonListener() {
  221. UIHelper.addButtonListener(this.startBtn, this.node, "RaioGameSence", "onClickStart");
  222. UIHelper.addButtonListener(this.stopBtn, this.node, "RaioGameSence", "onClickStop");
  223. UIHelper.addButtonListener(this.autoBtn, this.node, "RaioGameSence", "onClickQuick");
  224. UIHelper.addButtonListener(this.addBtn, this.node, "RaioGameSence", "onClickAdd");
  225. UIHelper.addButtonListener(this.delBtn, this.node, "RaioGameSence", "onClickDel");
  226. UIHelper.addButtonListener(this.menuBtn, this.node, "RaioGameSence", "onClickMenu");
  227. // UIHelper.addButtonListener(this.homeBtn, this.node, "RaioGameSence", "onClickHome");
  228. },
  229. onClickCloseControlInfo() {
  230. this._showControl = false;
  231. this.node.getChildByName("ControlInfo").active = false;
  232. },
  233. // 控制数据
  234. onSubSendControlInfo(data) {
  235. // return;
  236. if(BaseDefine.LOCALTEST && this._showControl) {
  237. Global.print(data);
  238. this.node.getChildByName("ControlInfo").active = true;
  239. this._controlInfo = data;
  240. this.showControlInfo();
  241. }
  242. },
  243. showControlInfo() {
  244. const infoNode = cc.find("ControlInfo/info", this.node);
  245. if(!infoNode.active) return;
  246. let data = this._controlInfo;
  247. let txt = `<b>`
  248. + `<color=#ffffff>房间杀率:${parseFloat(data.RoomSha/100.0).toFixed(2)}%</c> `
  249. + `<color=#ffffff>触发系统赢:${parseFloat(data.RoomWin/100.0).toFixed(2)}%</c> `
  250. + `<color=#ffffff>触发系统输:${parseFloat(data.RoomLost/100.0).toFixed(2)}%</c>\n`
  251. + (
  252. (!!data.IsDanKong) ? (
  253. `<color=#ffffff>单控有</c> `
  254. + `<color=#ffffff>单控玩家${(data.DanType==1)? "输" : ((data.DanType==2)? "赢": "无")}</c> `
  255. + `<color=#ffffff>随到${data.RoomSuiRate}%</c> `
  256. + `<color=#ffffff>玩家: ${data.szNickName}</c> `
  257. + `<color=#ffffff>门槛: ${data.DanMinBet}</c>`
  258. ): (
  259. (!!data.QunState) ? (
  260. `<color=#ffffff>群控${(data.RoomResult==1)? "系统赢" : ((data.RoomResult==2)? "系统输": "无控制")}</c>`
  261. + `<color=#ffffff>随到概率${parseFloat(data.RoomSuiRate/100.0).toFixed(2)}%</c>\t`
  262. ): (
  263. `<color=#ffffff>单控无, 群控无</c>`
  264. )
  265. )
  266. )
  267. + `<color=#ffffff> 控制值${data.cbControlValue}</c>`
  268. infoNode.getChildByName("label").getComponent(cc.RichText).string = txt;
  269. },
  270. onSocketUpdateUniqueCode(data){
  271. Global.print(`收到唯一对局码: (${data.strUniqueCode})`);
  272. if(!data.strUniqueCode) {return;}
  273. },
  274. judgeCannotRollGame() {
  275. //下注配置为空
  276. if(!this.bets || !this.gameConfig || !this.gameConfig.nJetton || this.curBetIndex == null) {
  277. return false;
  278. }
  279. //检测钱是否够用
  280. if(this._lastScore < Global.unify(this.bets[this.curBetIndex])) {
  281. // this.ShowGuideNode();
  282. this.showLowLackMoney();
  283. return false;
  284. }
  285. this._currentScore = this._lastScore - Global.unify(this.bets[this.curBetIndex]);
  286. this.upPlayerScore(this._currentScore);
  287. return true;
  288. },
  289. showLowLackMoney() {
  290. if(cc.vv.config.ReviewApk) {return;}
  291. this.lackMoneyNode.active = true;
  292. },
  293. lackClose() {
  294. this.lackMoneyNode.active = false;
  295. this.goldGameLeave();
  296. },
  297. lackSure() {
  298. this.lackMoneyNode.active = false;
  299. UIHelper.showWaitNode("loadResSingle", "")
  300. cc.vv.GetHallScript().showBuyGold(()=>{
  301. this.goldGameLeave();
  302. });
  303. },
  304. test() {
  305. ScenceManager.Instance().setGameComponent(this);
  306. this.gameConfig.nJetton = [50,100,500,5000]
  307. this.bets = [50,100,500,5000]
  308. this._currentScore = cc.vv.globalUserInfo.getUserScore();
  309. this._lastScore = cc.vv.globalUserInfo.getUserScore();
  310. this.curBetIndex = 0;
  311. this.leftFreeCount = 0;
  312. cc.vv.needFree = false;
  313. },
  314. testResult() {
  315. let data = {};
  316. data.cbFreeAdd = 0;
  317. data.cbFreeTime = this.leftFreeCount >= 0?this.leftFreeCount:0;
  318. data.m_berserk_data1 = [];
  319. data.m_berserk_data2 = [];
  320. data.m_chair_id = 0;
  321. data.m_chip_size = this.bets[this.curBetIndex];
  322. data.m_deposit_lotttery = 0;
  323. data.m_is_berserk = 0;
  324. data.m_kongming = 0;
  325. data.m_ruyi = 0;
  326. data.m_lottery_size = 0;
  327. data.lCurScore = this._currentScore;
  328. data.m_line_count = 0;
  329. 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];
  330. 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];
  331. 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];
  332. 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];
  333. data.m_desk_data = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]];
  334. let freeCount = 0;
  335. for(let i = 0; i < 3; ++i) {
  336. for(let j = 0; j < 5; ++j) {
  337. data.m_desk_data[i][j] = this.getRandomValue(j);
  338. if(i == 2 && j > 1 && cc.vv.needFree) {
  339. data.m_desk_data[i][j] = GameProtocol.FREE_ICON
  340. }
  341. if(data.m_desk_data[i][j] == GameProtocol.FREE_ICON) {
  342. freeCount++;
  343. }
  344. }
  345. }
  346. if(freeCount >= 3) {
  347. data.cbFreeTime = 5;
  348. data.cbFreeAdd = 5;
  349. data.m_kongming = 1;
  350. }
  351. let iconTimes = [
  352. [0,0,5,10,25],
  353. [0,0,5,10,25],
  354. [0,0,5,10,25],
  355. [0,0,5,15,30],
  356. [0,0,5,15,30],
  357. [0,0,10,20,40],
  358. [0,0,10,20,40],
  359. [0,0,10,20,50],
  360. [0,0,10,25,70],
  361. [0,0,10,25,80],
  362. [0,0,10,25,80],
  363. [0,0,10,25,80],
  364. [0,0,10,25,80],
  365. ];
  366. let linesArr = this.rollPanel.linesArr;
  367. let win = 0;
  368. for(let i = 0; i < GameProtocol.MAX_LINE_COUNT; ++i) {
  369. let lineArr = linesArr[i];
  370. let count = 1;
  371. let startV = -1;
  372. for(let j = 0; j < lineArr.length; ++j) {
  373. let idx = lineArr[j];
  374. let x = idx % 10;
  375. let y = Math.floor(idx/10);
  376. // Global.print("x:"+x+" y:"+y)
  377. let value = data.m_desk_data[y][x];
  378. if(j == 0) {
  379. startV = value;
  380. }else{
  381. if(value == GameProtocol.WILD_ICON || value == startV) {
  382. count++;
  383. }else{
  384. break;
  385. }
  386. }
  387. }
  388. if(count >= 3) {
  389. data.m_line_id[data.m_line_count] = i;
  390. data.m_line_size[data.m_line_count] = count;
  391. data.m_line_icon[data.m_line_count] = startV;
  392. data.m_line_times[data.m_line_count] = iconTimes[startV][count-1];
  393. win += data.m_line_times[data.m_line_count];
  394. data.m_line_count++;
  395. }
  396. }
  397. data.m_lottery_size = Global.unify(win*data.m_chip_size/50)*5;
  398. data.lCurScore = this._currentScore + data.m_lottery_size;
  399. this._lastScore = data.lCurScore;
  400. cc.vv.globalUserInfo.setUserScore(this._lastScore*100);
  401. setTimeout(()=>{
  402. this.onRollEndInfo(data);
  403. }, 300);
  404. },
  405. getRandomValue(i) {
  406. if(i > 0) {
  407. return this.rollPanel.getRandomValue();
  408. }
  409. let ddd = Math.floor(Math.random()*100);
  410. if(ddd > 90) {
  411. return ddd%2+10;
  412. }
  413. return ddd % 9;
  414. },
  415. onEventSceneMessage(gameStatus,lookonUser,data) {
  416. Global.print("GameSence onEventSceneMessage 场景消息 ");
  417. var arr = new DataView(data.slice(0, 8));
  418. var dataView = new DataView(data.slice(8));
  419. var msgHead = { m: arr.getUint16(4, true), s: arr.getUint16(6, true), d: null };
  420. arr = null;
  421. this.gameConfig = AnalyzeXieYi.analyze_GameConfig(dataView);
  422. Global.print(this.gameConfig);
  423. this.rollPanel.forceStop();
  424. this.bets = this.gameConfig.nJetton;
  425. this.deskRecords = this.gameConfig.mDeskDataArr;
  426. this.deskCashCnts = this.gameConfig.cbTrueCnt;
  427. this.curBetIndex = 0;
  428. this.refrushBet();
  429. },
  430. onEventGameMessage(data) {
  431. var arr = new DataView(data.slice(0, 8));
  432. var dataView = new DataView(data.slice(8));
  433. var msgHead = { m: arr.getUint16(4, true), s: arr.getUint16(6, true), d: null };
  434. arr = null;
  435. // Global.print(msgHead)
  436. var msg = AnalyzeXieYi.analyzeData(msgHead.m, msgHead.s, dataView);
  437. switch (msgHead.s) {
  438. case GameProtocol.SUB_S_REBACK_LOTTERY: { // 操作记录
  439. Global.print("SGLB::结果");
  440. this.onRollEndInfo(msg);
  441. }
  442. break;
  443. case GameProtocol.SUB_S_JACKPOT_RESET: { // 操作记录
  444. Global.print("JACKPOT:"+JSON.stringify(msg));
  445. // this.updateJackpot(msg);
  446. // this.rollPanel.updateJackpotValue(msg.lJackPot);
  447. }
  448. break;
  449. case GameProtocol.SUB_S_SEND_CONTROL_INFO: {
  450. Global.print("SUB_S_SEND_CONTROL_INFO");
  451. this.onSubSendControlInfo(msg);
  452. }
  453. break;
  454. default: {
  455. Global.print("SGLBGameSence onEventGameMessage error ");
  456. }
  457. break;
  458. }
  459. },
  460. showDebugRewardInfo() {
  461. let count = this.gameEndData.m_line_count;
  462. let lineid = this.gameEndData.m_line_id;
  463. let str = "中奖信息:" + count + "条线[";
  464. for(let i = 0; i < count; ++i) {
  465. str += (lineid[i]+1) + ',';
  466. }
  467. str += ']\n';
  468. str += this.gameEndData.m_is_berserk == 1 ? "、出CASH" : "";
  469. str += this.gameEndData.m_ruyi == 1 ? "、CASH结束" : "";
  470. const infoNode = cc.find("ControlInfo/info", this.node);
  471. infoNode.getChildByName("reward").getComponent(cc.RichText).string = str;
  472. },
  473. onEventGameRecord(data) {
  474. let dd = AnalyzeXieYi.analyze_Record(data);
  475. this._gameRecords.push(dd);
  476. this.addOneRecord(dd);
  477. // if(this._gameRecords.length >= 60) {
  478. // this.showRecordsPanel();
  479. // }
  480. },
  481. onEventJackpotRecord(data) {
  482. let dd = AnalyzeXieYi.analyze_JackpotRecord(data);
  483. this.jackpotRecord.push(dd);
  484. Global.print(dd);
  485. if(this.jackpotRecord.length == 1) {
  486. this.showWithNowIdx();
  487. }
  488. },
  489. onSocketHorseMessage(data) {
  490. if(cc.vv.config.ReviewApk) {return;}
  491. if(this.node.getChildByName("notice1") == null) {return;}
  492. Global.print(data)
  493. var str = data.szMessage;
  494. var list = str.split('##');
  495. if(this.getGameKind() == list[0]) {
  496. var rewardTxt = ['', 'jackpot'];
  497. var gameinfo = GameConstant.getGameUiInfoByKindId(list[0]);
  498. var sstr = `Enhorabuena a <color=#65c7ff>${list[2]}</color> por conseguir <color=#00ff00>${list[3]}</color> iconos de CASH Ultimate, ganando ${CASH_TIMES[list[3]]}x el bote, <color=#fff21a>${(list[4]/100).toFixed(2)}</color>`;
  499. this.marqueueArr.push(sstr);
  500. if(!this.updateMaring) {
  501. this.updateMaring = true;
  502. this.schedule(this.updateMarqueue);
  503. }
  504. if(this.delayMarqueueTime <= 0) {
  505. this.delayMarqueueTime += 5;
  506. // this.showNextMar();
  507. }
  508. }
  509. this.rightJackpotPanel.active = false;
  510. this.jackpotRecord.splice(0);
  511. this.nowShowIdx = 0;
  512. this.getJackpotRecord();
  513. },
  514. showNextMar() {
  515. var kStr = this.marqueueArr.shift();
  516. let noticeNode = this.node.getChildByName("notice1");
  517. let noticeLabel = noticeNode.getChildByName("Mask").getChildByName("label_notice");
  518. noticeNode.active = true;
  519. noticeLabel.x = 300;
  520. if(noticeLabel.getComponent(cc.RichText)) {
  521. noticeLabel.getComponent(cc.RichText).string = kStr;
  522. }else{
  523. noticeLabel.getComponent(cc.Label).string = kStr;
  524. }
  525. this.delayMarqueueTime = 25;
  526. },
  527. showWithNowIdx() {
  528. if(this.jackpotRecord.length <= 0) {
  529. return;
  530. }
  531. if(this.nowShowIdx >= this.jackpotRecord.length) {
  532. this.nowShowIdx = 0;
  533. }
  534. this.rightJackpotNode.active = true;
  535. let info = this.jackpotRecord[this.nowShowIdx];
  536. this.setItemInfos(this.rightJackpotPlayer1, info);
  537. this.rightJackpotPlayer1.y = 0;
  538. this.rightJackpotPlayer2.y = -75;
  539. this.delayNextTime = ShowNextJackpotTime;
  540. },
  541. jumpNextJackpot() {
  542. //小于两条 不滚动
  543. if(this.jackpotRecord.length < 2) {
  544. return;
  545. }
  546. this.nowShowIdx++;
  547. if(this.nowShowIdx >= this.jackpotRecord.length) {
  548. this.nowShowIdx = 0;
  549. }
  550. let info = this.jackpotRecord[this.nowShowIdx];
  551. let node1 = null;
  552. let node2 = null;
  553. if(this.rightJackpotPlayer1.y > this.rightJackpotPlayer2.y) {
  554. node1 = this.rightJackpotPlayer1;
  555. node2 = this.rightJackpotPlayer2;
  556. }else{
  557. node1 = this.rightJackpotPlayer2;
  558. node2 = this.rightJackpotPlayer1;
  559. }
  560. this.setItemInfos(node2, info);
  561. node1.stopAllActions();
  562. node2.stopAllActions();
  563. cc.tween(node1)
  564. .to(1, {y: 75})
  565. .call(()=>{
  566. node1.y = -75;
  567. })
  568. .start()
  569. cc.tween(node2)
  570. .to(1, {y: 0})
  571. .start()
  572. this.delayNextTime = ShowNextJackpotTime;
  573. },
  574. setItemInfos(node, info) {
  575. if(!node || !info) {
  576. return;
  577. }
  578. node.active = true;
  579. node.getChildByName("head").getChildByName("spr").getComponent(cc.Sprite).spriteFrame = cc.vv.globalUserInfo.getHeadSpriteFrameByFaceID(info.cbFaceID);
  580. node.getChildByName("name").getComponent(cc.Label).string = Global.subStr(info.szNickName, 12);
  581. node.getChildByName("times").getComponent(cc.Label).string = CASH_TIMES[info.nLotteryTimes]+'x';
  582. node.getChildByName("score").getComponent(cc.Label).string = 'R$:'+Global.formatString2Score(info.lLotteryMoney);
  583. },
  584. onClickShowJackpotUser() {
  585. this.rightJackpotPanel.active = true;
  586. this.rightJackpotPanel.getChildByName("mark").active = true;
  587. for(let i = 0; i < 10; ++i) {
  588. let item = null;
  589. if(i >= this.rightJackPotContent.childrenCount) {
  590. item = cc.instantiate(this.rightJackPotClone);
  591. item.parent = this.rightJackPotContent;
  592. }else{
  593. item = this.rightJackPotContent.children[i];
  594. }
  595. if(item) {
  596. let info = this.jackpotRecord[i];
  597. if(info) {
  598. this.setItemInfos(item, info);
  599. }else{
  600. item.active = false;
  601. }
  602. }
  603. }
  604. this.rightJackPotShowNode.stopAllActions();
  605. this.rightJackPotShowNode.scaleY = 0;
  606. cc.tween(this.rightJackPotShowNode)
  607. .to(0.07, {scaleY:1})
  608. .start()
  609. },
  610. onClickHideJackpotUser() {
  611. this.rightJackpotPanel.getChildByName("mark").active = false;
  612. this.rightJackPotShowNode.stopAllActions();
  613. this.rightJackPotShowNode.scaleY = 1;
  614. cc.tween(this.rightJackPotShowNode)
  615. .to(0.07, {scaleY:0})
  616. .call(()=>{
  617. this.rightJackpotPanel.active = false;
  618. })
  619. .start()
  620. },
  621. backHome: function() {
  622. if (CServerItem.get()) {
  623. CServerItem.get().PerformStandUpAction(1);
  624. } else {
  625. this.exitGame();
  626. }
  627. this._backHome = true;
  628. ScenceManager.Instance().gameBackScence();
  629. GameManagerBase.Instance().setInGameServerID(-1);
  630. },
  631. exitGameWhenPlaying() {
  632. if(!this._gameEnd) {
  633. topTipMsg.showTopTipMsg(LanguageKey.t("pubWords.cant_close_cause_gaming"));
  634. return;
  635. }
  636. if(cc.vv.config.ReviewApk) {
  637. cc.game.end();
  638. return;
  639. }
  640. this.goldGameLeave();
  641. // this.backHome();
  642. // this.exitGame();
  643. },
  644. ShowGuideNode() {
  645. topTipMsg.showTopTipMsg(LanguageKey.t("pubWords.coin_not_enghou"));
  646. this.quickBtn.getComponent(cc.Toggle).isChecked = false;
  647. this.upBtnInteractable(this.startBtn, true);
  648. this.upBetAddOrDelState();
  649. },
  650. showBackTips() {
  651. this.backPanel.active = true;
  652. },
  653. hideBackTips() {
  654. this.playEffect("button");
  655. this.backPanel.active = false;
  656. },
  657. upDeskRecordCashCnt(cnt, bCashEnd) {
  658. this.deskCashCnts[this.curBetIndex] = cnt;
  659. if(bCashEnd) {
  660. this.deskRecords[this.curBetIndex] = [
  661. [4,3,5,6,8],
  662. [4,3,5,6,8],
  663. [4,3,5,6,8],
  664. [4,3,5,6,8]
  665. ];
  666. }
  667. },
  668. onRollEndInfo(data) {
  669. Global.print(data);
  670. // this.onSocketHorseMessage({szMessage:"3019##1##u44656523165498569##18##600.00"})
  671. this.deskRecords[this.curBetIndex] = data.m_desk_data;
  672. this.gameEndData = data;
  673. this._lastScore = data.lCurScore;
  674. this.rollPanel.setRollDatas(data);
  675. this.rollPanel.openPrizes(false, this._bQuickGame);
  676. this.showDebugRewardInfo();
  677. },
  678. makeXieYi(m,s,data) {
  679. if(m == ProtocolGameServer.MDM_GF_FRAME) {
  680. return //new DataView(arrayBuffer)
  681. }
  682. return MakeXieYi.makeRoll(data);
  683. },
  684. onClickRecord() {
  685. this.recordContent.removeAllChildren();
  686. this._gameRecords.splice(0);
  687. this.recordPanel.active = true;
  688. this.getGameRecord();
  689. },
  690. onSendRoll() {
  691. // this.testResult();
  692. // return;
  693. let t = {};
  694. t.nJetton = this.gameConfig.nJetton[this.curBetIndex];
  695. // Global.print(t);
  696. this.SendGameSocketData(GameProtocol.SUB_C_LOTTERY, t);
  697. },
  698. // judgeAuto() {
  699. // let funcNode = this.node.getChildByName("FuncBtnNode");
  700. // if(this._nAutoCount == 0) {
  701. // this._bAutoGame = false;
  702. // }else{
  703. // this._bAutoGame = true;
  704. // }
  705. // funcNode.getChildByName("btn_left").active = this._bAutoGame;
  706. // let left = funcNode.getChildByName("btn_left");
  707. // left.active = this._bAutoGame;
  708. // left.getChildByName("left").active = this._nAutoCount > 0;
  709. // left.getChildByName("left2").active = this._nAutoCount < 0;
  710. // left.getChildByName("left").getComponent(cc.Label).string = this._nAutoCount;
  711. // },
  712. onStartRoll() {
  713. if(!this._gameEnd) return;
  714. this.node.stopAllActions();
  715. this.resetGameView();
  716. if(this.playingEffectID != -1) {
  717. cc.vv.audioMgr.stopSFX(this.playingEffectID);
  718. }
  719. //是否可以开始游戏
  720. if(!this.judgeCannotRollGame()) {
  721. return;
  722. }
  723. this._gameEnd = false;
  724. this.changeGameState(1);
  725. // if(!cc.vv.audioMgr.resumeBackMusic()) {
  726. // cc.vv.audioMgr.playBGM("bgm");
  727. // }
  728. this.onSendRoll();
  729. this.showCenterWinScore(0);
  730. this.onGameStart();
  731. this.rollPanel.startRollActions();
  732. },
  733. refrushBet() {
  734. this.upBetAddOrDelState();
  735. let bet = this.bets[this.curBetIndex];
  736. this.betNode.getChildByName("bet").getComponent(cc.Label).string = Global.formatString2Score(bet);
  737. if(this.curBetIndex >= 0 && this.curBetIndex < this.deskRecords.length) {
  738. this.rollPanel.reSetLastData(this.deskRecords[this.curBetIndex], this.deskCashCnts[this.curBetIndex]);
  739. this.showCenterWinScore(0);
  740. }
  741. },
  742. resetGameView() {
  743. this.resultNode.active = false;
  744. },
  745. resetAllBtn() {
  746. if(this._bAutoGame || this._bSpecialGame) return;
  747. this.upBtnInteractable(this.startBtn, true);
  748. this.upBetAddOrDelState();
  749. },
  750. onGameStart() {
  751. this.upBtnInteractable(this.startBtn, false);
  752. this.upBtnInteractable(this.addBtn, false);
  753. this.upBtnInteractable(this.delBtn, false);
  754. },
  755. showCenterWinScore(score) {
  756. // cc.error(score);
  757. this.winScoreNode.getComponent(cc.Label).string = 'R$'+Global.formatString2Score(score);
  758. },
  759. showGameEnd() {
  760. this._gameEnd = true;
  761. this.changeGameState(2);
  762. },
  763. onClickSkip() {
  764. this.playButtonEffect();
  765. let scoreNode = this.resultNode.getChildByName("mask").getChildByName("scoreNode");
  766. this.skipScoreAdd(scoreNode.getChildByName("score").getComponent(cc.Label),scoreNode.getChildByName("score2").getComponent(cc.Label))
  767. },
  768. showResultPanel() {
  769. let ssNodeY = [-44,-103,-103,-150,-150];
  770. this.changeGameState(3);
  771. this.resultNode.active = true;
  772. let node = this.resultNode.getChildByName("mask");
  773. let goldNode = node.getChildByName("goldani");
  774. let ssNode = node.getChildByName("scoreNode");
  775. let sNode = ssNode.getChildByName("score");
  776. let sNode2 = ssNode.getChildByName("score2");
  777. let sLabel = sNode.getComponent(cc.Label);
  778. let sLabel2 = sNode2.getComponent(cc.Label);
  779. let aniNode1 = node.getChildByName("wani");
  780. aniNode1.active = true;
  781. goldNode.active = true;
  782. ssNode.active = false;
  783. let anii = aniNode1.getComponent(sp.Skeleton);
  784. anii.skeletonData = this.winSpineData[this.winAniIdx];
  785. if(this.winAniIdx >= 0) {
  786. //金币动画
  787. let gAni = goldNode.getComponent(sp.Skeleton);
  788. // gAni.clearTracks();
  789. // gAni.setAnimation(0, 'a'+(this.winAniIdx>3?3:this.winAniIdx), true);
  790. gAni.setAnimation(0, 'a'+(this.winAniIdx+1>5?5:this.winAniIdx+1), true);
  791. }else{
  792. goldNode.active = false;
  793. }
  794. this.isPlayingScoreAddAni = true;
  795. //win动画
  796. anii.clearTracks();
  797. anii.setAnimation(0, "a1", false);
  798. anii.addAnimation(0, "a2", true);
  799. this.resultNode.stopAllActions();
  800. cc.tween(this.resultNode)
  801. .delay(0.3)
  802. .call(()=>{
  803. if(this.winAniIdx>=0 && this.winAniIdx<ssNodeY.length)
  804. ssNode.y = ssNodeY[this.winAniIdx];
  805. ssNode.active = true;
  806. sLabel.string = '0';
  807. sLabel2.string = '.00';
  808. this.playScoreAddAni(sLabel, sLabel2);
  809. // this.changeSkipBtnState(true);
  810. })
  811. .start()
  812. },
  813. playScoreAddAni(sLabel, sLabel2) {
  814. let start = 0;
  815. let bet = this.gameConfig.nJetton[this.curBetIndex];
  816. let endScore = Global.formatString2Score(this.needPlayinfScore);
  817. let add = parseFloat(bet/100/this.MAX_LINE);
  818. this.upScoreLabel = ()=>{
  819. start += add;
  820. if(start >= endScore) {
  821. this.skipScoreAdd(sLabel, sLabel2);
  822. }else{
  823. sLabel.string = Math.floor(start);
  824. sLabel2.string = ((parseFloat(start - Math.floor(start)).toFixed(2)).toString()).slice(1);
  825. }
  826. }
  827. if(this.upScoreLabel) {
  828. this.unschedule(this.upScoreLabel);
  829. }
  830. this.schedule(this.upScoreLabel, 0.01);
  831. },
  832. skipScoreAdd(sLabel, sLabel2) {
  833. if(this.upScoreLabel) {
  834. this.unschedule(this.upScoreLabel);
  835. }
  836. let score = Global.formatString2Score(this.needPlayinfScore);
  837. sLabel.string = Math.floor(score);
  838. sLabel2.string = ((parseFloat(score - Math.floor(score)).toFixed(2)).toString()).slice(1);
  839. this.changeSkipBtnState(false);
  840. this.delayStartNextRoll(1);
  841. this.isPlayingScoreAddAni = false;
  842. },
  843. hideResultPanel() {
  844. this.resultNode.active = false;
  845. },
  846. changeSkipBtnState(bShow) {
  847. },
  848. onClickResultMask() {
  849. if(this.isPlayingScoreAddAni) {
  850. this.onClickSkip();
  851. }else{
  852. this.hideResultPanel();
  853. }
  854. },
  855. //cash结算
  856. showCashWin(cnt) {
  857. this.cashWinNode.active = true;
  858. let mask = this.cashWinNode.getChildByName('mask');
  859. let cashAni1 = mask.getChildByName("cashani1").getComponent(sp.Skeleton);
  860. let cashAni2 = mask.getChildByName("cashani2").getComponent(sp.Skeleton);
  861. cashAni2.node.active = false;
  862. let countNode1 = mask.getChildByName("count");
  863. let timesNode = mask.getChildByName("times");
  864. timesNode.getComponent(cc.Label).string = CASH_TIMES[cnt]+'x';
  865. countNode1.getComponent(cc.Label).string = cnt;
  866. countNode1.scale = 0;
  867. countNode1.active = false;
  868. timesNode.scale = 0;
  869. timesNode.active = false;
  870. let showScore = this.gameEndData.m_deposit_lotttery;
  871. let scoreNode = mask.getChildByName("score");
  872. scoreNode.getComponent(cc.Label).string = 'R$'+Global.formatString2Score(showScore);
  873. scoreNode.y = 0;
  874. scoreNode.scale = 0;
  875. scoreNode.active = false;
  876. cashAni1.clearTracks();
  877. cashAni1.setAnimation(0, 'b1', false);
  878. mask.stopAllActions();
  879. cc.tween(mask)
  880. .delay(0.1)
  881. .call(()=>{
  882. countNode1.active = true;
  883. countNode1.opacity = 255;
  884. countNode1.stopAllActions();
  885. cc.tween(countNode1)
  886. .to(0.1, {scale: 2})
  887. .to(0.1, {scale: 1})
  888. .delay(1.5)
  889. .to(0.2, {opacity: 0})
  890. .start()
  891. timesNode.active = true;
  892. timesNode.opacity = 255;
  893. timesNode.stopAllActions();
  894. cc.tween(timesNode)
  895. .to(0.1, {scale: 2})
  896. .to(0.1, {scale: 1})
  897. .delay(1.5)
  898. .to(0.2, {opacity: 0})
  899. .start()
  900. })
  901. .start()
  902. this.cashWinNode.stopAllActions();
  903. if(cnt > 3) {
  904. if(cnt <= 10) {
  905. this.playEffectByID(0);
  906. }else if(cnt <= 15) {
  907. this.playEffectByID(1);
  908. }else{
  909. this.playEffectByID(2);
  910. }
  911. cashAni1.setCompleteListener(()=>{
  912. cashAni1.setCompleteListener(null);
  913. this.cashWinNode.active = false;
  914. })
  915. cc.tween(this.cashWinNode)
  916. .delay(1.8)
  917. .call(()=>{
  918. this.rollPanel.showPrizes();
  919. })
  920. .start();
  921. return;
  922. }
  923. cc.tween(this.cashWinNode)
  924. .delay(1.8)
  925. .call(()=>{
  926. cashAni2.node.active = true;
  927. cashAni2.clearTracks();
  928. cashAni2.setAnimation(0, 'b2', false);
  929. })
  930. .delay(0.1)
  931. .call(()=>{
  932. scoreNode.active = true;
  933. scoreNode.stopAllActions();
  934. cc.tween(scoreNode)
  935. .to(0.1, {scale: 2})
  936. .to(0.1, {scale: 1})
  937. .delay(1.5)
  938. .to(0.2, {scale: 0, y:-339})
  939. .call(()=>{
  940. this.winScoreNode.stopAllActions();
  941. let scoreL = this.winScoreNode.getComponent(cc.Label);
  942. scoreL.string = 'R$0.00';
  943. cc.tween(this.winScoreNode)
  944. .to(0.1, {scale: 1.2})
  945. .to(0.1, {scale: 1})
  946. .start()
  947. let startS = 0;
  948. this.schedule(()=>{
  949. startS += showScore*0.25;
  950. if(startS > showScore) {
  951. return;
  952. }
  953. scoreL.string = 'R$'+Global.formatString2Score(Math.floor(startS));
  954. }, 0.04, 4, 0.04)
  955. })
  956. .start()
  957. })
  958. .delay(2.4)
  959. .call(()=>{
  960. this.cashWinNode.active = false;
  961. this.rollPanel.showPrizes();
  962. })
  963. .start()
  964. },
  965. //最终结算
  966. showGameWinScore() {
  967. this.winAniIdx = -1;
  968. this.needPlayinfScore = this.gameEndData.m_lottery_size;
  969. let score = this.gameEndData.m_lottery_size
  970. this.winScoreNode.getComponent(cc.Label).string = 'R$'+Global.formatString2Score(score);
  971. let timers = Math.floor(score * this.MAX_LINE / this.gameConfig.nJetton[this.curBetIndex]);
  972. this._currentScore = this._lastScore;
  973. this.upPlayerScore(this._currentScore);
  974. // cc.tween(this.node)
  975. // .delay(0.3)
  976. // .call(()=>{
  977. // this.showGameEnd();
  978. // })
  979. // .start()
  980. this.showGameEnd();
  981. if(score <= 0) {
  982. this.delayStartNextRoll(1);
  983. return;
  984. }
  985. this.playSoundByTimes(timers);
  986. if(this.winAniIdx >= 0) {
  987. this.showResultPanel();
  988. }else{
  989. this.delayStartNextRoll(1);
  990. }
  991. },
  992. delayStartNextRoll(delayTime) {
  993. this.changeGameState(0);
  994. this.resetAllBtn();
  995. this.node.stopAllActions();
  996. cc.tween(this.node)
  997. .delay(delayTime)
  998. .call(()=>{
  999. if(this._bAutoGame){ //自动游戏时
  1000. this.onStartRoll();
  1001. }else{
  1002. // this.upBtnInteractable(this.startBtn, true);
  1003. this.resetAllBtn();
  1004. }
  1005. })
  1006. .start()
  1007. },
  1008. changeGameState(state) {
  1009. this._gameState = state;
  1010. },
  1011. changeBtnState(bEnd) {
  1012. this.startBtn.active = !bEnd;
  1013. },
  1014. upBetAddOrDelState() {
  1015. this.upBtnInteractable(this.delBtn, this.curBetIndex>0);
  1016. this.upBtnInteractable(this.addBtn, this.curBetIndex<this.bets.length-1);
  1017. },
  1018. upBtnInteractable(btn, state) {
  1019. btn.getComponent(cc.Button).interactable = state;
  1020. },
  1021. addOneRecord(info) {
  1022. let item = cc.instantiate(this.recordClone);
  1023. item.getChildByName("time").getComponent(cc.Label).string = Global.formatDate(new Date(info.nTime*1000));
  1024. item.getChildByName("bet").getComponent(cc.Label).string = Global.formatString2Score(info.nBet);
  1025. let win = info.nBet+info.nWinLost;
  1026. item.getChildByName("win").getComponent(cc.Label).string = Global.formatString2Score(win);
  1027. item.active = true;
  1028. item.parent = this.recordContent;
  1029. },
  1030. showRecordsPanel() {
  1031. this.recordContent.removeAllChildren();
  1032. for(let i = 0; i < this._gameRecords.length; ++i) {
  1033. let info = this._gameRecords[i];
  1034. let item = cc.instantiate(this.recordClone);
  1035. item.getChildByName("time").getComponent(cc.Label).string = Global.formatDate(new Date(info.nTime*1000));
  1036. item.getChildByName("bet").getComponent(cc.Label).string = Global.formatString2Score(info.nBet);
  1037. let win = info.nBet+info.nWinLost;
  1038. item.getChildByName("win").getComponent(cc.Label).string = Global.formatString2Score(win);
  1039. item.active = true;
  1040. item.parent = this.recordContent;
  1041. }
  1042. this.recordPanel.active = true;
  1043. },
  1044. onClickStart() {
  1045. this.playButtonEffect();
  1046. this.onStartRoll();
  1047. },
  1048. onClickStop() {
  1049. this.playButtonEffect();
  1050. this.onStopRoll();
  1051. },
  1052. onClickAdd() {
  1053. this.curBetIndex++;
  1054. this.playButtonEffect();
  1055. this.refrushBet();
  1056. },
  1057. onClickDel() {
  1058. this.curBetIndex--;
  1059. this.playButtonEffect();
  1060. this.refrushBet();
  1061. },
  1062. onClickQuick(event) {
  1063. this.playButtonEffect();
  1064. this._bAutoGame = !event.target.getComponent(cc.Toggle).isChecked;
  1065. this._nAutoCount = -1;
  1066. },
  1067. onClickMenu() {
  1068. this.playButtonEffect();
  1069. UIHelper.loadRes('GamePrefabs/Public/GameMenu', cc.Prefab, (prefab)=>{
  1070. if (!this._ruleNode) {
  1071. this._ruleNode = cc.instantiate(prefab);
  1072. this._ruleNode.parent = this.node.getChildByName("MenuNode");
  1073. }
  1074. this._ruleNode.getComponent("GameMenu").show();
  1075. this._ruleNode.getComponent("GameMenu").onBtnBangZhu = ()=>{
  1076. var self = this;
  1077. cc.resources.load("GamePrefabs/homescence/rule", cc.Prefab, function (err, prefab) {
  1078. if (!self._rule) {
  1079. self._rule = cc.instantiate(prefab);
  1080. self._rule.parent = self.node;
  1081. }
  1082. self._rule.getComponent("homeRule").showGameRuleByGameID(self.getGameKind());
  1083. });
  1084. }
  1085. this._ruleNode.getComponent("GameMenu").onClickMusic = ()=>{
  1086. this.onClickMusic();
  1087. }
  1088. })
  1089. },
  1090. onHideRule() {
  1091. this.ruleNode.active = false;
  1092. },
  1093. showRule() {
  1094. Global.print("展示规则");
  1095. if(this._ruleNode) {
  1096. this._ruleNode.active = false;
  1097. }
  1098. this.ruleNode.active = true;
  1099. },
  1100. onClickMusic(){
  1101. if(cc.vv.audioMgr.bgmVolume > 0) {
  1102. cc.vv.audioMgr.setBGMVolume(0, false, true);
  1103. this.stopBgm();
  1104. }else{
  1105. cc.vv.audioMgr.setBGMVolume(1, false, true);
  1106. this.resumeBGM();
  1107. }
  1108. this._ruleNode.getComponent("GameMenu").upSetting();
  1109. },
  1110. playSoundByTimes(_times) {
  1111. if(_times <= 0) return;
  1112. Global.print("winTimes:"+_times)
  1113. let id = 1;
  1114. if(_times > this.MAX_LINE*120){
  1115. id = 15;
  1116. this.winAniIdx = 3;
  1117. }else if(_times > this.MAX_LINE*100){
  1118. id = 14;
  1119. this.winAniIdx = 3;
  1120. }else if(_times > this.MAX_LINE*80){
  1121. id = 13;
  1122. this.winAniIdx = 3;
  1123. }else if(_times > this.MAX_LINE*64){
  1124. id = 12;
  1125. this.winAniIdx = 3;
  1126. }else if(_times > this.MAX_LINE*48){
  1127. id = 11;
  1128. this.winAniIdx = 3;
  1129. }else if(_times > this.MAX_LINE*32){
  1130. id = 10;
  1131. this.winAniIdx = 3;
  1132. }else if(_times > this.MAX_LINE*20){
  1133. id = 9;
  1134. this.winAniIdx = 3;
  1135. }else if(_times > this.MAX_LINE*12){
  1136. id = 8;
  1137. this.winAniIdx = 3;
  1138. }else if(_times > this.MAX_LINE*8){
  1139. id = 5;
  1140. this.winAniIdx = 2;
  1141. }else if(_times > this.MAX_LINE*4){
  1142. id = 4;
  1143. this.winAniIdx = 1;
  1144. }else if(_times > this.MAX_LINE*2){
  1145. id = 3;
  1146. this.winAniIdx = 0;
  1147. }else if(_times > this.MAX_LINE){
  1148. id = 2;
  1149. this.winAniIdx = -1;
  1150. }
  1151. // this.playEffect("Level"+this.winAniIdx);
  1152. // this.playEffectByID(this.winAniIdx);
  1153. },
  1154. playEffectByID(id) {
  1155. let audioC = this.audioArr[id];
  1156. if(audioC) {
  1157. this.playingEffectID = cc.vv.audioMgr.playEffectByAudioClip(audioC);
  1158. }
  1159. },
  1160. playEffect(effName, needStop = false) {
  1161. if(needStop)
  1162. cc.vv.audioMgr.stopAllEffects();
  1163. cc.vv.audioMgr.playSFX(effName);
  1164. },
  1165. playButtonEffect(){
  1166. this.playEffect("button");
  1167. },
  1168. upPlayerScore(score) {
  1169. cc.vv.globalUserInfo.setUserScore(score);
  1170. this.playerScore.string = Global.formatString2Score(score);
  1171. },
  1172. });