import { _decorator, Component, Node, Label } from 'cc'; import { ClientEvent } from '../clientEvent'; import { Constant } from '../constant'; import { GameMng } from '../GameMng'; import ScenceMng from '../gcommon/ScenceMng'; import { UIButton } from '../gcommon/UIButton'; import { UIManager } from '../gcommon/UIManager'; import { msgManager } from '../socket/msgManager'; import { Tools } from '../Tools'; import { roomData } from '../UserData/roomData'; import GBoardChess from './ChessGame/GBoardChess'; import ChessMng, { ChessType } from './DiffSel/ChessMng'; import { waitView } from './waitView'; const { ccclass, property } = _decorator; @ccclass('waitJifen') export class waitJifen extends Component { @property(Node) lab_jushu:Node=null; @property(Node) lab_bushu: Node = null; @property(Node) lab_meibujiashi: Node = null; @property(Node) btn_start: Node = null; @property(Node) btn_huanzhuo: Node = null; @property(Node) btn_huanzhuo_2: Node = null; @property(Node) onReady: Node = null; @property(Node) onReady_2: Node = null; @property(Node) btn_start_2: Node = null; @property(Node) //新的一盘 node_newRound: Node = null; @property(Node) //最初的一盘 node_initRound: Node = null; start() { if(GameMng._userData.room!=null){ let self = this; if(GameMng._userData.room.game_number>1){ this.node_newRound.active = true; this.node_initRound.active = false; }else{ this.node_newRound.active = false; this.node_initRound.active = true; } //新的一局了 this.lab_jushu.getComponent(Label).string ="局时:"+Tools.time(GameMng._userData.room.totaltime) this.lab_bushu.getComponent(Label).string ="步时:"+Tools.time(GameMng._userData.room.everysteptime) +"前3步=30秒" this.lab_meibujiashi.getComponent(Label).string ="局时用完判胜负" UIButton.BindClick(this.btn_start,function(){ self.ready() },this) UIButton.BindClick(this.btn_huanzhuo,function(){ waitView.Show("寻找对局!",()=>{ msgManager.cancel_matching_5_10_20() }) GBoardChess.instance.hideAllChess() msgManager.find_matching_5_10_20() },this) UIButton.BindClick(this.btn_huanzhuo_2,function(){ waitView.Show("寻找对局!",()=>{ msgManager.cancel_matching_5_10_20() }) GBoardChess.instance.hideAllChess() msgManager.find_matching_5_10_20() },this) UIButton.BindClick(this.btn_start_2,()=>{ self.onReady_2.active = true; self.btn_start_2.active = false; GBoardChess.instance.hideAllChess() msgManager.open_matching_5_10_20() },this) } ClientEvent.on(Constant.EVENT_TYPE.MSG_OPEN_MATCHING_5_10_20,this.openRoom,this) ClientEvent.on(Constant.EVENT_TYPE.MSG_FIND_MATCHING_5_10_20,this.findRoom,this) ClientEvent.on(Constant.EVENT_TYPE.MSG_CANCEL_MATCHING_5_10_20,this.cancelMatching,this) ClientEvent.on(Constant.UI_EVENT.UI_MSG_5_10_20_ready,this.ready,this) } onDestroy(){ ClientEvent.off(Constant.EVENT_TYPE.MSG_OPEN_MATCHING_5_10_20,this.openRoom,this) ClientEvent.off(Constant.EVENT_TYPE.MSG_CANCEL_MATCHING_5_10_20,this.cancelMatching,this) ClientEvent.off(Constant.EVENT_TYPE.MSG_FIND_MATCHING_5_10_20,this.findRoom,this) ClientEvent.off(Constant.UI_EVENT.UI_MSG_5_10_20_ready,this.ready,this) } ready(){ this.btn_start.active = false; GBoardChess.instance.hideAllChess() msgManager.open_matching_5_10_20() } cancelMatching(){ UIManager.removeWaitViewLayer() } findRoom(room:roomData){ UIManager.removeWaitViewLayer() GameMng.updateRoomData(room) console.log("findRoom",room) } openRoom(room:roomData){ this.onReady.active = true; this.btn_start.active = false; UIManager.removeWaitViewLayer() GameMng.updateRoomData(room) console.log("findRoom",room) } recvReady(room:roomData){ console.log("fuck!",room) if(GameMng._userData.room.game_number>1){ //新的一局了 if(room.wait_rival_startGame_status==3||room.wait_rival_startGame_status==1){ this.btn_start_2.active = false; this.onReady_2.active = true; }else{ this.btn_start_2.active = true; this.onReady_2.active = false; } }else{ if(room.wait_rival_startGame_status==3||room.wait_rival_startGame_status==1){ this.btn_start.active = false; this.onReady.active = true; }else{ this.btn_start.active = true; this.onReady.active = false; } } } //新的一盘 recvAgainRound(room:roomData){ if(room!=null){ this.node_newRound.active = true; this.node_initRound.active = false; if(room.wait_rival_startGame_status==3||room.wait_rival_startGame_status==1){ this.btn_start_2.active = false; this.onReady_2.active = true; }else{ this.btn_start_2.active = true; this.onReady_2.active = false; } } } update(deltaTime: number) { } }