1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258 |
- var GameBase = require("GameBase");
- var ProtocolGameServer = require("ProtocolGameServer");
- var GameProtocol = require("RaioGameProtocol");
- var AnalyzeXieYi = require("AnalyzeRaioXieYi");
- var MakeXieYi = require("MakeRaioXieYi");
- var Global = require("Global");
- var topTipMsg = require("topTipMsg");
- var UIHelper = require("UIHelper");
- var BaseDefine = require("BaseDefine");
- var GameConstant = require("GameConstant");
- const LanguageKey = require("LanguageKey");
- import { CServerItem } from 'CServerItem'
- import GameManagerBase from 'GameManagerBase'
- import ScenceManager from 'HNScenceManager'
- const GAME_FREE = 0; //无
- const GAME_PLAYING = 1; //游戏中
- const GAME_END = 2; //游戏结束
- const GAME_PLAYSCOREING = 3; //表现分数增加中
- const GAME_GAMEEND = 4; //游戏真正结束
- const ShowNextJackpotTime = 10;
- const CASH_TIMES = [0,0,0,2,3,4,5,6,7,8,10,15,25,42,72,125,250,500,1000,2000,5000];
- cc.Class({
- extends: GameBase,
- editor: {
- menu: 'Game/Raio/GameSence'
- },
- properties: {
- //场景节点
- rollNode: cc.Node,
- playerScore: cc.Label,
- resultNode: cc.Node,
- cashWinNode: cc.Node,
- lackMoneyNode: cc.Node,
- enterAni: cc.Node,
- winScoreNode: cc.Node,
- betNode: cc.Node,
- //功能按钮
- startBtn: cc.Node,
- stopBtn: cc.Node,
- addBtn: cc.Node,
- delBtn: cc.Node,
- autoBtn: cc.Node,
- menuBtn: cc.Node,
- homeBtn: cc.Node,
- LG_PATH_SC: "",
- LP_PATH_SC: "LB-Public/",
- //其余游戏数据
- MAX_LINE: 50,
- _gameEnd: true,
- _backHome: false,
- _gameState: GAME_FREE,
- _bAutoGame: false,
- _currentScore: 0,
- _lastScore: 0,
- _nowBet: 0,
- _playingAudioID: -1,
- _startTouchStart: 0,
- _bFirstIn: true,
- _showControl: true,
- ruleNode: cc.Node,
- winSpineData: [sp.SkeletonData],
- audioArr: [cc.AudioClip],
- // noticeNode: cc.Node,
- // noticeLabel: cc.Node,
- rightJackpotNode: cc.Node,
- rightJackpotPlayer1: cc.Node,
- rightJackpotPlayer2: cc.Node,
- rightJackpotPanel: cc.Node,
- rightJackPotClone: cc.Node,
- rightJackPotShowNode: cc.Node,
- rightJackPotContent: cc.Node,
- normalBGM: [cc.AudioClip],
- specialBGM: [cc.AudioClip],
- _normalBGMID: -1,
- _specialBGMID: -1,
- _nowIdx: -1,
- },
- playLightAni(){
- this.enterAni.active = true;
- let ani = this.enterAni.getComponent(sp.Skeleton);
- ani.clearTracks();
- ani.setAnimation(0, 'a1', false);
- ani.setCompleteListener(()=>{
- ani.setCompleteListener(null);
- this.enterAni.active = false;
- })
- },
- stopBgm() {
- if(this._normalBGMID != -1) {
- cc.audioEngine.stop(this._normalBGMID);
- this._normalBGMID = -1;
- }
- if(this._specialBGMID != -1) {
- cc.audioEngine.stop(this._specialBGMID);
- this._specialBGMID = -1;
- }
- },
- resumeBGM() {
- if(this._nowIdx < 0) {return;}
- if(this._nowIdx == 3) {
- this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[2], true, cc.vv.audioMgr.bgmVolume);
- this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[2], true, cc.vv.audioMgr.bgmVolume);
- }else if(this._nowIdx == 2) {
- this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[1], true, cc.vv.audioMgr.bgmVolume);
- this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[1], true, cc.vv.audioMgr.bgmVolume);
- }else{
- this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[0], true, cc.vv.audioMgr.bgmVolume);
- if(this._nowIdx == 1) {
- this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[0], true, cc.vv.audioMgr.bgmVolume);
- }
- }
- },
- changeBGM(cashCnt) {
- // cc.error(cashCnt);
- if(cashCnt <= 10) {
- if(cashCnt >= 3) {
- if(this._nowIdx == 1) {
- return;
- }
- }else{
- if(this._nowIdx == 0) {
- return;
- }
- }
- }else if(cashCnt <= 15) {
- if(this._nowIdx == 2) {
- return;
- }
- }else{
- if(this._nowIdx == 3) {
- return;
- }
- }
- this.stopBgm();
- if(cashCnt <= 10) {
- // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[0], true, cc.vv.audioMgr.bgmVolume);
- this._nowIdx = 0;
- if(cashCnt >= 3) {
- // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[0], true, cc.vv.audioMgr.bgmVolume);
- this._nowIdx = 1;
- }
- }else if(cashCnt <= 15) {
- // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[1], true, cc.vv.audioMgr.bgmVolume);
- // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[1], true, cc.vv.audioMgr.bgmVolume);
- this._nowIdx = 2;
- }else{
- // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[2], true, cc.vv.audioMgr.bgmVolume);
- // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[2], true, cc.vv.audioMgr.bgmVolume);
- this._nowIdx = 3;
- }
- if(cc.vv.audioMgr.bgmVolume <= 0) {
- return;
- }
- this.resumeBGM();
- // if(cashCnt <= 10) {
- // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[0], true, cc.vv.audioMgr.bgmVolume);
- // this._nowIdx = 0;
- // if(cashCnt >= 3) {
- // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[0], true, cc.vv.audioMgr.bgmVolume);
- // this._nowIdx = 1;
- // }
- // }else if(cashCnt <= 15) {
- // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[1], true, cc.vv.audioMgr.bgmVolume);
- // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[1], true, cc.vv.audioMgr.bgmVolume);
- // this._nowIdx = 2;
- // }else{
- // this._normalBGMID = cc.audioEngine.playMusic(this.normalBGM[2], true, cc.vv.audioMgr.bgmVolume);
- // this._specialBGMID = cc.audioEngine.playMusic(this.specialBGM[2], true, cc.vv.audioMgr.bgmVolume);
- // this._nowIdx = 3;
- // }
- },
- update(dt) {
- if(this.delayNextTime <= 0) {
- this.jumpNextJackpot();
- }else{
- this.delayNextTime -= dt;
- }
- },
- getItemSpineData(id) {
- if(this.rollPanel) {
- return this.rollPanel.getItemSpineData(id);
- }
- },
- onLoad () {
- this.rollPanel = this.rollNode.getComponent("RaioRollPanel");
- this.gameConfig = {};
- this.bets = [];
- this.LG_PATH_SC = "";
- this.judgeFuncArr = [];
-
- this.jackpotRecord = [];
- this.deskCashCnts = [];
- this.deskRecords = [];
- },
- start () {
- this.node.parent = cc.director.getScene().getChildByName("Canvas");
- this.node.setPosition(0,0);
- let player = this.getSelfPlayer();
- if(player)
- this._lastScore = player.getUserScore();
- this.upPlayerScore(this._lastScore);
-
- this._gameEnd = true;
- this._backHome = false;
- this.changeGameState(GAME_FREE);
- this._bFirstIn = true;
- this._gameRecords = [];
- this.changeBtnState(false);
- this.curBetIndex = 0;
- this._playingAudioID = -1;
- this.upBetAddOrDelState();
- this.addNormalButtonListener();
- this.nowShowIdx = 0;
- this.delayNextTime = ShowNextJackpotTime;
- this.jackpotRecord = [];
- this.getJackpotRecord();
- this.stopBtn.active = false;
- this.playLightAni();
- this.changeBGM(0);
- },
- //添加按钮事件
- addNormalButtonListener() {
- UIHelper.addButtonListener(this.startBtn, this.node, "RaioGameSence", "onClickStart");
- UIHelper.addButtonListener(this.stopBtn, this.node, "RaioGameSence", "onClickStop");
- UIHelper.addButtonListener(this.autoBtn, this.node, "RaioGameSence", "onClickQuick");
- UIHelper.addButtonListener(this.addBtn, this.node, "RaioGameSence", "onClickAdd");
- UIHelper.addButtonListener(this.delBtn, this.node, "RaioGameSence", "onClickDel");
- UIHelper.addButtonListener(this.menuBtn, this.node, "RaioGameSence", "onClickMenu");
- // UIHelper.addButtonListener(this.homeBtn, this.node, "RaioGameSence", "onClickHome");
- },
- onClickCloseControlInfo() {
- this._showControl = false;
- this.node.getChildByName("ControlInfo").active = false;
- },
- // 控制数据
- onSubSendControlInfo(data) {
- // return;
- if(BaseDefine.LOCALTEST && this._showControl) {
- Global.print(data);
- this.node.getChildByName("ControlInfo").active = true;
- this._controlInfo = data;
- this.showControlInfo();
- }
- },
- showControlInfo() {
- const infoNode = cc.find("ControlInfo/info", this.node);
- if(!infoNode.active) return;
- let data = this._controlInfo;
- let txt = `<b>`
- + `<color=#ffffff>房间杀率:${parseFloat(data.RoomSha/100.0).toFixed(2)}%</c> `
- + `<color=#ffffff>触发系统赢:${parseFloat(data.RoomWin/100.0).toFixed(2)}%</c> `
- + `<color=#ffffff>触发系统输:${parseFloat(data.RoomLost/100.0).toFixed(2)}%</c>\n`
- + (
- (!!data.IsDanKong) ? (
- `<color=#ffffff>单控有</c> `
- + `<color=#ffffff>单控玩家${(data.DanType==1)? "输" : ((data.DanType==2)? "赢": "无")}</c> `
- + `<color=#ffffff>随到${data.RoomSuiRate}%</c> `
- + `<color=#ffffff>玩家: ${data.szNickName}</c> `
- + `<color=#ffffff>门槛: ${data.DanMinBet}</c>`
- ): (
- (!!data.QunState) ? (
- `<color=#ffffff>群控${(data.RoomResult==1)? "系统赢" : ((data.RoomResult==2)? "系统输": "无控制")}</c>`
- + `<color=#ffffff>随到概率${parseFloat(data.RoomSuiRate/100.0).toFixed(2)}%</c>\t`
- ): (
- `<color=#ffffff>单控无, 群控无</c>`
- )
- )
- )
- + `<color=#ffffff> 控制值${data.cbControlValue}</c>`
-
- infoNode.getChildByName("label").getComponent(cc.RichText).string = txt;
- },
- onSocketUpdateUniqueCode(data){
- Global.print(`收到唯一对局码: (${data.strUniqueCode})`);
- if(!data.strUniqueCode) {return;}
- },
- judgeCannotRollGame() {
- //下注配置为空
- if(!this.bets || !this.gameConfig || !this.gameConfig.nJetton || this.curBetIndex == null) {
- return false;
- }
- //检测钱是否够用
- if(this._lastScore < Global.unify(this.bets[this.curBetIndex])) {
- // this.ShowGuideNode();
- this.showLowLackMoney();
- return false;
- }
- this._currentScore = this._lastScore - Global.unify(this.bets[this.curBetIndex]);
- this.upPlayerScore(this._currentScore);
- return true;
- },
- showLowLackMoney() {
- if(cc.vv.config.ReviewApk) {return;}
- this.lackMoneyNode.active = true;
- },
- lackClose() {
- this.lackMoneyNode.active = false;
- this.goldGameLeave();
- },
- lackSure() {
- this.lackMoneyNode.active = false;
- UIHelper.showWaitNode("loadResSingle", "")
- cc.vv.GetHallScript().showBuyGold(()=>{
- this.goldGameLeave();
- });
- },
- test() {
- ScenceManager.Instance().setGameComponent(this);
- this.gameConfig.nJetton = [50,100,500,5000]
- this.bets = [50,100,500,5000]
- this._currentScore = cc.vv.globalUserInfo.getUserScore();
- this._lastScore = cc.vv.globalUserInfo.getUserScore();
- this.curBetIndex = 0;
- this.leftFreeCount = 0;
- cc.vv.needFree = false;
- },
- testResult() {
- let data = {};
- data.cbFreeAdd = 0;
- data.cbFreeTime = this.leftFreeCount >= 0?this.leftFreeCount:0;
- data.m_berserk_data1 = [];
- data.m_berserk_data2 = [];
- data.m_chair_id = 0;
- data.m_chip_size = this.bets[this.curBetIndex];
- data.m_deposit_lotttery = 0;
- data.m_is_berserk = 0;
- data.m_kongming = 0;
- data.m_ruyi = 0;
- data.m_lottery_size = 0;
- data.lCurScore = this._currentScore;
- data.m_line_count = 0;
- 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];
- 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];
- 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];
- 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];
- data.m_desk_data = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]];
- let freeCount = 0;
- for(let i = 0; i < 3; ++i) {
- for(let j = 0; j < 5; ++j) {
- data.m_desk_data[i][j] = this.getRandomValue(j);
- if(i == 2 && j > 1 && cc.vv.needFree) {
- data.m_desk_data[i][j] = GameProtocol.FREE_ICON
- }
- if(data.m_desk_data[i][j] == GameProtocol.FREE_ICON) {
- freeCount++;
- }
- }
- }
- if(freeCount >= 3) {
- data.cbFreeTime = 5;
- data.cbFreeAdd = 5;
- data.m_kongming = 1;
- }
- let iconTimes = [
- [0,0,5,10,25],
- [0,0,5,10,25],
- [0,0,5,10,25],
- [0,0,5,15,30],
- [0,0,5,15,30],
- [0,0,10,20,40],
- [0,0,10,20,40],
- [0,0,10,20,50],
- [0,0,10,25,70],
- [0,0,10,25,80],
- [0,0,10,25,80],
- [0,0,10,25,80],
- [0,0,10,25,80],
- ];
- let linesArr = this.rollPanel.linesArr;
- let win = 0;
- 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);
- // Global.print("x:"+x+" y:"+y)
- let value = data.m_desk_data[y][x];
- if(j == 0) {
- startV = value;
- }else{
- if(value == GameProtocol.WILD_ICON || value == startV) {
- count++;
- }else{
- break;
- }
- }
- }
- if(count >= 3) {
- data.m_line_id[data.m_line_count] = i;
- data.m_line_size[data.m_line_count] = count;
- data.m_line_icon[data.m_line_count] = startV;
- data.m_line_times[data.m_line_count] = iconTimes[startV][count-1];
- win += data.m_line_times[data.m_line_count];
- data.m_line_count++;
- }
- }
- data.m_lottery_size = Global.unify(win*data.m_chip_size/50)*5;
- data.lCurScore = this._currentScore + data.m_lottery_size;
- this._lastScore = data.lCurScore;
- cc.vv.globalUserInfo.setUserScore(this._lastScore*100);
- setTimeout(()=>{
- this.onRollEndInfo(data);
- }, 300);
- },
- getRandomValue(i) {
- if(i > 0) {
- return this.rollPanel.getRandomValue();
- }
- let ddd = Math.floor(Math.random()*100);
- if(ddd > 90) {
- return ddd%2+10;
- }
- return ddd % 9;
- },
- onEventSceneMessage(gameStatus,lookonUser,data) {
- Global.print("GameSence onEventSceneMessage 场景消息 ");
- var arr = new DataView(data.slice(0, 8));
- var dataView = new DataView(data.slice(8));
- var msgHead = { m: arr.getUint16(4, true), s: arr.getUint16(6, true), d: null };
- arr = null;
- this.gameConfig = AnalyzeXieYi.analyze_GameConfig(dataView);
- Global.print(this.gameConfig);
- this.rollPanel.forceStop();
- this.bets = this.gameConfig.nJetton;
- this.deskRecords = this.gameConfig.mDeskDataArr;
- this.deskCashCnts = this.gameConfig.cbTrueCnt;
- this.curBetIndex = 0;
- this.refrushBet();
- },
- onEventGameMessage(data) {
- var arr = new DataView(data.slice(0, 8));
- var dataView = new DataView(data.slice(8));
- var msgHead = { m: arr.getUint16(4, true), s: arr.getUint16(6, true), d: null };
- arr = null;
- // Global.print(msgHead)
- var msg = AnalyzeXieYi.analyzeData(msgHead.m, msgHead.s, dataView);
- switch (msgHead.s) {
- case GameProtocol.SUB_S_REBACK_LOTTERY: { // 操作记录
- Global.print("SGLB::结果");
- this.onRollEndInfo(msg);
- }
- break;
- case GameProtocol.SUB_S_JACKPOT_RESET: { // 操作记录
- Global.print("JACKPOT:"+JSON.stringify(msg));
- // this.updateJackpot(msg);
- // this.rollPanel.updateJackpotValue(msg.lJackPot);
- }
- break;
- case GameProtocol.SUB_S_SEND_CONTROL_INFO: {
- Global.print("SUB_S_SEND_CONTROL_INFO");
- this.onSubSendControlInfo(msg);
- }
- break;
- default: {
- Global.print("SGLBGameSence onEventGameMessage error ");
- }
- break;
- }
- },
- showDebugRewardInfo() {
- let count = this.gameEndData.m_line_count;
- let lineid = this.gameEndData.m_line_id;
- let str = "中奖信息:" + count + "条线[";
- for(let i = 0; i < count; ++i) {
- str += (lineid[i]+1) + ',';
- }
- str += ']\n';
- str += this.gameEndData.m_is_berserk == 1 ? "、出CASH" : "";
- str += this.gameEndData.m_ruyi == 1 ? "、CASH结束" : "";
-
- const infoNode = cc.find("ControlInfo/info", this.node);
- infoNode.getChildByName("reward").getComponent(cc.RichText).string = str;
- },
- onEventGameRecord(data) {
- let dd = AnalyzeXieYi.analyze_Record(data);
- this._gameRecords.push(dd);
- this.addOneRecord(dd);
- // if(this._gameRecords.length >= 60) {
- // this.showRecordsPanel();
- // }
- },
- onEventJackpotRecord(data) {
- let dd = AnalyzeXieYi.analyze_JackpotRecord(data);
- this.jackpotRecord.push(dd);
- Global.print(dd);
- if(this.jackpotRecord.length == 1) {
- this.showWithNowIdx();
- }
- },
- onSocketHorseMessage(data) {
- if(cc.vv.config.ReviewApk) {return;}
- if(this.node.getChildByName("notice1") == null) {return;}
- Global.print(data)
- var str = data.szMessage;
- var list = str.split('##');
- if(this.getGameKind() == list[0]) {
- var rewardTxt = ['', 'jackpot'];
- var gameinfo = GameConstant.getGameUiInfoByKindId(list[0]);
- 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>`;
- this.marqueueArr.push(sstr);
- if(!this.updateMaring) {
- this.updateMaring = true;
- this.schedule(this.updateMarqueue);
- }
- if(this.delayMarqueueTime <= 0) {
- this.delayMarqueueTime += 5;
- // this.showNextMar();
- }
- }
- this.rightJackpotPanel.active = false;
- this.jackpotRecord.splice(0);
- this.nowShowIdx = 0;
- this.getJackpotRecord();
- },
- showNextMar() {
- var kStr = this.marqueueArr.shift();
- let noticeNode = this.node.getChildByName("notice1");
- let noticeLabel = noticeNode.getChildByName("Mask").getChildByName("label_notice");
- noticeNode.active = true;
- noticeLabel.x = 300;
- if(noticeLabel.getComponent(cc.RichText)) {
- noticeLabel.getComponent(cc.RichText).string = kStr;
- }else{
- noticeLabel.getComponent(cc.Label).string = kStr;
- }
-
- this.delayMarqueueTime = 25;
- },
- showWithNowIdx() {
- if(this.jackpotRecord.length <= 0) {
- return;
- }
- if(this.nowShowIdx >= this.jackpotRecord.length) {
- this.nowShowIdx = 0;
- }
- this.rightJackpotNode.active = true;
- let info = this.jackpotRecord[this.nowShowIdx];
- this.setItemInfos(this.rightJackpotPlayer1, info);
- this.rightJackpotPlayer1.y = 0;
- this.rightJackpotPlayer2.y = -75;
- this.delayNextTime = ShowNextJackpotTime;
- },
- jumpNextJackpot() {
- //小于两条 不滚动
- if(this.jackpotRecord.length < 2) {
- return;
- }
- this.nowShowIdx++;
- if(this.nowShowIdx >= this.jackpotRecord.length) {
- this.nowShowIdx = 0;
- }
- let info = this.jackpotRecord[this.nowShowIdx];
- let node1 = null;
- let node2 = null;
- if(this.rightJackpotPlayer1.y > this.rightJackpotPlayer2.y) {
- node1 = this.rightJackpotPlayer1;
- node2 = this.rightJackpotPlayer2;
- }else{
- node1 = this.rightJackpotPlayer2;
- node2 = this.rightJackpotPlayer1;
- }
- this.setItemInfos(node2, info);
- node1.stopAllActions();
- node2.stopAllActions();
- cc.tween(node1)
- .to(1, {y: 75})
- .call(()=>{
- node1.y = -75;
- })
- .start()
- cc.tween(node2)
- .to(1, {y: 0})
- .start()
- this.delayNextTime = ShowNextJackpotTime;
- },
- setItemInfos(node, info) {
- if(!node || !info) {
- return;
- }
- node.active = true;
- node.getChildByName("head").getChildByName("spr").getComponent(cc.Sprite).spriteFrame = cc.vv.globalUserInfo.getHeadSpriteFrameByFaceID(info.cbFaceID);
- node.getChildByName("name").getComponent(cc.Label).string = Global.subStr(info.szNickName, 12);
- node.getChildByName("times").getComponent(cc.Label).string = CASH_TIMES[info.nLotteryTimes]+'x';
- node.getChildByName("score").getComponent(cc.Label).string = 'R$:'+Global.formatString2Score(info.lLotteryMoney);
- },
- onClickShowJackpotUser() {
- this.rightJackpotPanel.active = true;
- this.rightJackpotPanel.getChildByName("mark").active = true;
-
- for(let i = 0; i < 10; ++i) {
- let item = null;
- if(i >= this.rightJackPotContent.childrenCount) {
- item = cc.instantiate(this.rightJackPotClone);
- item.parent = this.rightJackPotContent;
- }else{
- item = this.rightJackPotContent.children[i];
- }
- if(item) {
- let info = this.jackpotRecord[i];
- if(info) {
- this.setItemInfos(item, info);
- }else{
- item.active = false;
- }
- }
- }
- this.rightJackPotShowNode.stopAllActions();
- this.rightJackPotShowNode.scaleY = 0;
- cc.tween(this.rightJackPotShowNode)
- .to(0.07, {scaleY:1})
- .start()
- },
- onClickHideJackpotUser() {
- this.rightJackpotPanel.getChildByName("mark").active = false;
- this.rightJackPotShowNode.stopAllActions();
- this.rightJackPotShowNode.scaleY = 1;
- cc.tween(this.rightJackPotShowNode)
- .to(0.07, {scaleY:0})
- .call(()=>{
- this.rightJackpotPanel.active = false;
- })
- .start()
- },
- backHome: function() {
- if (CServerItem.get()) {
- CServerItem.get().PerformStandUpAction(1);
- } else {
- this.exitGame();
- }
- this._backHome = true;
- ScenceManager.Instance().gameBackScence();
- GameManagerBase.Instance().setInGameServerID(-1);
- },
- exitGameWhenPlaying() {
- if(!this._gameEnd) {
- topTipMsg.showTopTipMsg(LanguageKey.t("pubWords.cant_close_cause_gaming"));
- return;
- }
- if(cc.vv.config.ReviewApk) {
- cc.game.end();
- return;
- }
- this.goldGameLeave();
- // this.backHome();
- // this.exitGame();
- },
- ShowGuideNode() {
-
- topTipMsg.showTopTipMsg(LanguageKey.t("pubWords.coin_not_enghou"));
- this.quickBtn.getComponent(cc.Toggle).isChecked = false;
- this.upBtnInteractable(this.startBtn, true);
- this.upBetAddOrDelState();
- },
- showBackTips() {
- this.backPanel.active = true;
- },
- hideBackTips() {
- this.playEffect("button");
- this.backPanel.active = false;
- },
- upDeskRecordCashCnt(cnt, bCashEnd) {
- this.deskCashCnts[this.curBetIndex] = cnt;
- if(bCashEnd) {
- this.deskRecords[this.curBetIndex] = [
- [4,3,5,6,8],
- [4,3,5,6,8],
- [4,3,5,6,8],
- [4,3,5,6,8]
- ];
- }
- },
- onRollEndInfo(data) {
- Global.print(data);
- // this.onSocketHorseMessage({szMessage:"3019##1##u44656523165498569##18##600.00"})
- this.deskRecords[this.curBetIndex] = data.m_desk_data;
- this.gameEndData = data;
- this._lastScore = data.lCurScore;
- this.rollPanel.setRollDatas(data);
- this.rollPanel.openPrizes(false, this._bQuickGame);
- this.showDebugRewardInfo();
- },
- makeXieYi(m,s,data) {
- if(m == ProtocolGameServer.MDM_GF_FRAME) {
- return //new DataView(arrayBuffer)
- }
- return MakeXieYi.makeRoll(data);
- },
- onClickRecord() {
- this.recordContent.removeAllChildren();
- this._gameRecords.splice(0);
- this.recordPanel.active = true;
- this.getGameRecord();
- },
- onSendRoll() {
- // this.testResult();
- // return;
- let t = {};
- t.nJetton = this.gameConfig.nJetton[this.curBetIndex];
- // Global.print(t);
- this.SendGameSocketData(GameProtocol.SUB_C_LOTTERY, t);
- },
- // judgeAuto() {
- // let funcNode = this.node.getChildByName("FuncBtnNode");
- // if(this._nAutoCount == 0) {
- // this._bAutoGame = false;
- // }else{
- // this._bAutoGame = true;
- // }
- // funcNode.getChildByName("btn_left").active = this._bAutoGame;
- // let left = funcNode.getChildByName("btn_left");
- // left.active = this._bAutoGame;
- // left.getChildByName("left").active = this._nAutoCount > 0;
- // left.getChildByName("left2").active = this._nAutoCount < 0;
- // left.getChildByName("left").getComponent(cc.Label).string = this._nAutoCount;
- // },
- onStartRoll() {
- if(!this._gameEnd) return;
- this.node.stopAllActions();
- this.resetGameView();
- if(this.playingEffectID != -1) {
- cc.vv.audioMgr.stopSFX(this.playingEffectID);
- }
- //是否可以开始游戏
- if(!this.judgeCannotRollGame()) {
- return;
- }
- this._gameEnd = false;
- this.changeGameState(1);
- // if(!cc.vv.audioMgr.resumeBackMusic()) {
- // cc.vv.audioMgr.playBGM("bgm");
- // }
-
- this.onSendRoll();
- this.showCenterWinScore(0);
- this.onGameStart();
- this.rollPanel.startRollActions();
- },
- refrushBet() {
- this.upBetAddOrDelState();
- let bet = this.bets[this.curBetIndex];
- this.betNode.getChildByName("bet").getComponent(cc.Label).string = Global.formatString2Score(bet);
- if(this.curBetIndex >= 0 && this.curBetIndex < this.deskRecords.length) {
- this.rollPanel.reSetLastData(this.deskRecords[this.curBetIndex], this.deskCashCnts[this.curBetIndex]);
- this.showCenterWinScore(0);
- }
-
- },
- resetGameView() {
- this.resultNode.active = false;
- },
- resetAllBtn() {
- if(this._bAutoGame || this._bSpecialGame) return;
- this.upBtnInteractable(this.startBtn, true);
- this.upBetAddOrDelState();
- },
- onGameStart() {
- this.upBtnInteractable(this.startBtn, false);
- this.upBtnInteractable(this.addBtn, false);
- this.upBtnInteractable(this.delBtn, false);
- },
- showCenterWinScore(score) {
- // cc.error(score);
- this.winScoreNode.getComponent(cc.Label).string = 'R$'+Global.formatString2Score(score);
- },
- showGameEnd() {
- this._gameEnd = true;
- this.changeGameState(2);
- },
- onClickSkip() {
- this.playButtonEffect();
- let scoreNode = this.resultNode.getChildByName("mask").getChildByName("scoreNode");
- this.skipScoreAdd(scoreNode.getChildByName("score").getComponent(cc.Label),scoreNode.getChildByName("score2").getComponent(cc.Label))
- },
- showResultPanel() {
- let ssNodeY = [-44,-103,-103,-150,-150];
- this.changeGameState(3);
-
- this.resultNode.active = true;
- let node = this.resultNode.getChildByName("mask");
- let goldNode = node.getChildByName("goldani");
- let ssNode = node.getChildByName("scoreNode");
- let sNode = ssNode.getChildByName("score");
- let sNode2 = ssNode.getChildByName("score2");
- let sLabel = sNode.getComponent(cc.Label);
- let sLabel2 = sNode2.getComponent(cc.Label);
- let aniNode1 = node.getChildByName("wani");
- aniNode1.active = true;
- goldNode.active = true;
- ssNode.active = false;
- let anii = aniNode1.getComponent(sp.Skeleton);
- anii.skeletonData = this.winSpineData[this.winAniIdx];
- if(this.winAniIdx >= 0) {
- //金币动画
- let gAni = goldNode.getComponent(sp.Skeleton);
- // gAni.clearTracks();
- // gAni.setAnimation(0, 'a'+(this.winAniIdx>3?3:this.winAniIdx), true);
- gAni.setAnimation(0, 'a'+(this.winAniIdx+1>5?5:this.winAniIdx+1), true);
- }else{
- goldNode.active = false;
- }
- this.isPlayingScoreAddAni = true;
- //win动画
- anii.clearTracks();
- anii.setAnimation(0, "a1", false);
- anii.addAnimation(0, "a2", true);
- this.resultNode.stopAllActions();
- cc.tween(this.resultNode)
- .delay(0.3)
- .call(()=>{
- if(this.winAniIdx>=0 && this.winAniIdx<ssNodeY.length)
- ssNode.y = ssNodeY[this.winAniIdx];
- ssNode.active = true;
- sLabel.string = '0';
- sLabel2.string = '.00';
- this.playScoreAddAni(sLabel, sLabel2);
- // this.changeSkipBtnState(true);
- })
- .start()
- },
- playScoreAddAni(sLabel, sLabel2) {
- let start = 0;
- let bet = this.gameConfig.nJetton[this.curBetIndex];
- let endScore = Global.formatString2Score(this.needPlayinfScore);
- let add = parseFloat(bet/100/this.MAX_LINE);
- this.upScoreLabel = ()=>{
- start += add;
- if(start >= endScore) {
- this.skipScoreAdd(sLabel, sLabel2);
- }else{
- sLabel.string = Math.floor(start);
- sLabel2.string = ((parseFloat(start - Math.floor(start)).toFixed(2)).toString()).slice(1);
- }
- }
- if(this.upScoreLabel) {
- this.unschedule(this.upScoreLabel);
- }
- this.schedule(this.upScoreLabel, 0.01);
- },
- skipScoreAdd(sLabel, sLabel2) {
- if(this.upScoreLabel) {
- this.unschedule(this.upScoreLabel);
- }
- let score = Global.formatString2Score(this.needPlayinfScore);
- sLabel.string = Math.floor(score);
- sLabel2.string = ((parseFloat(score - Math.floor(score)).toFixed(2)).toString()).slice(1);
- this.changeSkipBtnState(false);
-
- this.delayStartNextRoll(1);
- this.isPlayingScoreAddAni = false;
- },
- hideResultPanel() {
- this.resultNode.active = false;
-
- },
- changeSkipBtnState(bShow) {
- },
- onClickResultMask() {
- if(this.isPlayingScoreAddAni) {
- this.onClickSkip();
- }else{
- this.hideResultPanel();
- }
- },
- //cash结算
- showCashWin(cnt) {
- this.cashWinNode.active = true;
- let mask = this.cashWinNode.getChildByName('mask');
- let cashAni1 = mask.getChildByName("cashani1").getComponent(sp.Skeleton);
- let cashAni2 = mask.getChildByName("cashani2").getComponent(sp.Skeleton);
- cashAni2.node.active = false;
- let countNode1 = mask.getChildByName("count");
- let timesNode = mask.getChildByName("times");
- timesNode.getComponent(cc.Label).string = CASH_TIMES[cnt]+'x';
- countNode1.getComponent(cc.Label).string = cnt;
- countNode1.scale = 0;
- countNode1.active = false;
- timesNode.scale = 0;
- timesNode.active = false;
- let showScore = this.gameEndData.m_deposit_lotttery;
- let scoreNode = mask.getChildByName("score");
- scoreNode.getComponent(cc.Label).string = 'R$'+Global.formatString2Score(showScore);
- scoreNode.y = 0;
- scoreNode.scale = 0;
- scoreNode.active = false;
- cashAni1.clearTracks();
- cashAni1.setAnimation(0, 'b1', false);
- mask.stopAllActions();
- cc.tween(mask)
- .delay(0.1)
- .call(()=>{
- countNode1.active = true;
- countNode1.opacity = 255;
- countNode1.stopAllActions();
- cc.tween(countNode1)
- .to(0.1, {scale: 2})
- .to(0.1, {scale: 1})
- .delay(1.5)
- .to(0.2, {opacity: 0})
- .start()
- timesNode.active = true;
- timesNode.opacity = 255;
- timesNode.stopAllActions();
- cc.tween(timesNode)
- .to(0.1, {scale: 2})
- .to(0.1, {scale: 1})
- .delay(1.5)
- .to(0.2, {opacity: 0})
- .start()
- })
- .start()
- this.cashWinNode.stopAllActions();
- if(cnt > 3) {
- if(cnt <= 10) {
- this.playEffectByID(0);
- }else if(cnt <= 15) {
- this.playEffectByID(1);
- }else{
- this.playEffectByID(2);
- }
- cashAni1.setCompleteListener(()=>{
- cashAni1.setCompleteListener(null);
- this.cashWinNode.active = false;
- })
- cc.tween(this.cashWinNode)
- .delay(1.8)
- .call(()=>{
- this.rollPanel.showPrizes();
- })
- .start();
- return;
- }
- cc.tween(this.cashWinNode)
- .delay(1.8)
- .call(()=>{
- cashAni2.node.active = true;
- cashAni2.clearTracks();
- cashAni2.setAnimation(0, 'b2', false);
- })
- .delay(0.1)
- .call(()=>{
- scoreNode.active = true;
- scoreNode.stopAllActions();
- cc.tween(scoreNode)
- .to(0.1, {scale: 2})
- .to(0.1, {scale: 1})
- .delay(1.5)
- .to(0.2, {scale: 0, y:-339})
- .call(()=>{
- this.winScoreNode.stopAllActions();
- let scoreL = this.winScoreNode.getComponent(cc.Label);
- scoreL.string = 'R$0.00';
- cc.tween(this.winScoreNode)
- .to(0.1, {scale: 1.2})
- .to(0.1, {scale: 1})
- .start()
- let startS = 0;
- this.schedule(()=>{
- startS += showScore*0.25;
- if(startS > showScore) {
- return;
- }
- scoreL.string = 'R$'+Global.formatString2Score(Math.floor(startS));
- }, 0.04, 4, 0.04)
- })
- .start()
- })
- .delay(2.4)
- .call(()=>{
- this.cashWinNode.active = false;
- this.rollPanel.showPrizes();
- })
- .start()
- },
- //最终结算
- showGameWinScore() {
- this.winAniIdx = -1;
- this.needPlayinfScore = this.gameEndData.m_lottery_size;
- let score = this.gameEndData.m_lottery_size
- this.winScoreNode.getComponent(cc.Label).string = 'R$'+Global.formatString2Score(score);
-
- let timers = Math.floor(score * this.MAX_LINE / this.gameConfig.nJetton[this.curBetIndex]);
- this._currentScore = this._lastScore;
- this.upPlayerScore(this._currentScore);
- // cc.tween(this.node)
- // .delay(0.3)
- // .call(()=>{
- // this.showGameEnd();
- // })
- // .start()
- this.showGameEnd();
- if(score <= 0) {
- this.delayStartNextRoll(1);
- return;
- }
- this.playSoundByTimes(timers);
- if(this.winAniIdx >= 0) {
- this.showResultPanel();
- }else{
- this.delayStartNextRoll(1);
- }
- },
- delayStartNextRoll(delayTime) {
- this.changeGameState(0);
- this.resetAllBtn();
- this.node.stopAllActions();
- cc.tween(this.node)
- .delay(delayTime)
- .call(()=>{
- if(this._bAutoGame){ //自动游戏时
- this.onStartRoll();
- }else{
- // this.upBtnInteractable(this.startBtn, true);
- this.resetAllBtn();
- }
- })
- .start()
- },
- changeGameState(state) {
- this._gameState = state;
- },
- changeBtnState(bEnd) {
- this.startBtn.active = !bEnd;
- },
- upBetAddOrDelState() {
- this.upBtnInteractable(this.delBtn, this.curBetIndex>0);
- this.upBtnInteractable(this.addBtn, this.curBetIndex<this.bets.length-1);
- },
- upBtnInteractable(btn, state) {
- btn.getComponent(cc.Button).interactable = state;
- },
-
- addOneRecord(info) {
- let item = cc.instantiate(this.recordClone);
- item.getChildByName("time").getComponent(cc.Label).string = Global.formatDate(new Date(info.nTime*1000));
- item.getChildByName("bet").getComponent(cc.Label).string = Global.formatString2Score(info.nBet);
- let win = info.nBet+info.nWinLost;
- item.getChildByName("win").getComponent(cc.Label).string = Global.formatString2Score(win);
- item.active = true;
- item.parent = this.recordContent;
- },
- showRecordsPanel() {
- this.recordContent.removeAllChildren();
- for(let i = 0; i < this._gameRecords.length; ++i) {
- let info = this._gameRecords[i];
- let item = cc.instantiate(this.recordClone);
- item.getChildByName("time").getComponent(cc.Label).string = Global.formatDate(new Date(info.nTime*1000));
- item.getChildByName("bet").getComponent(cc.Label).string = Global.formatString2Score(info.nBet);
- let win = info.nBet+info.nWinLost;
- item.getChildByName("win").getComponent(cc.Label).string = Global.formatString2Score(win);
- item.active = true;
- item.parent = this.recordContent;
- }
- this.recordPanel.active = true;
- },
- onClickStart() {
- this.playButtonEffect();
- this.onStartRoll();
- },
- onClickStop() {
- this.playButtonEffect();
- this.onStopRoll();
- },
- onClickAdd() {
- this.curBetIndex++;
- this.playButtonEffect();
- this.refrushBet();
- },
- onClickDel() {
- this.curBetIndex--;
- this.playButtonEffect();
- this.refrushBet();
- },
- onClickQuick(event) {
- this.playButtonEffect();
- this._bAutoGame = !event.target.getComponent(cc.Toggle).isChecked;
- this._nAutoCount = -1;
- },
- onClickMenu() {
- this.playButtonEffect();
- UIHelper.loadRes('GamePrefabs/Public/GameMenu', cc.Prefab, (prefab)=>{
- if (!this._ruleNode) {
- this._ruleNode = cc.instantiate(prefab);
- this._ruleNode.parent = this.node.getChildByName("MenuNode");
- }
- this._ruleNode.getComponent("GameMenu").show();
- this._ruleNode.getComponent("GameMenu").onBtnBangZhu = ()=>{
- var self = this;
- cc.resources.load("GamePrefabs/homescence/rule", cc.Prefab, function (err, prefab) {
- if (!self._rule) {
- self._rule = cc.instantiate(prefab);
- self._rule.parent = self.node;
- }
- self._rule.getComponent("homeRule").showGameRuleByGameID(self.getGameKind());
- });
- }
- this._ruleNode.getComponent("GameMenu").onClickMusic = ()=>{
- this.onClickMusic();
- }
- })
- },
- onHideRule() {
- this.ruleNode.active = false;
- },
- showRule() {
- Global.print("展示规则");
- if(this._ruleNode) {
- this._ruleNode.active = false;
- }
- this.ruleNode.active = true;
- },
- onClickMusic(){
- if(cc.vv.audioMgr.bgmVolume > 0) {
- cc.vv.audioMgr.setBGMVolume(0, false, true);
- this.stopBgm();
- }else{
- cc.vv.audioMgr.setBGMVolume(1, false, true);
- this.resumeBGM();
- }
- this._ruleNode.getComponent("GameMenu").upSetting();
- },
- playSoundByTimes(_times) {
- if(_times <= 0) return;
- Global.print("winTimes:"+_times)
- let id = 1;
- if(_times > this.MAX_LINE*120){
- id = 15;
- this.winAniIdx = 3;
- }else if(_times > this.MAX_LINE*100){
- id = 14;
- this.winAniIdx = 3;
- }else if(_times > this.MAX_LINE*80){
- id = 13;
- this.winAniIdx = 3;
- }else if(_times > this.MAX_LINE*64){
- id = 12;
- this.winAniIdx = 3;
- }else if(_times > this.MAX_LINE*48){
- id = 11;
- this.winAniIdx = 3;
- }else if(_times > this.MAX_LINE*32){
- id = 10;
- this.winAniIdx = 3;
- }else if(_times > this.MAX_LINE*20){
- id = 9;
- this.winAniIdx = 3;
- }else if(_times > this.MAX_LINE*12){
- id = 8;
- this.winAniIdx = 3;
- }else if(_times > this.MAX_LINE*8){
- id = 5;
- this.winAniIdx = 2;
- }else if(_times > this.MAX_LINE*4){
- id = 4;
- this.winAniIdx = 1;
- }else if(_times > this.MAX_LINE*2){
- id = 3;
- this.winAniIdx = 0;
- }else if(_times > this.MAX_LINE){
- id = 2;
- this.winAniIdx = -1;
- }
- // this.playEffect("Level"+this.winAniIdx);
- // this.playEffectByID(this.winAniIdx);
- },
- playEffectByID(id) {
- let audioC = this.audioArr[id];
- if(audioC) {
- this.playingEffectID = cc.vv.audioMgr.playEffectByAudioClip(audioC);
- }
- },
- playEffect(effName, needStop = false) {
- if(needStop)
- cc.vv.audioMgr.stopAllEffects();
- cc.vv.audioMgr.playSFX(effName);
- },
- playButtonEffect(){
- this.playEffect("button");
- },
- upPlayerScore(score) {
- cc.vv.globalUserInfo.setUserScore(score);
- this.playerScore.string = Global.formatString2Score(score);
- },
- });
|