1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045 |
- var RollPanel = require("LBRollPanel");
- var Global = require("Global");
- var topTipMsg = require("topTipMsg");
- var UIHelper = require("UIHelper");
- var BaseDefine = require("BaseDefine");
- var GameProtocol = require("SGLBGameProtocol");
- import ScenceManager from 'HNScenceManager'
- const arr_posX = [-373, -186, 1, 186, 373];
- cc.Class({
- extends: RollPanel,
- editor: {
- menu: 'Game/SGLB/RollPanel'
- },
- properties: {
- aniNode: cc.Node,
- // rollBG: [cc.Node],
- // itemClone: cc.Prefab,
- // itemSpines: [sp.SkeletonData],
- // bGameEnd: false,
- },
- // LIFE-CYCLE CALLBACKS:
- // onLoad () {
- // this._rollResultData = {};
- // this._lineCount = 0;
- // this._lineSize = [];
- // this._lineID = [];
- // this._lineIcon = [];
- // this._lineTimes = [];
- // this.elementNode = [];
- // this.elementJS = [];
- // this.rollNode = [];
- // this.itemData = [];
- // // this.initSingleItemLists();
- // this.initLongLists();
- // this._startRollTime = 0;
- // },
- // update(dt) {
- // // Global.print(dt)
- // for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- // let yy = this.rollBG[i].y;
- // for(let j = 0; j < this.maxRolItemlLen; ++j) {
- // let dy = this.rollNode[i][j].y + yy;
- // this.rollNode[i][j].active = (dy > -2*sizec) && (dy < 2*sizec);
- // }
- // }
- // },
- // initLongLists() {
- // this.tempValue = [];
- // for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- // this.elementNode[i] = [];
- // this.elementJS[i] = [];
- // this.rollNode[i] = [];
- // this.itemData[i] = [];
- // this.tempValue[i] = [];
- // this.rollBG[i].active = true;
- // 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 - j)*(sizec);
- // item.parent = this.rollBG[i];
- // item.active = true;
- // this.rollNode[i][j] = item;
- // this.elementJS[i][j] = this.rollNode[i][j].getComponent("SGLBItem");
- // this.elementJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]]);
- // }
- // }
- // },
- // startRollActions() {
- // this.bGameEnd = false;
- // this.node.stopAllActions();
- // this.resetItemCounts();
- // for(let i = 0; i < GameProtocol.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.itemSpines[this.tempValue[i][j]]);
- // }
- // cc.tween(rollbg)
- // .sequence(
- // cc.tween().to(1, {y: -12*sizec}),
- // cc.tween().call(()=>{ rollbg.y = 0, this.resetRollingItemValue(i) })
- // )
- // .repeatForever()
- // .start()
- // }
- // this._startRollTime = new Date().getTime();
- // },
- // 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]]);
- // }
- // // Global.print("resetItem"+i);
- // // for(let j = 1; j < 4; ++j) {
- // // Global.print("j:"+j+" v:"+this.tempValue[i][j]);
- // // }
- // },
- openPrizes(justEnd, bQuick) {
- if(this.bGameEnd == true) {
- return;
- }
- let endTime = new Date().getTime();
- let leftTime = this._startRollTime - endTime + 1000;
- 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;
- //快速,并且前四排骷髅头总数少于2
- if(bQuick || justEnd) {
- for(let i = 0;i < this.MAX_COL_NUM; ++i) {
- if(this.FreeCount >= 2) {
- this.playEffect("freeicon");
- cc.tween(this.node)
- .delay(leftTime/1000+0.2)
- .call(()=>{
- this.hotRolls(i);
- })
- .start()
- return;
- }
- cc.tween(this.node)
- .delay(leftTime/1000)
- .call(()=>{
- this.quickEnd(i);
- if(i >= 4) {
- this.delayShowPrizes(1000);
- }
- })
- .start()
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- if(this.tempValue[i][j+1] == this.SPECIAL_ICON) {
- this.FreeCount++;
- }
- }
- }
- this.playEffect("normal_stop");
- return;
- }
- cc.tween(this.node)
- .delay(leftTime/1000)
- .call(()=>{
- this.rollEnds(0);
- })
- .start()
- },
- setItemColInfo(i, dIdx) {
- let bHasFree = false;
- for(let j = this.maxRolItemlLen-5; j < this.maxRolItemlLen; ++j) {
- this.elementNode[i][j-this.maxRolItemlLen+dIdx-1].active = true;
- this.elementNode[i][j].active = true;
- this.tempValue[i][j] = this.tempValue[i][j-this.maxRolItemlLen+dIdx-1];
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]], this.isSpecialIcon(this.tempValue[i][j]));
- if(j > this.maxRolItemlLen-5 && j < this.maxRolItemlLen-1) {
- if(this.tempValue[i][j] == this.SPECIAL_ICON) {
- bHasFree = true;
- }
- }
- }
- if(bHasFree) {
- this.playEffect("freeicon");
- }else{
- this.playEffect("normal_stop");
- }
- },
- 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.itemSpines[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/12;
- 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.itemSpines[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/12*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()
- },
- hotRolls(i) {
- if(i >= this.MAX_COL_NUM) {
- this.delayShowPrizes(600);
- return;
- }
- this.playLPEffect("hotroll");
- let rollbg = this.rollBG[i];
- rollbg.stopAllActions();
- this.aniNode.active = true;
- this.aniNode.x = arr_posX[i];
- let yy = rollbg.y;
- let lessY = yy + 12*this.sizec;
- let lastTime = lessY/this.sizec/12*0.3;
- cc.tween(rollbg)
- .to(lastTime, {y: -12*this.sizec})
- .sequence(
- cc.tween().call(()=>{ rollbg.y = 0, this.resetRollingItemValue(i) }),
- cc.tween().to(0.5, {y: -12*this.sizec})
- )
- .repeatForever()
- .start()
- cc.tween(this.node)
- .delay(2)
- .call(()=>{
- this.aniNode.active = false;
- this.justEnd(i);
- })
- .start()
- },
- rollEnds(i) {
- if(i == 0) {
- ScenceManager.Instance().getGameComponent().onGameEnd();
- }
- if(this.FreeCount >= 2) {
- cc.tween(this.node)
- .delay(0.3)
- .call(()=>{
- this.hotRolls(i);
- })
- .start()
- // this.hotRolls(i);
- return;
- }
- if(i > 4) {
- this.delayShowPrizes(600);
- return;
- }
- //先统计骷髅头数量
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- if(this.tempValue[i][j+1] == this.SPECIAL_ICON) {
- this.FreeCount++;
- }
- }
- let rollbg = this.rollBG[i];
- rollbg.stopAllActions();
- let yy = rollbg.y;
- let destIdx = this.maxRolItemlLen - 3 - Math.floor(yy/-this.sizec);
- // Global.print("i"+i+" "+destIdx)
- 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.itemSpines[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/12;
- 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;
- }
- cc.tween(rollbg)
- .to(lastTime, {y: destY-50})
- .call(()=>{
- this.rollEnds(i+1);
- })
- .to(0.1, {y: destY}, {easing: 'sineInOut'})
- // .delay(this.delayTime)
- .call(()=>{
- this.setItemColInfo(i, destIdx);
- rollbg.y = 0;
- // rollbg.y = -16*140;
- // this.rollEnds(i+1);
- })
- .start()
- },
- delayShowPrizes(delayTime) {
- cc.tween(this.node)
- .delay(delayTime/1000)
- .call(()=>{
- this.bGameEnd = true;
- ScenceManager.Instance().getGameComponent().showGameWinScore();
- this.showPrizes();
- })
- .delay(0.6)
- .call(()=>{
- // ScenceManager.Instance().getGameComponent().resetAllBtn();
- ScenceManager.Instance().getGameComponent().showGameEnd();
- })
- .start()
- },
- // showPrizes() {
- // for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- // for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- // this.elementJS[i][j+17].showLightAniNoScale();
- // if(this._hasFreeCount == 1) {
- // this.elementJS[i][j+17].showFreeAni();
- // }
- // }
- // }
- // cc.tween(this.node)
- // .delay(2.5)
- // .call(()=>{
- // this.resetItemsShow();
- // })
- // .delay(0.5)
- // .call(()=>{
- // this.showLines(0);
- // })
- // .start();
- // },
- // showLines(iIndex) {
- // if(iIndex >= this._lineCount) {
- // this.showPrizes();
- // return;
- // }
-
- // let lineID = this._lineID[iIndex];
- // let lineArr = 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.elementJS[i][j+17].showLightAni();
- // }
- // cc.tween(this.node)
- // .delay(2)
- // .call(()=>{
- // this.resetItemsShow();
- // })
- // .delay(0.5)
- // .call(()=>{
- // this.showLines(iIndex+1);
- // })
- // .start();
- // },
- // setRollDatas(msg) {
- // this._rollResultData = msg;
- // this.setItemDatas(msg.m_desk_data);
- // this._hasFreeCount = msg.m_kongming;
- // //线信息
- // 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();
- // },
- // setItemDatas(itemData) {
- // this.allFreeCount = 0;
- // for(let i = 0; i < GameProtocol.MAX_ROW_NUM; ++i) {
- // for(let j = 0;j < GameProtocol.MAX_COL_NUM; ++j) {
- // this.tempValue[j][i+1] = itemData[i][j];
- // // Global.print("i:"+i+" j:"+j+" v:"+this.tempValue[j][i+1]+" cc:"+itemData[i][j]);
- // this.elementJS[j][i+1].setValue(itemData[i][j], this.itemSpines[this.tempValue[i][j]]);
- // if(itemData[i][j] == GameProtocol.FREE_ICON && j < GameProtocol.MAX_COL_NUM-1) {
- // this.allFreeCount++;
- // }
- // }
- // }
- // 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();
- // }
- // }
- // },
- // resetItemsShow() {
- // for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- // for(let j = 0; j < this.maxRolItemlLen; ++j) {
- // this.elementJS[i][j].showNormal();
- // }
- // }
- // },
- // analyzeLinesData() {
- // this._allTimers = 0;
- // for(let i = 0; i < this._lineCount; ++i) {
- // let lineID = this._lineID[i];
- // let lineArr = 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+17].addCount();
- // }
- // }
- // },
- /**
- * 旧版
- */
- /*
- initSingleItemLists() {
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- this.elementNode[i] = [];
- this.elementJS[i] = [];
- this.rollNode[i] = [];
- this.itemData[i] = [];
- this.rollBG[i].active = false;
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- this.itemData[i][j] = -1;
- this.elementNode[i][j] = this.createItem(i, j);
- this.elementJS[i][j] = this.elementNode[i][j].getComponent("SGLBItem");
- }
- for(let j = 0; j < 4; ++j) {
- let item = cc.instantiate(this.itemClone);
- item.y = 2 * sizec;
- item.parent = this.rollBG[i];
- item.active = false;
- this.rollNode[i][j] = item;
- }
- }
-
- this.initElementData();
- },
- createItem(i, j) {
- let item = cc.instantiate(this.itemClone);
- item.x = arr_posX[i];
- item.y = sizec - j*sizec;
- item.parent = this.resultNode;
- item.active = true;
- return item;
- },
- // getRandomValue() {
- // return Math.floor(Math.random()*100)%10;
- // },
- resetItemValue(item, value) {
- let js = item.getComponent("SGLBItem");
- if(value == undefined || value < 0){
- value = this.getRandomValue();
- }
- if(js) {
- js.setValue(value);
- }
- },
- reset () {
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- let rollbg = this.rollBG[i];
- for(let j = 0; j < rollbg.childrenCount; ++j) {
- let item = rollbg.children[j];
- let js = item.getComponent("SGLBItem");
- if(js) {
- js.setValue(Math.floor(Math.random()*100)%11);
- }
- }
- }
- },
- repeatItemAction(item) {
- item.active = true;
- item.y = 2*sizec;
- this.resetItemValue(item);
- item.stopAllActions();
- cc.tween(item)
- .sequence(
- cc.tween().to(0.4, {y: -2*sizec}),
- cc.tween().call(()=>{ item.y = 2*sizec, this.resetItemValue(item) })
- )
- .repeatForever()
- .start()
- },
- startRollAction() {
- Global.print("startRollAction");
- this.bGameEnd = false;
- // this._hasFreeCount = 0;
- this.node.stopAllActions();
- this.resetItemCount();
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- let item = this.elementNode[i][j];
- item.stopAllActions();
- cc.tween(item)
- .by(0.4, {y: -4*sizec})
- .call(()=>{
- item.active = false;
- })
- .start()
- }
- let rollbg = this.rollBG[i];
- rollbg.active = true;
- rollbg.y = 0//pos_ary[1];
- rollbg.stopAllActions();
- cc.tween(rollbg)
- .call(()=>{
- this.repeatItemAction(this.rollNode[i][0]);
- })
- .delay(0.1)
- .call(()=>{
- this.repeatItemAction(this.rollNode[i][1]);
- })
- .delay(0.1)
- .call(()=>{
- this.repeatItemAction(this.rollNode[i][2]);
- })
- .delay(0.1)
- .call(()=>{
- this.repeatItemAction(this.rollNode[i][3]);
- })
- .start()
- {// cc.tween(rollbg)
- // // .sequence(
- // // cc.tween().to(0.5, {y: pos_ary[2]}),
- // // cc.tween().call(()=>{ rollbg.y = pos_ary[1] })
- // // )
- // // .repeatForever()
- // .call(()=>{
- // this.rollNode[i][0].stopAllActions();
- // cc.tween(this.rollNode[i][0])
- // .sequence(
- // cc.tween().to(0.4, {y: -2*sizec}),
- // cc.tween().call(()=>{ this.rollNode[i][0].y = 2*sizec, this.resetItemValue(this.rollNode[i][0]) })
- // )
- // .repeatForever()
- // .start()
- // })
- // .delay(0.1)
- // .call(()=>{
- // this.rollNode[i][1].stopAllActions();
- // cc.tween(this.rollNode[i][1])
- // .sequence(
- // cc.tween().to(0.4, {y: -2*sizec}),
- // cc.tween().call(()=>{ this.rollNode[i][1].y = 2*sizec, this.resetItemValue(this.rollNode[i][1]) })
- // )
- // .repeatForever()
- // .start()
- // })
- // .delay(0.1)
- // .call(()=>{
- // this.rollNode[i][2].stopAllActions();
- // cc.tween(this.rollNode[i][2])
- // .sequence(
- // cc.tween().to(0.4, {y: -2*sizec}),
- // cc.tween().call(()=>{ this.rollNode[i][2].y = 2*sizec, this.resetItemValue(this.rollNode[i][2]) })
- // )
- // .repeatForever()
- // .start()
- // })
- // .delay(0.1)
- // .call(()=>{
- // this.rollNode[i][3].stopAllActions();
- // cc.tween(this.rollNode[i][3])
- // .sequence(
- // cc.tween().to(0.4, {y: -2*sizec}),
- // cc.tween().call(()=>{ this.rollNode[i][3].y = 2*sizec, this.resetItemValue(this.rollNode[i][3]) })
- // )
- // .repeatForever()
- // .start()
- // })
- // .start()
- }
- }
- this._startRollTime = new Date().getTime();
- },
- openPrize(justEnd, bQuick) {
- if(this.bGameEnd == true) {
- return;
- }
- let endTime = new Date().getTime();
- let leftTime = this._startRollTime - endTime + 3000;
- let delayTime = 0.2;
- if(bQuick) {
- delayTime = 0;
- leftTime -= 2000;
- }
- if(leftTime < 0 || justEnd) {
- leftTime = 0;
- }
- this.node.stopAllActions();
- let ccount = 0;
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- if(ccount < 2) {
- cc.tween(this.node)
- .delay(i*delayTime+leftTime/1000)
- .call(()=>{
- this.rollEnd(i);
- })
- .start()
- }else{
- cc.tween(this.node)
- .delay(i*delayTime+leftTime/1000)
- .call(()=>{
- this.hotRoll(i);
- })
- .start()
- return;
- }
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- if(this.itemData[i][j] == GameProtocol.FREE_ICON) {
- ccount++;
- }
- }
- }
- },
- hotRoll(i) {
- if(i >= GameProtocol.MAX_COL_NUM) {
- // ScenceManager.Instance().getGameComponent().showGameWinScore();
- // this.showPrize();
- this.delayShowPrize(600);
- return;
- }
- let rollbg = this.rollBG[i];
- rollbg.stopAllActions();
- let arr = this.rollNode[i];
- let maxTim = 1;
- for(let j = 0; j < 4; ++j) {
- let item = arr[j];
- item.active = true;
- item.stopAllActions();
- let time = (item.y + 2 * sizec) / sizec * 0.05;
- maxTim = maxTim > time ? time : maxTim;
- cc.tween(item)
- .to(time, {y: -2*sizec})
- .sequence(
- cc.tween().to(0.15, {y: -2*sizec}),
- cc.tween().call(()=>{ item.y = 2*sizec, this.resetItemValue(item) })
- )
- .repeatForever()
- .start()
- }
- cc.tween(rollbg)
- .delay(maxTim+3)
- .call(()=>{
- for(let j = 0; j < 4; ++j) {
- let item = arr[j];
- item.active = true;
- item.stopAllActions();
- let time = (item.y + 2 * sizec) / sizec * 0.01;
- maxTim = maxTim > time ? time : maxTim;
- cc.tween(item)
- .to(time, {y: -2*sizec})
- .call(()=>{
- item.active = false;
- })
- .start()
- }
- })
- .delay(0.2)
- .call(()=>{
- this.hotRoll(i+1);
- })
- .start()
- let ars = this.elementNode[i];
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- let item = ars[j];
- item.active = true;
- this.resetItemValue(item, this.getItemData(i, j));
- item.stopAllActions();
- cc.tween(item)
- .delay(maxTim+3)
- .call(()=>{
- item.y = (4-j)*sizec;
- })
- .to(0.1, {y: (1-j)*sizec})
- .start()
- }
- },
- rollEnd(i) {
- if(i == 0) {
- ScenceManager.Instance().getGameComponent().onGameEnd();
- }
- let rollbg = this.rollBG[i];
- rollbg.stopAllActions();
- let arr = this.rollNode[i];
- let maxTim = 1;
- for(let j = 0; j < 4; ++j) {
- let item = arr[j];
- item.active = true;
- item.stopAllActions();
- let time = (item.y + 2 * sizec) / sizec * 0.05;
- maxTim = maxTim > time ? time : maxTim;
- cc.tween(item)
- .to(time, {y: -2*sizec})
- .call(()=>{
- item.active = false;
- })
- .start()
- }
- let ars = this.elementNode[i];
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- let item = ars[j];
- item.active = true;
- this.resetItemValue(item, this.getItemData(i, j));
- item.y = (4-j)*sizec;
- item.stopAllActions();
- cc.tween(item)
- .delay(maxTim)
- .to(0.2, {y: (1-j)*sizec})
- .start()
- }
- if(i >= 4) {
- this.delayShowPrize(600);
- // setTimeout(()=>{
- // this.bGameEnd = true;
- // ScenceManager.Instance().getGameComponent().showGameWinScore();
- // this.showPrize();
- // }, 600);
- }
-
- return;
- {
- cc.tween(rollbg)
- .call(()=>{
- this.elementState[i][0] = ELEMENTSTATE_RUNNING;
- arr[0].y = elementPosY + sizec*4 + lessLenth;
- arr[0].active = true;
- cc.tween(arr[0])
- .to(0.2, {y: elementPosY + sizec*3-10})
- .to(0.2, {y: elementPosY + sizec*3}, {easing: 'sineInOut'})
- .call(()=>{
- this.elementState[i][0] = ELEMENTSTATE_END;
- })
- .start()
- })
- .call(()=>{
- this.elementState[i][1] = ELEMENTSTATE_RUNNING;
- arr[1].y = elementPosY + sizec*3 + lessLenth;
- arr[1].active = true;
- cc.tween(arr[1])
- .to(0.2, {y: elementPosY + sizec*2-10})
- .to(0.2, {y: elementPosY + sizec*2}, {easing: 'sineInOut'})
- .call(()=>{
- this.elementState[i][1] = ELEMENTSTATE_END;
- })
- .start()
- })
- .call(()=>{
- this.elementState[i][2] = ELEMENTSTATE_RUNNING;
- arr[2].y = elementPosY + sizec*2 + lessLenth;
- arr[2].active = true;
- cc.tween(arr[2])
- .to(0.2, {y: elementPosY + sizec-10})
- .to(0.2, {y: elementPosY + sizec}, {easing: 'sineInOut'})
- .call(()=>{
- this.elementState[i][2] = ELEMENTSTATE_END;
- if(i == 5) {
- this.bGameEnd = true;
- }
- })
- .start()
- })
- .to(0.2, {y: pos_ary[3]})
- .delay(1.5)
- .call(()=>{
- if(i == 5) {
- this.showPrize();
- }
- })
- .start()
- }
- },
- delayShowPrize(delayTime) {
- cc.tween(this.node)
- .delay(delayTime/1000)
- .call(()=>{
- this.bGameEnd = true;
- ScenceManager.Instance().getGameComponent().showGameWinScore();
- this.showPrize();
- })
- .delay(1)
- .call(()=>{
- ScenceManager.Instance().getGameComponent().resetAllBtn();
- ScenceManager.Instance().getGameComponent().showGameEnd();
- })
- .start()
- // setTimeout(()=>{
- // this.bGameEnd = true;
- // ScenceManager.Instance().getGameComponent().showGameWinScore();
- // this.showPrize();
- // }, delayTime);
- },
- showPrize() {
- return;
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- this.elementJS[i][j].showLightAni();
- if(this._hasFreeCount == 1) {
- this.elementJS[i][j].showFreeAni();
- }
- }
- }
- cc.tween(this.node)
- .delay(1)
- // .call(()=>{
- // ScenceManager.Instance().getGameComponent().resetAllBtn();
- // ScenceManager.Instance().getGameComponent().showGameEnd();
- // })
- .delay(0.5)
- .call(()=>{
- this.resetItemShow();
- })
- .delay(0.5)
- .call(()=>{
- this.showLine(0);
- })
- .start();
- },
- showLine(iIndex) {
- if(iIndex >= this._lineCount) {
- this.showPrize();
- return;
- }
-
- let lineID = this._lineID[iIndex];
- let lineArr = linesArr[lineID];
- let count = this._lineSize[iIndex];
- // Global.print(iIndex+" lineid:"+lineID+" linecount:"+count);
- // this.resetItemShow();
- for(let k = 0; k < count; ++k) {
- let idx = lineArr[k];
- let i = idx % 10;
- let j = Math.floor(idx/10);
- // Global.print("showLine:i"+i+"j"+j);
- this.elementJS[i][j].showLightAni();
- }
- cc.tween(this.node)
- .delay(1)
- .call(()=>{
- this.resetItemShow();
- })
- .delay(0.5)
- .call(()=>{
- this.showLine(iIndex+1);
- })
- .start();
- },
- setRollData(msg) {
- this._rollResultData = msg;
- this.setItemData(msg.m_desk_data);
- this._hasFreeCount = msg.m_kongming;
- //线信息
- 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.analyseLinesFromData();
- this.analyseLinesData();
- },
- analyseLinesFromData() {
- this._lineCount = 0;
- this._lineID = [];
- this._lineSize = [];
- this._lineIcon = [];
- this._lineTimes = [];
- for(let i = 0; i < GameProtocol.MAX_LINE_COUNT; ++i) {
- let lineArr = linesArr[i];
- let count = 1;
- let startV = -1;
- for(let j = 0; j < lineArr.length; ++j) {
- let idx = lineArr[j];
- let x = idx % 10;
- let y = Math.floor(idx/10);
- let value = this.itemData[x][y];
- if(j == 0) {
- startV = value;
- }else{
- if(value == 11 || value == startV) {
- count++;
- }else{
- break;
- }
- }
- }
- if(count >= 3) {
- this._lineCount++;
- this._lineID.push(i);
- this._lineSize.push(count);
- }
- }
- Global.print(this._lineCount);
- Global.print(this._lineID);
- Global.print(this._lineSize);
- },
- analyseLinesData() {
- this._allTimers = 0;
- for(let i = 0; i < this._lineCount; ++i) {
- let lineID = this._lineID[i];
- let lineArr = 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].addCount();
- }
- }
- },
- setItemData(itemData) {
- for(let i = 0; i < GameProtocol.MAX_ROW_NUM; ++i) {
- for(let j = 0;j < GameProtocol.MAX_COL_NUM; ++j) {
- this.itemData[j][i] = itemData[i][j];
- }
- }
- // this.initElementData();
- },
- resetItemCount() {
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- this.elementJS[i][j].resetCount();
- }
- }
- },
- resetItemShow() {
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- this.elementJS[i][j].showNormal();
- }
- }
- },
- initElementData() {
- for(let i = 0; i < GameProtocol.MAX_COL_NUM; ++i) {
- for(let j = 0; j < GameProtocol.MAX_ROW_NUM; ++j) {
- this.resetItemValue(this.elementNode[i][j], this.getItemData(i, j));
- }
- }
- },
- getItemData(i, j) {
- if(!this.itemData || this.itemData.length <= 0) {
- return -1;
- }
- return this.itemData[i][j];
- },
- */
- // update (dt) {},
- });
|