123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- import { _decorator, Component, Node, Color, Label, Button, director, Director, SpriteFrame, Sprite } from 'cc';
- import { ClientEvent } from '../clientEvent';
- import { Constant } from '../constant';
- import { GameMng } from '../GameMng';
- import AudioMng from '../gcommon/AudioMng';
- import ScenceMng from '../gcommon/ScenceMng';
- import { UIButton } from '../gcommon/UIButton';
- import { UIManager } from '../gcommon/UIManager';
- import { msgManager } from '../socket/msgManager';
- import GBoardChess from './ChessGame/GBoardChess';
- import UIDialog from './UIDialog';
- import { waitView } from './waitView';
- const { ccclass, property } = _decorator;
- @ccclass('menuList')
- export class menuList extends Component {
- @property(Node)
- btn_quit: Node = null; //离开
- @property(Node)
- spr_renshu: Node = null;//认输
- @property(SpriteFrame)
- sp_renshu_1: SpriteFrame = null;//认输
- @property(SpriteFrame)
- sp_renshu_0: SpriteFrame = null;//认输
- @property(Node)
- spr_qiuhe: Node = null;//求和
- @property(SpriteFrame)
- sp_qiuhe_1: SpriteFrame = null;//求和
- @property(SpriteFrame)
- sp_qiuhe_0: SpriteFrame = null;//求和
- @property(Node)
- spr_huiqi: Node = null;//悔棋
- @property(SpriteFrame)
- sp_huiqi_0: SpriteFrame = null;//悔棋
- @property(SpriteFrame)
- sp_huiqi_1: SpriteFrame = null;//悔棋
- @property(Node)
- btn_renshu: Node = null;//认输
- @property(Node)
- btn_qiuhe: Node = null;//求和
- @property(Node)
- btn_huiqi: Node = null;//悔棋
- @property(Node)
- lab_qiuhe: Node = null;//求和
- @property(Node)
- lab_huiqi: Node = null;//悔棋
- @property(Node)
- lab_renshu: Node = null;//认输
- @property(Node)
- btn_shezhi: Node = null;//设置
- color:Color = new Color()
- start() {
- UIButton.BindClick(this.btn_quit,function(){
- this.onClickQuit();
- UIDialog.Show(()=>{
- msgManager.quitRoom()
- },()=>{
-
- },"是否确定退出",GBoardChess.instance.uiLayer,true)
- },this)
- UIButton.BindClick(this.btn_renshu,function(){
- this.onClickQuit();
- UIDialog.Show(()=>{
- msgManager.renshu_game()
- },()=>{
-
- },"是否认输",GBoardChess.instance.uiLayer,true)
- },this)
- UIButton.BindClick(this.btn_qiuhe,function(){
- this.onClickQuit();
- ClientEvent.dispatchEvent(Constant.UI_EVENT.UI_MSG_BTN_HEQI)
- },this)
- UIButton.BindClick(this.btn_shezhi,function(){
- this.onClickQuit();
- UIManager.AddPrefab(GameMng.Instance.uiChessSettingView)
- },this)
- UIButton.BindClick(this.btn_huiqi,function(){
- this.onClickQuit();
- ClientEvent.dispatchEvent(Constant.UI_EVENT.UI_MSG_BTN_HUIQI)
- },this)
- this.updateBtnsStatus()
- ClientEvent.on(Constant.UI_EVENT.UI_MSG_UPDATE_MENU_STATUS,this.updateBtnsStatus,this)
- }
- onDestroy(){
- ClientEvent.off(Constant.UI_EVENT.UI_MSG_UPDATE_MENU_STATUS,this.updateBtnsStatus,this)
- }
- onEnable(){
- director.once(Director.EVENT_AFTER_DRAW,function(){
- ClientEvent.dispatchEvent(Constant.UI_EVENT.UI_MSG_UPDATE_MENU_STATUS)
- })
-
- }
- updateBtnsStatus(){
- // var x = (GameMng._userData.room.huiqi_number-GBoardChess.instance.huiqi_number);
- // var y = (GameMng._userData.room.heqi_number-GBoardChess.instance.heqi_number);
- this.lab_huiqi.getComponent(Label).string = "悔棋("+ GBoardChess.instance.huiqi_number+")"
- this.lab_qiuhe.getComponent(Label).string = "和棋("+GBoardChess.instance.heqi_number+")"
- var hui_se = this.color.fromHEX("#949494")
- this.lab_huiqi.getComponent(Label).color = hui_se
- this.lab_qiuhe.getComponent(Label).color = hui_se
- this.lab_renshu.getComponent(Label).color = hui_se
- this.btn_huiqi.getComponent(Button).enabled = false;
- this.btn_qiuhe.getComponent(Button).enabled = false;
- this.btn_renshu.getComponent(Button).enabled = false;
- this.spr_renshu.getComponent(Sprite).spriteFrame = this.sp_renshu_0
- this.spr_qiuhe.getComponent(Sprite).spriteFrame = this.sp_qiuhe_0
- this.spr_huiqi.getComponent(Sprite).spriteFrame = this.sp_huiqi_0
- console.log("当前是游戏已开",GBoardChess.instance.rund_number)
- console.log("悔棋剩余",GBoardChess.instance.huiqi_number)
- console.log("和棋剩余",GBoardChess.instance.heqi_number)
- if(!GBoardChess.instance.isStartGame){
- }else{
- if(GBoardChess.instance.rund_number>=3){
- this.color = this.color.fromHEX("#5F3D36")
- if(GBoardChess.instance.rund_number>=10){
- this.btn_renshu.getComponent(Button).enabled = true;
- this.lab_renshu.getComponent(Label).color = this.color
- this.spr_renshu.getComponent(Sprite).spriteFrame = this.sp_renshu_1
- }
- if(GBoardChess.instance.who_round===1){ //自己回合
- console.log("当前是自己回合")
- }else{
- console.log("当前是对手回合")
- if(!GBoardChess.instance.isStartGame){
-
- }else{
- if(GBoardChess.instance.huiqi_number>0&&GBoardChess.instance.huiqi_setup!=GBoardChess.instance.rund_number){
- this.btn_huiqi.getComponent(Button).enabled = true;
- this.lab_huiqi.getComponent(Label).color = this.color;
- this.spr_huiqi.getComponent(Sprite).spriteFrame = this.sp_huiqi_1
- }
- if(GBoardChess.instance.rund_number>=10){
- if(GBoardChess.instance.heqi_number>0){
- this.btn_qiuhe.getComponent(Button).enabled = true;
- this.lab_qiuhe.getComponent(Label).color = this.color;
- this.spr_qiuhe.getComponent(Sprite).spriteFrame = this.sp_qiuhe_1
- }
- }
- }
- }
- }
- }
-
-
-
- }
- // recvQuit(){
- // GameMng._userData.room = null;
- // AudioMng.Instance.PlayBGM(GameMng.Instance.mainbgm);
- // ScenceMng.Instance.load('GameLaunch');
- // }
- update(deltaTime: number) {
-
- }
- onClickQuit(){
- this.node.active = false;
- }
- }
|