import { _decorator, Component, Node, SpriteFrame, Sprite, Label, resources, Vec3 } from 'cc'; import { ClientEvent } from '../clientEvent'; import { Constant } from '../constant'; import { GameMng, quit_chess_show_view } from '../GameMng'; import AudioMng from '../gcommon/AudioMng'; import GameData from '../gcommon/GameData'; import GameUtil from '../gcommon/GameUtil'; import { ResMng } from '../gcommon/ResMng'; import ScenceMng from '../gcommon/ScenceMng'; import { UIButton } from '../gcommon/UIButton'; import { msgManager } from '../socket/msgManager'; import { Tools } from '../Tools'; import { roomData } from '../UserData/roomData'; import { settlementData } from '../UserData/settlementData'; import GBoardChess from './ChessGame/GBoardChess'; import { jifen_jiesuan } from './ChessGame/jifen_jiesuan'; import ChessMng, { ChessType } from './DiffSel/ChessMng'; import UIDiffSel from './DiffSel/UIDiffSel'; import { tongqian_jiesuan } from './tongqian_jiesuan'; const { ccclass, property } = _decorator; @ccclass('UIjiesuan') export class UIjiesuan extends Component { @property(Node) btn_close:Node=null; // @property(Node) btn_new:Node=null; // @property(Node) btn_again:Node=null;// @property(Node) btn_share:Node=null;// @property(Node) btn_reinfo:Node=null;//复盘 @property(Node) lab_des:Node=null;//对盘信息 @property(Node) sp_isWin:Node=null;// @property(SpriteFrame) winSp:SpriteFrame=null;// @property(SpriteFrame) loseSp:SpriteFrame=null;// @property(SpriteFrame) heqiSp:SpriteFrame=null;// @property(Node) self_head_sp:Node=null;// @property(Node) rival_head_sp:Node=null;// @property(Node) self_name:Node=null;// @property(Node) rival_name:Node=null;// @property(Node) block_node:Node =null; @property(Node) ui_node:Node =null; @property(Node) jifen_node:Node =null; @property(Node) tongqian_node:Node =null; @property(Node) rival_tongbi_node:Node =null; @property(Node) self_tongbi_node:Node =null; start() { let self = this; UIButton.BindClick(this.btn_close,()=>{ self.node.active = false; // AudioMng.Instance.PlayBGM(GameMng.Instance.mainbgm); // ScenceMng.Instance.load('GameLaunch'); },this); UIButton.BindClick(this.btn_new,()=>{ if(ChessMng.Instance.isHaoyouRoom()){ GameMng.Instance.quit_view = quit_chess_show_view.haoyou msgManager.quitRoom() }else if(ChessType.renjiboyi==ChessMng.Instance.chesstype){ GameMng.Instance.quit_view = quit_chess_show_view.renji GBoardChess.instance.recvQuit() } },this); UIButton.BindClick(this.btn_again,()=>{ this.node.active=false; if(ChessMng.Instance.isHaoyouRoom()){ if(GameMng._userData.room===null){ }else{ ClientEvent.dispatchEvent(Constant.UI_EVENT.UI_MSG_ready) } }else if(ChessType.renjiboyi==ChessMng.Instance.chesstype){ GBoardChess.instance.restartGame() }else if(ChessMng.Instance.isJiFenRoom()){ ClientEvent.dispatchEvent(Constant.UI_EVENT.UI_MSG_5_10_20_ready) } },this); UIButton.BindClick(this.btn_share,()=>{ },this); UIButton.BindClick(this.btn_reinfo,()=>{ },this); } update(deltaTime: number) { } setData(data:settlementData,time:string,bushu:number){ this.block_node.active = true; this.rival_tongbi_node.active =false; this.self_tongbi_node.active = false; this.ui_node.scale = new Vec3(0,0,1) this.scheduleOnce(()=>{ this.ui_node.scale = new Vec3(1,1,1) },2) if(ChessMng.Instance.chesstype===ChessType.renjiboyi){ data.result = 1-data.result; } if(data.result==1){ this.sp_isWin.getComponent(Sprite).spriteFrame = this.winSp; AudioMng.Instance.PlaySoundByName(GameMng.Instance.winclip); }else if(data.result==0){ this.sp_isWin.getComponent(Sprite).spriteFrame = this.loseSp; AudioMng.Instance.PlaySoundByName(GameMng.Instance.failclip); } var data = GBoardChess.instance.last_settlementData; if(data!=null){ switch(data.result_type){ case 0:{ //正常绝杀 break; } case 1:{ //到时间 if(data.result==1){ }else{ } break; } case 2:{ //逃跑 break; } case 3:{ //认输 break; } case 4:{ //和棋 this.sp_isWin.getComponent(Sprite).spriteFrame = this.heqiSp; break; } } } this.self_name.getComponent(Label).string = GameMng._userData.user_name if(GameMng._userData.user_avatar!=""){ Tools.loadWeiXinHead(GameMng._userData.user_avatar,this.self_head_sp.getComponent(Sprite)) } let name = "" if(ChessMng.Instance.chesstype===ChessType.renjiboyi){ name = "人机对战," this.rival_name.getComponent(Label).string = UIDiffSel.lvArr[UIDiffSel.selectIndex] ResMng.LoadAvatar(Tools.getAvatarByIndex(UIDiffSel.selectIndex+1),this.rival_head_sp.getComponent(Sprite)) this.lab_des.getComponent(Label).string = name+bushu+"步,"+GameUtil.timestampToTime() }else if(ChessMng.Instance.isHaoyouRoom()){ name = "好友对战," if(GameMng._userData.room!=null){ if(GameMng._userData.room.rival!=null){ this.rival_name.getComponent(Label).string = GameMng._userData.room.rival.user_name if(GameMng._userData.room.rival.user_avatar!=""){ Tools.loadWeiXinHead(GameMng._userData.room.rival.user_avatar,this.rival_head_sp.getComponent(Sprite)) } } if(GBoardChess.instance.last_settlementData!=null){ this.lab_des.getComponent(Label).string = name+GBoardChess.instance.last_settlementData.round+"回合,"+GBoardChess.instance.last_settlementData.server_time } } }else if(ChessMng.Instance.isJiFenRoom()){ name = "积分对战," this.jifen_node.getComponent(jifen_jiesuan).show(data) if(GameMng._userData.room!=null){ if(GameMng._userData.room.rival!=null){ this.rival_name.getComponent(Label).string = GameMng._userData.room.rival.user_name if(GameMng._userData.room.rival.user_avatar!=""){ Tools.loadWeiXinHead(GameMng._userData.room.rival.user_avatar,this.rival_head_sp.getComponent(Sprite)) } } if(GBoardChess.instance.last_settlementData!=null){ this.lab_des.getComponent(Label).string = name+GBoardChess.instance.last_settlementData.round+"回合,"+GBoardChess.instance.last_settlementData.server_time } } }else if(ChessMng.Instance.isTongqianRoom()){ this.rival_tongbi_node.active =true; this.self_tongbi_node.active = true; name = "铜钱对战," this.tongqian_node.getComponent(tongqian_jiesuan).show(data) if(GameMng._userData.room!=null){ if(GameMng._userData.room.rival!=null){ this.rival_name.getComponent(Label).string = GameMng._userData.room.rival.user_name if(GameMng._userData.room.rival.user_avatar!=""){ Tools.loadWeiXinHead(GameMng._userData.room.rival.user_avatar,this.rival_head_sp.getComponent(Sprite)) } } if(GBoardChess.instance.last_settlementData!=null){ this.lab_des.getComponent(Label).string = name+GBoardChess.instance.last_settlementData.round+"回合,"+GBoardChess.instance.last_settlementData.server_time } } } GameData.SaveGame(); } }