123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- import { _decorator, Component, Node, Label } from 'cc';
- import { ClientEvent } from '../clientEvent';
- import { Constant, room_type } from '../constant';
- import { GameMng } from '../GameMng';
- import { UIButton } from '../gcommon/UIButton';
- import { UIManager } from '../gcommon/UIManager';
- import { msgManager } from '../socket/msgManager';
- import { roomData } from '../UserData/roomData';
- import GBoardChess from './ChessGame/GBoardChess';
- import { waitView } from './waitView';
- const { ccclass, property } = _decorator;
- @ccclass('wait_tongqian')
- export class wait_tongqian extends Component {
- @property(Node)
- lab_menpiao: Node = null;
- @property(Node)
- lab_duzhu: Node = null;
- @property(Node)
- btn_start: 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;
- } //新的一局了
- if(GameMng._userData.room.roomtype===room_type._chuji_tongqian){
- this.lab_menpiao.getComponent(Label).string ="对局门票: "+1000
- this.lab_duzhu.getComponent(Label).string ="单局输赢: "+5000
- }else if(GameMng._userData.room.roomtype===room_type._zhongji_tongqian){
- this.lab_menpiao.getComponent(Label).string ="对局门票: "+3000
- this.lab_duzhu.getComponent(Label).string ="单局输赢: "+20000
- }
-
- UIButton.BindClick(this.btn_start,function(){
- self.ready()
- },this)
-
- UIButton.BindClick(this.btn_start_2,()=>{
- self.ready()
- },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(){
- waitView.Show("正在匹配!")
- 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;
- }
- }
- }
- }
|