123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663 |
- var RollPanel = require("LBRollPanel");
- var Global = require("Global");
- var UIHelper = require("UIHelper");
- var BaseDefine = require("BaseDefine");
- var GameProtocol = require("RomanGameProtocol");
- import ScenceManager from 'HNScenceManager'
- const arr_posX = [-425, -214, 0, 213, 424];
- cc.Class({
- extends: RollPanel,
- editor: {
- menu: 'Game/Roman/RollPanel'
- },
- properties: {
- aniNode: cc.Node,
- itemLayer: cc.Node,
- endLayer: cc.Node,
- fraLayer: cc.Node,
- kuangClone: cc.Node,
- _hMoreMan: false,
- _hMoreWoman: false,
- },
- // LIFE-CYCLE CALLBACKS:
- initOthers () {
- this.goldTimes = [50, 100, 200, 500, 1000, 2000, 5000, 10000];
- this.endNode = [];
- this.endNodeJS = [];
- this.kuangArrs = [];
- this.endLayer.removeAllChildren();
- this.fraLayer.removeAllChildren();
- this.sunValue = [];
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- this.sunValue[i] = [];
- for(let j = 0; j < this.maxRolItemlLen-5; ++j) {
- this.sunValue[i][j] = this.isSunGold(this.tempValue[i][j]) ? this.getRandomGoldValue() : 0;
- }
- for(let j = this.maxRolItemlLen-5; j < this.maxRolItemlLen; ++j) {
- this.sunValue[i][j] = this.sunValue[i][j-12];
- }
- }
- for(let i = 0; i < this.MAX_ROW_NUM; ++i) {
- this.endNode[i] = [];
- this.endNodeJS[i] = [];
- this.kuangArrs[i] = [];
-
- for(let j = 0; j < this.MAX_COL_NUM; ++j) {
- let item = cc.instantiate(this.itemClone);
- item.x = arr_posX[j];
- item.y = (1-i)*(this.sizec);
- item.parent = this.endLayer;
- item.active = false;
- this.endNode[i][j] = item;
- this.endNodeJS[i][j] = this.endNode[i][j].getComponent("LBItem");
- this.endNodeJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]], this.sunValue[i][j]);
- let kuang = cc.instantiate(this.kuangClone);
- kuang.x = arr_posX[j];
- kuang.y = (1-i)*(this.sizec);
- kuang.parent = this.fraLayer;
- kuang.active = false;
- this.kuangArrs[i][j] = kuang;
- }
- }
- this.endLayer.active = false;
- this.fraLayer.active = false;
- },
- forceStop() {
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- let rollbg = this.rollBG[i];
- rollbg.active = true;
- rollbg.stopAllActions();
- rollbg.y = 0;
- }
- },
- resetView() {
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- let rollbg = this.rollBG[i];
- rollbg.active = true;
- rollbg.y = 0;
- rollbg.stopAllActions();
- }
- },
- getRandomValue() {
- return Math.floor(Math.random()*100)%6;
- },
- getRandomGoldValue() {
- let val = Math.floor(Math.random()*10000);
- if(val < 5055) {
- return this.goldTimes[0];
- }else if(val < 7555) {
- return this.goldTimes[1];
- }else if(val < 9055) {
- return this.goldTimes[2];
- }else if(val < 9555) {
- return this.goldTimes[3];
- }else if(val < 9805) {
- return this.goldTimes[4];
- }else if(val < 9930) {
- return this.goldTimes[5];
- }else if(val < 9980) {
- return this.goldTimes[6];
- }else {
- return this.goldTimes[7];
- }
- },
- startRollActions() {
- this.itemLayer.active = true;
- this.endLayer.active = false;
- this.fraLayer.active = false;
- this._hMoreMan = false;
- this._hMoreWoman = false;
- this._bSunGame = false;
- this._rollSunData = null;
- // this._super();
- this.bGameEnd = false;
- this.node.stopAllActions();
- this.resetItemCounts();
- 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.itemSpines[this.tempValue[i][j]], this.sunValue[i][j]);
- }
- */
- cc.tween(rollbg)
- .sequence(
- cc.tween().to(0.4, {y: -6*this.sizec}),
- cc.tween().call(()=>{
- for(let j = this.maxRolItemlLen-5; j < this.maxRolItemlLen; ++j) {
- this.tempValue[i][j] = this.tempValue[i][j-12];
- // this.tempValue[i][j] = this.getSpecialRandomValue();
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]], this.isSpecialIcon(this.tempValue[i][j]));
- }
- }),
- cc.tween().to(0.4, {y: -12*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 + 1000;
- this.delayTime = 0.2;
- if(bQuick) {
- leftTime -= 700;
- }
- 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) {
- // SoundFun.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++; //ma 取消hotRolls
- }
- }
- }
- // SoundFun.playEffect("normal_stop");
- return;
- }
- 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-1].active = true;
- this.elementNode[i][j].active = true;
- this.tempValue[i][j] = this.tempValue[i][j-this.maxRolItemlLen+dIdx-1];
- this.sunValue[i][j] = this.sunValue[i][j-this.maxRolItemlLen+dIdx-1];
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]], this.sunValue[i][j]);
- }
- // for(let k = this.maxRolItemlLen-4; k < this.maxRolItemlLen-1; ++k) {
- // if(this.isSunGold(this.tempValue[i][k])){
- // this.elementJS[i][k].setGoldLabel(this.endNodeJS[k-this.maxRolItemlLen+4][i].getGoldLabel());
- // }
-
- // }
- this.playEffect("line"+i);
- },
- resetRollingItemValue(i) {
- for(let j = 9; j < this.maxRolItemlLen-5; ++j) {
- this.tempValue[i][j] = this.getRandomValue();
- if(this.isSunGold(this.tempValue[i][j])) {
- this.sunValue[i][j] = this.getRandomGoldValue()*this._singleLineBet;
- }else{
- this.sunValue[i][j] = 0;
- }
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]], this.sunValue[i][j]);
- }
- for(let j = this.maxRolItemlLen-5; j < this.maxRolItemlLen; ++j) {
- this.elementNode[i][j].active = true;
- }
- },
- 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.sunValue[i][j] = this.sunValue[i][j-destIdx+6];
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]], this.sunValue[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.sunValue[i][j] = this.sunValue[i][j-destIdx+6];
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]], this.sunValue[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(400);
- return;
- }
- //先统计骷髅头数量
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- if(this.tempValue[i][j+1] == this.SPECIAL_ICON) {
- // this.FreeCount++; ////ma 取消hotRolls
- }
- }
- 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.sunValue[i][j] = this.sunValue[i][j-destIdx+6];
- this.elementJS[i][j].setValue(this.tempValue[i][j], this.itemSpines[this.tempValue[i][j]], this.sunValue[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.beforeShowPrize();
- })
- .delay(0.1)
- .call(()=>{
- ScenceManager.Instance().getGameComponent().showGameWinScore();
- if(this._bSunGame) {
- this.showSpecialPrize()
- this.playEffect("sunstart")
- }else{
- this.bGameEnd = true;
-
- this.showPrizes();
- }
- })
- .delay(0.1)
- .call(()=>{
- if(!this._bSunGame) {
- ScenceManager.Instance().getGameComponent().showGameEnd();
- }else{
- // ScenceManager.Instance().getGameComponent().resetAllBtn();
- }
- // ScenceManager.Instance().getGameComponent().resetAllBtn();
-
- })
- .start()
- },
- beforeShowPrize() {
- this.endLayer.active = true;
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- this.endNodeJS[j][i].showNormal();
- this.kuangArrs[j][i].active = false;
- }
- }
- this.fraLayer.active = true;
- this.itemLayer.active = false;
- // if(this._hMoreMan) {
- // this.playEffect("man");
- // }
- // if(this._hMoreWoman) {
- // this.playEffect("woman");
- // }
- },
- showSpecialPrize() {
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- this.kuangArrs[j][i].active = this.endNodeJS[j][i].getCount() > 0;
- if(this._hasSpecial) {
- this.endNodeJS[j][i].showSpecialAni();
- }
- this.endNodeJS[j][i].playGoldCoinAni();
- }
- }
- cc.tween(this.node)
- .delay(3)
- .call(()=>{
- // ScenceManager.Instance().getGameComponent().onSunGameInfo();
- ScenceManager.Instance().getGameComponent().showSun2Game();
- })
- .start()
- },
- showPrizes() {
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- this.kuangArrs[j][i].active = this.endNodeJS[j][i].getCount() > 0;
- if(this._hasSpecial) {
- this.endNodeJS[j][i].showSpecialAni();
- }
- }
- }
- 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 = this.linesArr[lineID];
- let count = this._lineSize[iIndex];
- let hWild = false;
- for(let k = 0; k < count; ++k) {
- let idx = lineArr[k];
- let i = idx % 10;
- let j = Math.floor(idx/10);
- this.kuangArrs[j][i].active = true;
- this.endNodeJS[j][i].showLightAni();
- if(this.endNodeJS[j][i]._value == GameProtocol.WILD_ICON) {
- hWild = true;
- }
- }
- if(hWild) {
- this.playEffect("wild");
- }
- cc.tween(this.node)
- .delay(2.6667)
- .call(()=>{
- this.resetItemsShow();
- })
- .delay(0.5)
- .call(()=>{
- this.showLines(iIndex+1);
- })
- .start();
- },
- setSpecialData(sunData) {
- this._rollSunData = sunData;
- },
- setItemDatas(itemData) {
- /*
- this._bSunGame = this._rollResultData.m_is_berserk;
- let sunVal = this._rollSunData ? this._rollSunData.wSunIconMulti : null;
- this._singleLineBet = ScenceManager.Instance().getGameComponent().getSingleLineBet();//this._rollResultData.m_chip_size / GameProtocol.MAX_LINE_COUNT;
- 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];
- if(this.isSunGold(itemData[i][j])) {
- if(this._bSunGame && sunVal) {
- this.sunValue[j][i+1] = sunVal[i][j]*this._singleLineBet;
- }else{
- this.sunValue[j][i+1] = this.getRandomGoldValue()*this._singl eLineBet;
- }
-
- }else{
- this.sunValue[j][i+1] = 0;
- }
- // this.sunValue[j][i+1] = this.isSunGold(itemData[i][j]) ? ((this._bSunGame && sunVal) ? sunVal[i][j] : this.getRandomGoldValue()) : 0;
- this.elementJS[j][i+1].setValue(itemData[i][j], this.itemSpines[this.tempValue[i][j]], this.sunValue[j][i+1]);
- }
- }
- Global.print(this.sunValue);
- // Global.print(itemData);
- */
- this._bSunGame = this._rollResultData.m_is_berserk;
- let sunValueArr = this._rollResultData.m_desk_value;
- 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.sunValue[j][i+1] = sunValueArr[i][j]; //ma
- this.elementJS[j][i+1].setValue(itemData[i][j], this.itemSpines[this.tempValue[i][j]], this.sunValue[j][i+1]);
- }
- }
- },
- doOthersWithResultData() {
- let data = this._rollResultData.m_desk_data;
- let temp = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]];
- //每列统计连续数
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- this.endNodeJS[j][i].setValue(data[j][i], this.itemSpines[data[j][i]], this.sunValue[i][j+1]);
- // if(this.isManOrWomanIcon(data[j][i])) {
- // temp[j][i] = 1;
- // for(let k = j+1; k < this.MAX_ROW_NUM; ++k) {
- // if(this.isManOrWomanIcon(data[k][i]) && data[j][i] == data[k][i]) {
- // temp[j][i]++;
- // }else{
- // break;
- // }
- // }
- // }
- // if(this.isSunGold(data[j][i]) && !this._bSunGame) {
- // let val = this.getRandomGoldValue() * singleLine
- // this.endNodeJS[j][i].setGoldLabel(val);
- // }
- }
- }
- // Global.print(JSON.stringify(temp));
- // //每列从下到上,连续的只计算最上一个其余的置-1
- // for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- // for(let j = this.MAX_ROW_NUM-1; j > 0; --j) {
- // if(temp[j][i] > 0 && temp[j-1][i] > 0 && data[j][i] == data[j-1][i]) {
- // temp[j][i] = -1;
- // if(data[j][i] == GameProtocol.MAN_ICON) {
- // this._hMoreMan = true;
- // }
- // if(data[j][i] == GameProtocol.WOMAN_ICON) {
- // this._hMoreWoman = true;
- // }
- // }
- // }
- // }
- // Global.print(JSON.stringify(temp));
- // //第一列统计合并连续的3
- // for(let i = 1; i < this.MAX_COL_NUM; ++i) {
- // if(temp[0][i] == 3 && temp[0][i-1] == 3 && data[0][i] == data[0][i-1]) {
- // temp[0][i-1] = 6;
- // temp[0][i] = -1;
- // }
- // }
- Global.print(JSON.stringify(temp));
- //设置
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- this.endNodeJS[j][i].setRowCount(temp[j][i]);
- this.endNodeJS[j][i].setCount(this.elementJS[i][j+17].getCount());
- }
- }
- // this.endLayer.active = true;
- // this.fraLayer.active = true;
- },
- isManOrWomanIcon(val) {
- return val == GameProtocol.MAN_ICON || val == GameProtocol.WOMAN_ICON;
- },
- isSunGold(val) {
- return val == GameProtocol.SUN_ICON;
- },
-
- resetItemsShow() {
- for(let i = 0; i < this.MAX_COL_NUM; ++i) {
- for(let j = 0; j < this.MAX_ROW_NUM; ++j) {
- this.kuangArrs[j][i].active = false;
- this.endNodeJS[j][i].resetShow();
- }
- }
- },
- // 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();
- // }
- // }
- // },
- });
|