123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- 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;
- 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.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()){
- 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();
- }
- }
|