123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- 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 UILoading from '../gcommon/UILoading';
- import { UIManager } from '../gcommon/UIManager';
- import { msgManager } from '../socket/msgManager';
- import { Tools } from '../Tools';
- import { roomData } from '../UserData/roomData';
- import ChessMng, { ChessType } from './DiffSel/ChessMng';
- const { ccclass, property } = _decorator;
- @ccclass('waitFirend')
- export class waitFirend extends Component {
- @property(Node)
- lab_dumiao:Node=null;
- @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_start_2: Node = null;
- @property(Node)
- btn_yaoqing: Node = null;
- @property(Node)
- btn_yaoqing_2: Node = null;
- @property(Node)
- onReady: Node = null;
- @property(Node)
- onReady_2: Node = null;
- @property(Node)
- lab_roomid: Node = null;
- @property(Node)
- lab_new_roomid: Node = null;
- @property(Node) //新的一盘
- node_newRound: Node = null;
- @property(Node) //最初的一盘
- node_initRound: Node = null;
- start() {
-
- if(ChessMng.Instance.chesstype===ChessType.renjiboyi){
- }else{
- if(GameMng._userData.room!=null){
- 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_meibujiashi.active = false;
- this.lab_dumiao.active = false;
- this.lab_roomid.getComponent(Label).string ="象棋"
- let self = this;
- if(GameMng._userData.room!=null){
- this.lab_jushu.getComponent(Label).string ="局时:"+Tools.time(GameMng._userData.room.totaltime)
- this.lab_bushu.getComponent(Label).string ="步时:"+Tools.time(GameMng._userData.room.everysteptime)
- if(GameMng._userData.room.roomtype===room_type._jing_dian_hao_you){
- if(GameMng._userData.room.countdown>0){
- this.lab_dumiao.active = true;
- this.lab_dumiao.getComponent(Label).string ="读秒:"+Tools.time(GameMng._userData.room.countdown)
- }
- }
- if(GameMng._userData.room.roomtype===room_type._mei_miao_die_jia_hao_you){
- if(GameMng._userData.room.everystepaddtime>0){
- this.lab_meibujiashi.active = true;
- this.lab_meibujiashi.getComponent(Label).string ="每步加时:"+Tools.time(GameMng._userData.room.everystepaddtime)
- }
- }
-
- if(GameMng._userData.room.wait_rival_startGame_status==3||GameMng._userData.room.wait_rival_startGame_status==1){
- this.btn_start.active = false;
- this.onReady.active = true;
- }
- UIButton.BindClick(this.btn_start,function(){
- self.sendReady(self.btn_start)
- },this)
- UIButton.BindClick(this.btn_start_2,function(){
- self.sendReady(self.btn_start_2)
- },this)
- UIButton.BindClick(this.btn_yaoqing,function(){
- UIManager.AddPrefab(GameMng.Instance.invite_firend_view)
- },this)
- UIButton.BindClick(this.btn_yaoqing_2,function(){
- UIManager.AddPrefab(GameMng.Instance.invite_firend_view)
- },this)
- this.lab_roomid.getComponent(Label).string = "象棋"+"【"+GameMng._userData.room.roomid+"】"
- this.lab_new_roomid.getComponent(Label).string = "象棋"+"【"+GameMng._userData.room.roomid+"】"
- }
- ClientEvent.on(Constant.UI_EVENT.UI_MSG_ready,this.sendReady,this)
-
- }
- sendReady(node:Node=null){
- if(node){
- node.active = false;
- }
- UILoading.deley_show(2);
- msgManager.ready()
- }
- onDestroy(){
- ClientEvent.off(Constant.UI_EVENT.UI_MSG_ready,this.sendReady,this)
- }
- recvReady(room:roomData){
- console.log("recvReady",room.wait_rival_startGame_status)
- if(ChessMng.Instance.chesstype===ChessType.renjiboyi){
- }else{
- 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;
- }
- }
- }
- setData(){
-
- }
- update(deltaTime: number) {
-
- }
- }
|