123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818 |
- var Global = require("Global");
- var UIHelper = require("UIHelper");
- var BaseDefine = require("BaseDefine");
- var GameProtocol = require("RaioGameProtocol");
- import ScenceManager from 'HNScenceManager'
- const arr_posX = [-357, -178, 0, 178, 357];
- cc.Class({
- extends: cc.Component,
- editor: {
- menu: 'Game/Raio/RollPanel'
- },
- properties: {
- rollBG: [cc.Node],
- rollAni: [cc.Node],
- lineNodes: [cc.Node],
- itemClone: cc.Prefab,
- lightBG: cc.Node,
- itemSpines: [sp.SkeletonData],
- numAni: sp.Skeleton,
- titleAni: sp.Skeleton,
- bgAni: sp.Skeleton,
- shakeNode: cc.Node,
- bGameEnd: false,
- maxRolItemlLen: 21,
- MAX_COL_NUM: 5,
- MAX_ROW_NUM: 4,
- SPECIAL_ICON: 9,
- sizec: 150,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.linesArr = [[0,1,2,3,4],[10,11,12,13,14],[20,21,22,23,24],[30,31,32,33,34],[0,11,2,13,4],[10,1,12,3,14],
- [10,21,12,23,14],[20,11,22,13,24],[20,31,22,33,24],[30,21,32,23,34],[0,11,22,13,4],[20,11,2,13,24],
- [10,21,32,23,14],[30,21,12,23,34],[0,1,12,3,4],[10,11,2,13,14],[10,11,22,13,14],[20,21,12,23,24],
- [20,21,32,23,24],[30,31,22,33,34],[0,11,12,13,4],[10,1,2,3,14],[10,21,22,23,14],[20,11,12,13,24],
- [20,31,32,33,24],[30,21,22,23,34],[0,1,12,23,24],[20,21,12,3,4],[10,11,22,33,34],[30,31,22,13,14]];
- this._rollResultData = {};
- this._lineCount = 0;
- this._lineSize = [];
- this._lineID = [];
- this._lineIcon = [];
- this._lineTimes = [];
- this.itemData = [];
- this.elementNode = [];
- this.elementJS = [];
- this.tempValue = [];
- this.lightNode = [];
- this.lightJS = [];
-
- this._startRollTime = 0;
- this.numAni.node.active = false;
- this._lastCashCnt = 0;
- this.initLists();
- },
- start() {
- this.titleAni.node.active = true;
- this.titleAni.clearTracks();
- this.titleAni.setAnimation(0, "1a", false);
- this.titleAni.addAnimation(0, "1b", true);
- this.nowTitleIdx = 1;
- this.delayShowNextTitleTime = 15;
- this.updateRollBGAni(0);
- },
- upTitleAni() {
- this.titleAni.clearTracks();
- let c = '3c';
- let a = ''+this.nowTitleIdx+'a';
- let b = ''+this.nowTitleIdx+'b';
- if(this.nowTitleIdx == 2) {
- c = '1c';
- }else if(this.nowTitleIdx == 3) {
- c = '2c';
- this.nowTitleIdx = 0;
- }
- this.titleAni.clearTracks();
- this.titleAni.setAnimation(0, c, false);
- this.titleAni.addAnimation(0, a, false);
- this.titleAni.addAnimation(0, b, true);
- this.delayShowNextTitleTime = 15;
- },
- showNumAni(num) {
- Global.print("showNumAni:"+num)
- if(num < 3) {
- this.numAni.node.active = false;
- return;
- }
- if(num < 10) {
- num = '0'+num;
- }
- this.numAni.node.active = true;
- this.numAni.clearTracks();
- this.numAni.setAnimation(0, ''+num+'a', false);
- this.numAni.addAnimation(0, ''+num+'b', true);
- },
- updateRollBGAni(cnt) {
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- this.rollAni[i].active = cnt > 10;
- if(cnt >= 10) {
- let ani = this.rollAni[i].getComponent(sp.Skeleton);
- ani.clearTracks();
- ani.setAnimation(0, cnt > 15?'a2':'a1', true);
- }
- }
- },
- resetRollBGAni() {
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- this.rollAni[i].active = false;
- }
- },
- playEffectByCashCnt() {
- if(this.cashCnt == 0) {return;}
- if(this.cashCnt < 3) {
- this.playEffect('cashcnt12');
- }else if(this.cashCnt <= 10) {
- this.playEffect('cashcnt310')
- this.playEffect('cash310')
- }else if(this.cashCnt <= 15) {
- this.playEffect('cashcnt1115')
- this.playEffect('cash1115')
- }else{
- this.playEffect('cashcnt1620')
- this.playEffect('cash1620')
- }
- },
- startHotBGAct() {
- let x = 0//this.bgAni.node.x;
- let y = 0//this.bgAni.node.y;
- this.shakeNode.stopAllActions();
- cc.tween(this.shakeNode)
- .sequence(
- cc.tween().to(0.03, {x:x+5, y:y+5}),
- cc.tween().to(0.03, {x:x, y:y})
- )
- .repeatForever()
- .start()
- },
- stopHotBGAct() {
- this.shakeNode.stopAllActions();
- this.shakeNode.x = 0;
- this.shakeNode.y = 0;
- },
- shake2() {
- let x = 0//this.bgAni.node.x;
- let y = 0//this.bgAni.node.y;
- this.shakeNode.stopAllActions();
- cc.tween(this.shakeNode)
- .sequence(
- cc.tween().to(0.03, {x:x-1, y:y-2}),
- cc.tween().to(0.03, {x:x, y:y+1}),
- cc.tween().to(0.03, {y:y-1}),
- cc.tween().to(0.03, {y:y})
- )
- .repeat(3)
- .start()
- },
- shake3() {
- let x = 0//this.bgAni.node.x;
- let y = 0//this.bgAni.node.y;
- this.shakeNode.stopAllActions();
- cc.tween(this.shakeNode)
- .sequence(
- cc.tween().to(0.03, {x:x-1, y:y-2}),
- cc.tween().to(0.03, {x:x, y:y+1}),
- cc.tween().to(0.03, {y:y-1}),
- cc.tween().to(0.03, {y:y})
- )
- .repeat(2)
- .start()
- },
- updateBGAni() {
- let shake2 = ()=>{
- let x = 0//this.bgAni.node.x;
- let y = 0//this.bgAni.node.y;
- this.shakeNode.stopAllActions();
- cc.tween(this.shakeNode)
- .sequence(
- cc.tween().to(0.03, {x:x-1, y:y-2}),
- cc.tween().to(0.03, {x:x, y:y+1}),
- cc.tween().to(0.03, {y:y-1}),
- cc.tween().to(0.03, {y:y})
- )
- .repeat(3)
- .start()
- }
- let shake3 = ()=>{
- let x = 0//this.bgAni.node.x;
- let y = 0//this.bgAni.node.y;
- this.shakeNode.stopAllActions();
- cc.tween(this.shakeNode)
- .sequence(
- cc.tween().to(0.03, {x:x-1, y:y-2}),
- cc.tween().to(0.03, {x:x, y:y+1}),
- cc.tween().to(0.03, {y:y-1}),
- cc.tween().to(0.03, {y:y})
- )
- .repeat(2)
- .start()
- }
-
- if(this.cashCnt > 0) {
- //首次中,10个及以上 用a4 否则用a1
- if(this._lastCashCnt == 0) {
- this.bgAni.clearTracks();
- this.bgAni.setAnimation(0, "a2", false);
- this.bgAni.addAnimation(0, this.cashCnt>=10?'a4':'a1', true);
- shake2();
- }else{
- //新增,少于10
- if(this.cashCnt <= 10) {
- this.bgAni.clearTracks();
- this.bgAni.setAnimation(0, "a3", false);
- this.bgAni.addAnimation(0, 'a1', true);
- shake3();
- }else if(this.cashCnt >= 11 && this.cashCnt <= 15) {
- this.bgAni.clearTracks();
- this.bgAni.setAnimation(0, "a6", false);
- this.bgAni.addAnimation(0, 'a4', true);
- shake3();
- }else{
- this.bgAni.clearTracks();
- this.bgAni.setAnimation(0, "a5", false);
- this.bgAni.addAnimation(0, 'a4', true);
- shake2();
- }
- }
- }else{
- //未中 使用默认
- this.bgAni.clearTracks();
- this.bgAni.setAnimation(0, "a1", true);
- }
- },
- initLists() {
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- this.elementNode[i] = [];
- this.elementJS[i] = [];
- this.itemData[i] = [];
- this.tempValue[i] = [];
- this.lightNode[i] = [];
- this.lightJS[i] = [];
- this.rollBG[i].active = true;
- this.rollBG[i].removeAllChildren();
- for(let j = 0; j < this.maxRolItemlLen-5; ++j) {
- this.tempValue[i][j] = this.getRandomValue();
- }
- for(let j = this.maxRolItemlLen-5; j < this.maxRolItemlLen; ++j) {
- this.tempValue[i][j] = this.tempValue[i][j-12];
- }
- for(let j = 0; j < this.maxRolItemlLen; ++j) {
- let item = cc.instantiate(this.itemClone);
- item.y = (this.maxRolItemlLen - 3.5 - j)*(this.sizec);
- item.parent = this.rollBG[i];
- item.active = true;
- this.elementNode[i][j] = item;
- this.elementJS[i][j] = this.elementNode[i][j].getComponent("RaioItem");
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]], this.isSpecialIcon(this.tempValue[i][j]));
- }
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- let light = cc.instantiate(this.itemClone);
- light.x = arr_posX[i];
- light.y = (1.5-j)*this.sizec;
- light.parent = this.lightBG;
- light.active = false;
- this.lightNode[i][j] = light;
- this.lightJS[i][j] = this.lightNode[i][j].getComponent("RaioItem");
- this.lightJS[i][j].setValue(GameProtocol.LIGHT_ICON, this.itemSpines[GameProtocol.LIGHT_ICON], true);
- }
- }
- },
- forceStop() {
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- let rollbg = this.rollBG[i];
- rollbg.active = false;
- rollbg.stopAllActions();
- rollbg.y = 0;
- }
- },
- reSetLastData(data, cashCnt) {
- // Global.print(data);
- this.node.stopAllActions();
- this.resetAllLines();
- this._hasSpecial = cashCnt >= 3;
- this.cashCnt = cashCnt;
- this._lastCashCnt = cashCnt;
- for(let i = 0; i < this.MAX_ROW_NUM; ++i) {
- for(let j = 0;j < this.MAX_COL_NUM; ++j) {
- this.tempValue[j][i+16] = data[i][j];
- this.elementJS[j][i+16].setValue(data[i][j], this.itemSpines[data[i][j]], this.isSpecialIcon(data[i][j]));
- this.lightJS[j][i].resetShow();
- this.lightJS[j][i].setValue(data[i][j], this.itemSpines[data[i][j]], this.isSpecialIcon(data[i][j]));
- this.lightNode[j][i].active = true;
- this.lightJS[j][i].showLightAni(this._hasSpecial);
- }
- }
- this.showNumAni(cashCnt);
- this.updateRollBGAni(cashCnt);
- ScenceManager.Instance().getGameComponent().changeBGM(this.cashCnt);
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- this.rollBG[i].active = false;
- for(let j = 0;j < this.MAX_ROW_NUM; ++j) {
- this.lightJS[i][j].showNewPrizes(this._hasSpecial);
- }
- }
- // Global.print("reSetLastData:"+this.cashCnt)
- this.bgAni.clearTracks();
- this.bgAni.setAnimation(0, this.cashCnt>=10?'a4':'a1', true);
- },
- isSpecialIcon(val) {
- return val == GameProtocol.LIGHT_ICON;
- },
- getRandomValue() {
- let rand = Math.floor(Math.random()*100);
- return rand % 10;
- },
- getItemSpineData(id) {
- return this.itemSpines[id];
- },
- resetRollingItemValue(i) {
- for(let j = 9; j < this.maxRolItemlLen-5; ++j) {
- this.tempValue[i][j] = this.getRandomValue();
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]], this.isSpecialIcon(this.tempValue[i][j]));
- }
- for(let j = this.maxRolItemlLen-5; j < this.maxRolItemlLen; ++j) {
- this.elementNode[i][j].active = true;
- }
- },
- startRollActions() {
- this.playEffect("roll");
-
- this.bGameEnd = false;
- this.node.stopAllActions();
- this.resetItemCounts();
- if(this.cashCnt > 10) {
- this.startHotBGAct();
- }
- this._lastCashCnt = this.cashCnt;
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- let rollbg = this.rollBG[i];
- rollbg.active = true;
- rollbg.y = 0;
- rollbg.stopAllActions();
- for(let j = 4; j < 9; ++j) {
- this.tempValue[i][j] = this.tempValue[i][j+12];
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.getItemSpineData(this.tempValue[i][j]), this.isSpecialIcon(this.tempValue[i][j]));
- }
- // this.updateRollBGAni(this.cashCnt, i)
- cc.tween(rollbg)
- .sequence(
- cc.tween().to(0.3, {y: -10*this.sizec}),
- cc.tween().call(()=>{ rollbg.y = 0, this.resetRollingItemValue(i) })
- )
- .repeatForever()
- .start()
- }
- this._startRollTime = new Date().getTime();
- },
- openPrizes(justEnd, bQuick) {
- if(this.bGameEnd == true) {
- return;
- }
- let endTime = new Date().getTime();
- let leftTime = this._startRollTime - endTime + 1300;
- this.delayTime = 0.2;
- if(bQuick) {
- leftTime -= 500;
- }
- if(leftTime < 0 || justEnd) {
- leftTime = 0;
- }
- if(justEnd) {
- this.delayTime = 0;
- }
- this.node.stopAllActions();
- this.bQuick = bQuick;
- this.FreeCount = 0;
- cc.tween(this.node)
- .delay(leftTime/1000)
- .call(()=>{
- this.rollEnds(0);
- })
- .start()
- },
- setItemColInfo(i, dIdx) {
- for(let j = this.maxRolItemlLen-5; j < this.maxRolItemlLen; ++j) {
- this.elementNode[i][j-this.maxRolItemlLen+dIdx].active = true;
- this.elementNode[i][j].active = true;
- this.tempValue[i][j] = this.tempValue[i][j-this.maxRolItemlLen+dIdx];
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.getItemSpineData(this.tempValue[i][j]), this.isSpecialIcon(this.tempValue[i][j]));
- }
- this.rollBG[i].active = false;
- // this.updateRollBGAni(0, i);
-
- let hasNewCash = false;
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- if(!this.lightNode[i][j].active) {
- this.lightNode[i][j].active = true;
- this.lightJS[i][j].showLightAni(this._hasSpecial);
- if(this.lightJS[i][j].getValue() == GameProtocol.LIGHT_ICON) {
- hasNewCash = true;
- }
- }
- }
- if(hasNewCash) {
- this.playEffectByCashCnt();
- if(this._lastCashCnt == 0 || this.cashCnt == 10) {
- this.shake2();
- }else{
- this.shake3();
- }
- }
- },
- quickEnd(i) {
- if(i >= this.MAX_COL_NUM) {
- return;
- }
- let rollbg = this.rollBG[i];
- rollbg.stopAllActions();
- let yy = rollbg.y;
- let destIdx = this.maxRolItemlLen - 3 - Math.floor(yy/-this.sizec);
- for(let j = destIdx-3; j >= destIdx-6; --j) {
- this.tempValue[i][j] = this.tempValue[i][j-destIdx+6];
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.getItemSpineData(this.tempValue[i][j]), this.isSpecialIcon(this.tempValue[i][j]));
- }
- let destY = (this.maxRolItemlLen - destIdx+1) * -this.sizec;
- let lastTime = (yy - destY + 50)/this.sizec/10;
- cc.tween(rollbg)
- .to(lastTime, {y: destY-50})
- .to(0.1, {y: destY}, {easing: 'sineInOut'})
- .call(()=>{
- this.setItemColInfo(i, destIdx);
- rollbg.y = 0;
- })
- .start()
- },
- justEnd(i) {
- if(i >= this.MAX_COL_NUM) {
- return;
- }
- let rollbg = this.rollBG[i];
- rollbg.stopAllActions();
- let yy = rollbg.y;
- let destIdx = this.maxRolItemlLen - 3 - Math.floor(yy/-this.sizec);
- for(let j = destIdx-3; j >= destIdx-6; --j) {
- this.tempValue[i][j] = this.tempValue[i][j-destIdx+6];
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.getItemSpineData(this.tempValue[i][j]), this.isSpecialIcon(this.tempValue[i][j]));
- }
- let destY = (this.maxRolItemlLen - destIdx+1) * -this.sizec;
- let lastTime = (yy - destY + 50)/this.sizec/10*0.5;
- cc.tween(rollbg)
- .to(lastTime, {y: destY-50})
- .call(()=>{
- this.hotRolls(i+1);
- })
- .to(0.1, {y: destY}, {easing: 'sineInOut'})
- .call(()=>{
- this.setItemColInfo(i, destIdx);
- rollbg.y = 0;
- })
- .start()
- },
- rollEnds(i) {
- // if(i == 0) {
- // ScenceManager.Instance().getGameComponent().onGameEnd();
- // }
- if(i > 4) {
- this.delayShowPrizes(600);
- return;
- }
- let rollbg = this.rollBG[i];
- rollbg.stopAllActions();
- let yy = rollbg.y;
- let destIdx = Math.floor(this.maxRolItemlLen - 3.5 - Math.floor(yy/-this.sizec));
- // Global.print("i"+i+" "+destIdx)
- for(let j = destIdx-2; j >= destIdx-6; --j) {
- this.tempValue[i][j] = this.tempValue[i][j-destIdx+6];
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.getItemSpineData(this.tempValue[i][j]), this.isSpecialIcon(this.tempValue[i][j]));
- }
-
- let destY = (this.maxRolItemlLen - destIdx+1) * -this.sizec;
- let lastTime = (yy - destY + 10)/this.sizec/10*0.3;
- if(this.bQuick) {
- cc.tween(rollbg)
- .call(()=>{
- this.rollEnds(i+1);
- })
- .to(lastTime, {y: destY-50})
- .to(0.1, {y: destY}, {easing: 'sineInOut'})
- .call(()=>{
- this.setItemColInfo(i, destIdx);
- rollbg.y = 0;
- })
- .start()
- return;
- }
- // Global.print(`endTime:${i}, ${lastTime}`)
- cc.tween(rollbg)
- .to(lastTime, {y: destY-50})
- .call(()=>{
- this.rollEnds(i+1);
- this.playEffect("rollend");
- })
- // .to(0.03, {y: destY-30}, {easing: 'sineIn'})
- .to(0.03, {y: destY})
- // .delay(this.delayTime)
- .call(()=>{
- this.setItemColInfo(i, destIdx);
- rollbg.y = 0;
- // rollbg.y = -16*140;
- // this.rollEnds(i+1);
- })
- .start()
- },
- delayShowPrizes(delayTime) {
- this.stopHotBGAct();
- //cash结束, 先播cash中奖动画
- if(this._rollResultData.m_ruyi == 1) {
- cc.tween(this.node)
- .delay(0.1)
- .call(()=>{
- // this.playEffectByCashCnt();
- this.behindShowPrizes();
- })
- .delay(delayTime/1000)
- .call(()=>{
- this.goCashPrizes(false);
- ScenceManager.Instance().getGameComponent().showCashWin(this.cashCnt);
- })
- .start()
- }else{
- this.updateBGAni();
- cc.tween(this.node)
- .delay(0.1)
- .call(()=>{
- // this.playEffectByCashCnt();
- this.beforeShowPrizes();
- })
- .delay(delayTime/1000)
- .call(()=>{
- // this.showNumAni(this.cashCnt);
- this.showPrizes();
- })
- .start()
- }
- return;
- cc.tween(this.node)
- .delay(0.1)
- .call(()=>{
- if(this._rollResultData.m_ruyi == 1) {
- this.behindShowPrizes();
- }else{
- this.beforeShowPrizes();
- }
- // this.beforeShowPrizes();
- })
- .delay(delayTime/1000)
- .call(()=>{
- this.bGameEnd = true;
- //没有中彩金和小游戏 才展示
- //有
- if(this._hasSpecial && this._rollResultData.m_ruyi != 1) {
- this.showNumAni(this.cashCnt);
- }
- if(this._rollResultData.m_ruyi == 1) {
- this.goCashPrizes(false);
- ScenceManager.Instance().getGameComponent().showCashWin(this.cashCnt);
- }else{
-
- this.showPrizes();
- }
-
- if(this._rollResultData.m_ruyi == 1 || this.cashCnt < 3) {
- this._hasSpecial = false;
- this.cashCnt = 0;
- }
- ScenceManager.Instance().getGameComponent().upDeskRecordCashCnt(this.cashCnt);
- // this.showPrizes();
- })
- .delay(0.3)
- .call(()=>{
- ScenceManager.Instance().getGameComponent().showGameEnd();
- })
- .start()
- },
- goCashPrizes(bShow) {
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- this.lightJS[i][j].goCashPrizes(bShow);
- }
- }
- },
- beforeShowPrizes() {
- for(let j = 0; j < GameProtocol.MAX_COL_NUM; ++j) {
- for(let i = 0; i < GameProtocol.MAX_ROW_NUM; ++i) {
- this.lightJS[j][i].showNewPrizes(this._hasSpecial);
- }
- }
- },
- behindShowPrizes() {
- for(let j = 0; j < GameProtocol.MAX_COL_NUM; ++j) {
- for(let i = 0; i < GameProtocol.MAX_ROW_NUM; ++i) {
- this.lightJS[j][i].showEndPrizes();
- }
- }
- },
- showPrizes() {
- this.bGameEnd = true;
- if(this._rollResultData.m_ruyi == 1 || this.cashCnt < 3) {
- this._hasSpecial = false;
- this.cashCnt = 0;
- }
- if(this._rollResultData.m_ruyi == 1) {
- this.updateBGAni();
- }
- ScenceManager.Instance().getGameComponent().changeBGM(this.cashCnt);
- ScenceManager.Instance().getGameComponent().upDeskRecordCashCnt(this.cashCnt, this._rollResultData.m_ruyi == 1);
- this.showNumAni(this.cashCnt);
- this.goCashPrizes(true);
- // ScenceManager.Instance().getGameComponent().showGameWinScore();
- this.updateRollBGAni(this.cashCnt);
- if(this._lineCount > 0) {
- let nowIdx = 0;
- let func = ()=>{
- if(nowIdx >= this._lineCount) {
- this.unschedule(func);
- return;
- }
- this.lineNodes[this._lineID[nowIdx++]].active = true;
- this.playEffect("line");
- }
- this.schedule(func, 0.1);
- cc.tween(this.node)
- .delay(this._lineCount*0.1+0.5)
- .call(()=>{
- ScenceManager.Instance().getGameComponent().showGameWinScore();
- this.resetItemsShow();
- this.resetAllLines();
- })
- .delay(0.1)
- .call(()=>{
- // this.resetItemsShow();
- this.showLines(0);
- })
- .start();
- }else{
- ScenceManager.Instance().getGameComponent().showGameWinScore();
- }
- },
- resetAllLines() {
- for(let i = 0; i < this.lineNodes.length; ++i) {
- this.lineNodes[i].active = false;
- }
- },
- showLines(iIndex) {
- if(iIndex >= this._lineCount) {
- this.showLines(0);
- return;
- }
- // this.resetAllLines();
- let lineID = this._lineID[iIndex];
- this.lineNodes[lineID].active = true;
- let lineArr = this.linesArr[lineID];
- let count = this._lineSize[iIndex];
- for(let k = 0; k < count; ++k) {
- let idx = lineArr[k];
- let i = idx % 10;
- let j = Math.floor(idx/10);
- this.lightJS[i][j].showPrizes();
- }
- cc.tween(this.node)
- .delay(1)
- // .call(()=>{
- // this.resetItemsShow();
- // this.resetAllLines();
- // })
- // .delay(0.1)
- .call(()=>{
- this.resetItemsShow();
- this.resetAllLines();
- this.showLines(iIndex+1);
- })
- .start();
- },
- setRollDatas(msg) {
- this._rollResultData = msg;
- this.setItemDatas(msg.m_desk_data);
- this._hasSpecial = msg.m_is_berserk == 1;
- //线信息
- this._lineCount = msg.m_line_count;
- this._lineID = msg.m_line_id;
- this._lineSize = msg.m_line_size;
- this._lineIcon = msg.m_line_icon;
- this._lineTimes = msg.m_line_times;
- this.analyzeLinesData();
- this.doOthersWithResultData();
- },
- setItemDatas(itemData) {
- this.cashCnt = 0;
- for(let i = 0; i < this.MAX_ROW_NUM; ++i) {
- for(let j = 0;j < this.MAX_COL_NUM; ++j) {
- this.tempValue[j][i+1] = itemData[i][j];
- this.elementJS[j][i+1].setValue(itemData[i][j], this.itemSpines[this.tempValue[i][j]], this.isSpecialIcon(this.tempValue[i][j]));
- if(this.isSpecialIcon(itemData[i][j])) {
- this.cashCnt++;
- }
- }
- }
- // Global.print(this.tempValue);
- // Global.print(itemData);
- },
- resetItemCounts() {
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- for(let j = 0; j < this.maxRolItemlLen; ++j) {
- this.elementJS[i][j].resetCount();
- }
- this.rollBG[i].active = true;
- }
- let showIcon = -1;
- if(this._hasSpecial) {
- showIcon = GameProtocol.LIGHT_ICON;
- }else{
- this.numAni.node.active = false;
- }
- this.resetAllLines();
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- this.lightJS[i][j].resetShow();
- this.lightNode[i][j].active = this.lightJS[i][j].getValue() == showIcon;
- this.lightJS[i][j].resetCashShow();
- }
- }
- },
- resetItemsShow() {
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- this.lightJS[i][j].showNotPrizes();
- }
- }
- },
- analyzeLinesData() {
- this._allTimers = 0;
- for(let i = 0; i < this._lineCount; ++i) {
- let lineID = this._lineID[i];
- let lineArr = this.linesArr[lineID];
- this._allTimers += this._lineTimes[i];
- for(let j = 0; j < this._lineSize[i]; ++j) {
- let idx = lineArr[j];
- let x = idx % 10;
- let y = Math.floor(idx/10);
- this.elementJS[x][y+16].addCount();
- }
- }
- },
- doOthersWithResultData() {
- //设置
- let data = this._rollResultData.m_desk_data;
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- if(this.lightNode[i][j].active == false) {
- this.lightJS[i][j].setValue(data[j][i], this.getItemSpineData(data[j][i]), this.isSpecialIcon(data[j][i]));
- this.lightJS[i][j].setCount(this.elementJS[i][j+16].getCount());
- }
- }
- }
- },
- playEffect(effName, needStop = false) {
- ScenceManager.Instance().getGameComponent().playEffect(effName, needStop);
- },
- update (dt) {
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- let yy = this.rollBG[i].y;
- for(let j = 0; j < this.maxRolItemlLen; ++j) {
- let dy = this.elementNode[i][j].y + yy;
- this.elementNode[i][j].active = (dy > -3*this.sizec) && (dy < 3*this.sizec);
- }
- }
- if(this.delayShowNextTitleTime <= 0) {
- this.nowTitleIdx++;
- this.upTitleAni();
- }else{
- this.delayShowNextTitleTime-=dt;
- }
- },
- });
|