123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719 |
- var GameBase = require("GameBase");
- var Global = require("Global");
- var topTipMsg = require("topTipMsg");
- var UIHelper = require("UIHelper");
- var BaseDefine = require("BaseDefine");
- var popScence = require("popScence");
- var ProtocolLoginServer = require("ProtocolLoginServer");
- const GAME_FREE = 0; //无
- const GAME_PLAYING = 1; //游戏中
- const GAME_END = 2; //游戏结束
- const GAME_PLAYSCOREING = 3; //表现分数增加中
- const GAME_GAMEEND = 4; //游戏真正结束
- cc.Class({
- extends: GameBase,
- properties: {
- //场景节点
- rollNode: cc.Node,
- playerScore: cc.Label,
- recordPanel: cc.Node,
- recordContent: cc.Node,
- recordClone: cc.Node,
- backPanel: cc.Node,
- setPanel: cc.Node,
- resultNode: cc.Node,
- guideNode: cc.Node,
- autoSelectNode: cc.Node,
- betNode: cc.Node,
- //功能按钮
- startBtn: cc.Node,
- stopBtn: cc.Node,
- skipBtn: cc.Node,
- addBtn: cc.Node,
- delBtn: cc.Node,
- maxBtn: cc.Node,
- stopAutoBtn: cc.Node,
- quickBtn: cc.Node,
- homeBtn: cc.Node,
- ruleBtn: cc.Node,
- recordBtn: cc.Node,
- setBtn: cc.Node,
- goldBtn: cc.Node,
- LG_PATH_SC: "",
- LP_PATH_SC: "LB-Public/",
- //其余游戏数据
- MAX_LINE: 50,
- _gameEnd: true,
- _backHome: false,
- _gameState: GAME_FREE,
- _bQuickGame: false,
- _bAutoGame: false,
- _bSpecialGame: false,
- _nAutoCount: 0,
- _bFreeGame: false,
- _nFreeCount: 0,
- _nFreeTotal: 0,
- _bFreeState: 0,
- _nFreeWin: 0,
- _currentScore: 0,
- _lastScore: 0,
- _nowBet: 0,
- _playingAudioID: -1,
- _startTouchStart: 0,
- _bFirstIn: true,
- _showControl: true,
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {
- this.rollPanel = this.rollNode.getComponent("LBRollPanel");
- this.gameConfig = {};
- this.autoCount = [30, 50, 100, 500, -1];
- this.bets = [];
- this.addSetBtnListener();
- //向服务器请求游戏配置
- cc.vv.netSocket.registerEvent(ProtocolLoginServer.CMD_C2S_Game_Config,this.onGameRoomInfo,this);
- let kindID = cc.vv.serverListData.getCurRoomData().KindID;
- let roomID = cc.vv.serverListData.getCurRoomData().ServerID;
- let _data = {'CMD':ProtocolLoginServer.CMD_C2S_Game_Config, 'GameID':kindID, 'RoomID': roomID};
- cc.vv.netSocket.send(JSON.stringify(_data));
- },
- start () {
- this.node.parent = cc.director.getScene().getChildByName("Canvas");
- this.node.setPosition(0,0);
- // popScence.createPopScenceNode();
- cc.vv.audioMgr.stopBackMusic();
- this._gameEnd = true;
- this._backHome = false;
- this.changeGameState(GAME_FREE);
- this._bFirstIn = true;
- this._gameRecords = [];
- this.changeBtnState(false);
- this._lastScore = cc.vv.globalUserInfo.getUserScore();
- this.upPlayerScore(this._lastScore);
- this.curBetIndex = 0;
- this._playingAudioID = -1;
- this.upBetAddOrDelState();
- this.addNormalButtonListener();
- this.initStartTouchEvent();
- this._showControl = true;
- },
- // 服务器传来的格式和之前的不一样, 转换成之前的格式.
- conversionTable(tId){
- let table = {
- '1':0, '2': 10, '3': 20,
- '4':1, '5': 11, '6': 21,
- '7':2, '8': 12, '9': 22,
- '10':3, '11': 13, '12': 23,
- '13':4, '14': 14, '15': 24
- };
- for(let key in table){
- if(key == tId)
- return table[ Number(key)];
- }
- return '没有找到对应的值';
- },
- onGameRoomInfo(data){
- let lineMap = data.LineMap;
- this.rollPanel.linesArr = [];
- for(let key in lineMap){
- this.rollPanel.linesArr.push(lineMap[key].Line);
- }
- for(let i=0; i< this.rollPanel.linesArr.length; i++){
- for(let j=0; j < this.rollPanel.linesArr[i].length; j++){
- this.rollPanel.linesArr[i][j] = this.conversionTable(this.rollPanel.linesArr[i][j]);
- }
- }
- cc.vv.netSocket.removeEvent(ProtocolLoginServer.CMD_C2S_Game_Config,this.onGameRoomInfo,this);
- },
- testResult() {
- let data = {};
- data.cbFreeAdd = 0;
- data.cbFreeTime = 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]];
- for(let i = 0; i < 3; ++i) {
- for(let j = 0; j < 5; ++j) {
- data.m_desk_data[i][j] = this.getRandomValue(j);
- }
- }
- 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]
- ]
- let linesArr = this.rollPanel.linesArr;
- let win = 0;
- for(let i = 0; i < 50; ++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 == 11 || 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);
- 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 11;
- }
- return ddd % 10;
- },
- //添加按钮事件
- addNormalButtonListener() {
- // UIHelper.addButtonListener(this.startBtn, this.node, "LBGameBase", "onClickStart");
- UIHelper.addButtonListener(this.stopBtn, this.node, "LBGameBase", "onClickStop");
- UIHelper.addButtonListener(this.skipBtn, this.node, "LBGameBase", "onClickSkip");
- UIHelper.addButtonListener(this.quickBtn, this.node, "LBGameBase", "onClickQuick");
- UIHelper.addButtonListener(this.addBtn, this.node, "LBGameBase", "onClickAdd");
- UIHelper.addButtonListener(this.delBtn, this.node, "LBGameBase", "onClickDel");
- UIHelper.addButtonListener(this.maxBtn, this.node, "LBGameBase", "onClickMax");
- UIHelper.addButtonListener(this.stopAutoBtn, this.node, "LBGameBase", "onClickStopAuto");
-
- UIHelper.addButtonListener(this.homeBtn, this.node, "LBGameBase", "onClickHome");
- UIHelper.addButtonListener(this.ruleBtn, this.node, "LBGameBase", "onClickRule");
- UIHelper.addButtonListener(this.recordBtn, this.node, "LBGameBase", "onClickRecord");
- UIHelper.addButtonListener(this.setBtn, this.node, "LBGameBase", "onClickSet");
- UIHelper.addButtonListener(this.goldBtn, this.node, "LBGameBase", "onClickGoldBuy");
- for(let i = 1; i < 6; ++i) {
- let btn = this.autoSelectNode.getChildByName("auto"+i);
- if(btn) {
- UIHelper.addButtonListener(btn, this.node, "LBGameBase", "onClickAuto", i-1);
- }
- }
- },
- initStartTouchEvent() {
- this.isShowAuto = false;
- this.clickSuccess = false;
- this.delayStartTouchShowAuto = ()=>{
- this.unschedule(this.delayStartTouchShowAuto);
- this.isShowAuto = true;
- this.onShowAuto();
- }
- this.unschedule(this.delayStartTouchShowAuto);
- this.startBtn.on(cc.Node.EventType.TOUCH_START, (event)=> {
- // cc.log("This is a callback after the trigger event");
- // this._startTouchStart = new Date().getTime();
- this.isShowAuto = false;
- this.clickSuccess = false;
- if(!this._gameEnd) {
- return false;
- }
- if(this.delayStartTouchShowAuto){
- this.unschedule(this.delayStartTouchShowAuto);
- }
- if(!this._bAutoGame && !this._bSpecialGame && this._gameEnd)
- this.schedule(this.delayStartTouchShowAuto, 1.5);
- this.clickSuccess = true;
- return true;
- });
- // this.startBtn.on(cc.Node.EventType.TOUCH_MOVE, (event)=> {
- // Global.print("MOVE");
- // Global.print(event);
- // });
- this.startBtn.on(cc.Node.EventType.TOUCH_END, (event)=> {
- // cc.log("TOUCH_END");
- if(this.delayStartTouchShowAuto){
- this.unschedule(this.delayStartTouchShowAuto);
- }
-
- if(this.isShowAuto) {
- this.isShowAuto = false;
- return;
- }
- if(this.autoSelectNode.scaleY >= 1) {
- this.onHideAuto();
- return;
- }
- if(!this.clickSuccess) return;
- this.onClickStart();
-
- });
- // this.startBtn.on(cc.Node.EventType.TOUCH_CANCEL, (event)=> {
- // Global.print("TOUCH_CANCEL");
- // Global.print(event);
- // });
- },
-
- refrushBet() {
- this.upBetAddOrDelState();
- let bet = this.bets[this.curBetIndex];
- this.betNode.getChildByName("allbet").getComponent(cc.Label).string = Global.formatString2Score(bet);
- this.betNode.getChildByName("bet").getComponent(cc.Label).string = ""+this.MAX_LINE+" x "+Global.formatString2Score(bet/this.MAX_LINE);
- },
- 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;}
- // let roomNumNode = cc.find("RoomInfoNode/num", this.node);
- // roomNumNode.active = true;
- // roomNumNode.getComponent(cc.Label).string = data.strUniqueCode;
- },
- judgeCannotRollGame() {
- //下注配置为空
- if(!this.bets || !this.gameConfig || !this.gameConfig.nJetton || this.curBetIndex == null) {
- return false;
- }
- if(this._nFreeCount > 0) {
- return true;
- }
- //检测钱是否够用
- 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;
- },
- onStartRoll() {
- if(!this._gameEnd) return;
- this.node.stopAllActions();
- this.resetGameView();
- cc.vv.audioMgr.stopAllEffects();
- //是否可以开始游戏
- if(!this.judgeCannotRollGame()) {
- return;
- }
- this._gameEnd = false;
- this.changeGameState(GAME_PLAYING);
- if(!cc.vv.audioMgr.resumeBackMusic()) {
- cc.vv.audioMgr.playBGM("bgm");
- }
-
- this.upLeftCount();
- this.onSendRoll();
- this.showCenterNormal();
- this.onGameStart();
- this.rollPanel.startRollActions();
- },
- onStopRoll() {
- if(this._gameEnd) {
- return;
- }
- // this.rollPanel.openPrize(true, this._bQuickGame);
- this.rollPanel.openPrizes(true, this._bQuickGame);
- this.onGameEnd();
- },
- onRollEndInfo(data) {
- if(!this._bQuickGame)
- this.changeBtnState(true);
- this.gameEndData = data;
- this.rollPanel.setRollDatas(data);
- this.rollPanel.openPrizes(false, this._bQuickGame);
- },
- onCancelAutoRoll() {
- this._bAutoGame = false;
- this._nAutoCount = 0;
- if(this._gameState == GAME_FREE) {
- this.resetAllBtn();
- }
- this.stopAutoBtn.active = false;
- },
- onStartAutoRoll(autoC) {
- this._nAutoCount = autoC;
- this._bAutoGame = true;
- this.stopAutoBtn.active = true;
- this.onStartRoll();
- },
- upLeftCount() {
- if(!this._bAutoGame) return;
- this._nAutoCount--;
- this._bAutoGame = this._nAutoCount != 0;
- this.stopAutoBtn.active = this._bAutoGame;
- let left = this.stopAutoBtn.getChildByName("l");
- left.active = this._nAutoCount > 0;
- left.getComponent(cc.Label).string = this._nAutoCount;
- this.stopAutoBtn.getChildByName("ll").active = this._nAutoCount < 0;
- },
- resetGameView() {
- this.hideResultPanel();
- this.hideGuideNode();
- },
- resetAllBtn() {
- if(this._bAutoGame || this._bSpecialGame) return;
- this.upBtnInteractable(this.startBtn, true);
- this.upBtnInteractable(this.stopBtn, true);
- this.upBtnInteractable(this.maxBtn, true);
- this.upBetAddOrDelState();
- },
- onGameStart() {
- this.upBtnInteractable(this.startBtn, false);
- this.upBtnInteractable(this.addBtn, false);
- this.upBtnInteractable(this.delBtn, false);
- this.upBtnInteractable(this.maxBtn, false);
- },
- onGameEnd() {
- this.changeBtnState(false);
- },
- showGameEnd() {
- this._gameEnd = true;
- this.changeGameState(GAME_END);
- setTimeout(()=>{
- // Global.print("pauseBackMusic")
- if(this._gameEnd && !this._backHome) {
- // Global.print(this.node);
- cc.vv.audioMgr.pauseBackMusic();
- }
- }, 3000);
- },
- playScoreAddAni(sLabel, sLabel2) {
- let start = 0;
- let bet = this.gameConfig.nJetton[this.curBetIndex];
- let endScore = Global.formatString2Score(this.needPlayinfScore);
- let add = parseFloat(bet/10/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);
- },
- delayStartNextRoll(delayTime) {
- this.changeGameState(GAME_FREE);
- this.resetAllBtn();
- this.node.stopAllActions();
- cc.tween(this.node)
- .delay(delayTime)
- .call(()=>{
- if(this._bAutoGame || this._bSpecialGame){ //自动游戏时
- this.onStartRoll();
- }
- })
- .start()
- },
-
- onShowAuto() {
- this.autoSelectNode.stopAllActions();
- cc.tween(this.autoSelectNode)
- .to(0.1, {scaleY: 1})
- .start()
- },
- onHideAuto() {
- this.autoSelectNode.stopAllActions();
- cc.tween(this.autoSelectNode)
- .to(0.1, {scaleY: 0})
- .start()
- },
- ShowGuideNode(){
- if(cc.vv.config.ReviewApk) return;
- this.guideNode.active = true;
- },
- hideRecordsPanel() {
- this.playButtonEffect();
- this.recordPanel.active = false;
- },
- hideGuideNode() {
- this.guideNode.active = false;
- },
- addSetBtnListener() {
- let node = this.setPanel.getChildByName("mask");
- UIHelper.addButtonListener(node.getChildByName("music_off"), this.node, "LBGameBase", "onClickSetAudio", 1);
- UIHelper.addButtonListener(node.getChildByName("music_on"), this.node, "LBGameBase", "onClickSetAudio", 2);
- UIHelper.addButtonListener(node.getChildByName("effect_off"), this.node, "LBGameBase", "onClickSetAudio", 3);
- UIHelper.addButtonListener(node.getChildByName("effect_on"), this.node, "LBGameBase", "onClickSetAudio", 4);
- UIHelper.addButtonListener(node.getChildByName("btn-gb"), this.node, "LBGameBase", "hideSetNode");
- },
- hideSetNode() {
- this.playButtonEffect();
- this.setPanel.active = false;
- },
- onClickSetAudio(event, data) {
- if(data == '1') {
- cc.vv.audioMgr.setBGMVolume(1, false, true);
- }else if(data == '2') {
- cc.vv.audioMgr.setBGMVolume(0, false, true);
- }else if(data == '3') {
- cc.vv.audioMgr.setSFXVolume(1);
- }else if(data == '4') {
- cc.vv.audioMgr.setSFXVolume(0);
- }
- this.changeAudioBtnState();
- },
- changeAudioBtnState() {
- let sfxVolume = cc.vv.audioMgr.sfxVolume;
- let bgmVolume = cc.vv.audioMgr.bgmVolume;
- let node = this.setPanel.getChildByName("mask");
- node.getChildByName("music_off").active = bgmVolume == 0;
- node.getChildByName("music_on").active = bgmVolume != 0;
- node.getChildByName("effect_off").active = sfxVolume == 0;
- node.getChildByName("effect_on").active = sfxVolume != 0;
- },
- changeGameState(state) {
- this._gameState = state;
- },
- changeSkipBtnState(bShow) {
- this.skipBtn.active = bShow;
- },
- changeBtnState(bEnd) {
- this.stopBtn.active = 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;
- },
- /**
- * 快速:开启的话 默认无跳过,全部一起停止
- * @param {*} bQuick
- */
- onChangeQuick(bQuick) {
- this._bQuickGame = bQuick;
- },
- getQuickState() {
- return this._bQuickGame;
- },
- upPlayerScore(score) {
- this.playerScore.string = Global.formatString2Score(score);
- },
- onUserEnter(clientUserItem) {
- this._currentScore = clientUserItem.GetUserScore();
- this._lastScore = this._currentScore;
- this.upPlayerScore(this._lastScore);
- },
- upPlayerInfo(clientUserItem) {
- this._lastScore = clientUserItem.GetUserScore();
- },
- //按钮监听
- onClickStart() {
- this.playButtonEffect();
- this.onStartRoll();
- },
- onClickStop() {
- this.playButtonEffect();
- this.onStopRoll();
- },
- onClickSkip() {
-
- },
- onClickAdd() {
- this.curBetIndex++;
- this.playButtonEffect();
- this.refrushBet();
- },
- onClickDel() {
- this.curBetIndex--;
- this.playButtonEffect();
- this.refrushBet();
- },
- onClickMax() {
- this.curBetIndex = this.bets.length-1;
- this.playButtonEffect();
- this.refrushBet();
- },
- onClickStopAuto() {
- this.playButtonEffect();
- this.onCancelAutoRoll();
- },
- onClickAuto(event, eventdata) {
- if(eventdata >= this.autoCount.length) {
- return;
- }
- this.playButtonEffect();
- this.onHideAuto();
- this.onStartAutoRoll(this.autoCount[eventdata]);
- },
- onClickQuick(event) {
- this.playButtonEffect();
- this.onChangeQuick(!event.target.getComponent(cc.Toggle).isChecked);
- },
- onClickHome() {
-
- },
- onClickRule() {
-
- },
- onClickRecord() {
-
- },
- onClickSet() {
- },
- onClickGoldBuy() {
- },
- playButtonEffect() {
- },
- //播放音效
- playEffect(effName, needStop = false) {
- if(needStop)
- cc.vv.audioMgr.stopAllEffects();
- cc.vv.audioMgr.playSFX(effName);
- },
- //播放通用音效
- playLPEffect(effName, needStop = false) {
- if(needStop)
- cc.vv.audioMgr.stopAllEffects();
- cc.vv.audioMgr.playSFX(effName);
- },
- // update (dt) {
- // if(this.stopBackMusicTimes > 0) {
- // this.stopBackMusicTimes -= dt;
- // if(this.stopBackMusicTimes <= 0) {
- // cc.vv.audioMgr.pauseBackMusic();
- // }
- // }
- // },
- });
|