123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- import { _decorator, Component, Node, Sprite, Color, Label, NodeEventType, tween, color, Vec3, SpriteFrame } from 'cc';
- import { ClientEvent } from '../clientEvent';
- import { Constant, room_type } from '../constant';
- import { GameMng } from '../GameMng';
- import GBaseUI from '../gcommon/GBaseUI';
- import ScenceMng from '../gcommon/ScenceMng';
- import { UIButton } from '../gcommon/UIButton';
- import { UIManager } from '../gcommon/UIManager';
- import { msgManager } from '../socket/msgManager';
- import { roomData } from '../UserData/roomData';
- import ChessRBSel from './ChessGame/ChessRBSel';
- import ChessMng, { ChessType } from './DiffSel/ChessMng';
- import UIDiffSel from './DiffSel/UIDiffSel';
- const { ccclass, property } = _decorator;
- var JU_SHI = [ "10分钟", "45分钟", "30分钟", "20分钟", "15分钟", "5分钟", "3分钟", "2分钟"];//局时
- var JU_SHI_NUM = [ 600, 2700, 1800,1200, 900, 300, 180, 120];//局时
- var BU_SHI = [ "1分钟", "5分钟", "3分钟", "2分钟", "30秒"];//步时
- var BU_SHI_NUM = [ 60, 300, 180, 120, 30];//步时
- var MEI_BU_JIA_SHI = [ "10秒", "20秒", "5秒", "3秒"];//每步加时
- var MEI_BU_JIA_SHI_NUM = [ 10, 20, 5, 3];//每步加时
- var WO_FANG = [ "执黑", "执红"];//我方棋局先后手
- var DU_MIAO = [ "0秒", "60秒","30秒"];//读秒
- var DU_MIAO_NUM = [ 0, 60,30];//读秒
- @ccclass('createFirendRoom')
- export class createFirendRoom extends GBaseUI {
- @property(Node)
- btnClose: Node = null;
- @property(SpriteFrame) sp_jing_dian:SpriteFrame =null
- @property(SpriteFrame) sp_jing_dian_0:SpriteFrame =null
- @property(SpriteFrame) sp_mei_bu:SpriteFrame =null
- @property(SpriteFrame) sp_mei_bu_0:SpriteFrame =null
- @property(Node)
- btnJingdian: Node = null; //经典
- @property(Node)
- btnMeibujiashi: Node = null; //每步加时
- //局时
- @property(Node)
- labJushi: Node = null; //局时间
- @property(Node)
- btn_Jushi_select: Node = null; //局时间选择
- //步时
- @property(Node)
- labBushi: Node = null; //步时间
- @property(Node)
- btn_Bushi_select: Node = null; //步时间选择
- //读秒
- @property(Node)
- labDumiao: Node = null; //读秒
- @property(Node)
- btn_Dumiao_select: Node = null; //读秒选择
- @property(Node)
- nodeDumiao: Node = null; //读秒节点
- //我方(红白方选择)
- @property(Node)
- labWofang: Node = null; //我方(红白方选择)
- @property(Node)
- btn_Wofang_select: Node = null; //我方(红白方选择)
- //每步加时
- @property(Node)
- labMeibujiashi: Node = null; //每步加时
- @property(Node)
- btn_Meibujiashi_select: Node = null; //每步加时选择
- @property(Node)
- nodeMeibujiashi: Node = null; //每步加时节点
- //显示选择页面
- @property(Node)
- select_node: Node = null; //显示选择页面
- //局时选择页面
- @property(Node)
- select_jushi_node: Node = null; //局时选择页面
- //步时选择页面
- @property(Node)
- select_bushi_node: Node = null; //步时选择页面
- //读秒选择页面
- @property(Node)
- select_dumiao_node: Node = null; //读秒选择页面
- //我方选择页面
- @property(Node)
- select_wofang_node: Node = null; //我方选择页面
- //每步加时选择页面
- @property(Node)
- select_meibujiashi_node: Node = null; //每步加时选择页面
- //局时选择页面容器
- @property(Node)
- select_jushi_content: Node = null; //局时选择页面容器
- //步时选择页面容器
- @property(Node)
- select_bushi_content: Node = null; //步时选择页面容器
- //读秒选择页面容器
- @property(Node)
- select_dumiao_content: Node = null; //读秒选择页面容器
- //我方选择页面容器
- @property(Node)
- select_wofang_content: Node = null; //我方选择页面容器
- //每步加时选择页面容器
- @property(Node)
- select_meibujiashi_content: Node = null; //每步加时选择页面容器
- //取消
- @property(Node)
- btn_cancel: Node = null; //
- //创建
- @property(Node)
- btn_create: Node = null; //创建
- curSelectMode:room_type=room_type._jing_dian_hao_you;
- curSelectJushiIndex:number=7; //默认选择下标7的局时
- curSelectBushiIndex:number=4; //默认选择下标4的步时
- curSelectDumiaoIndex:number=0; //默认选择下标0的读秒
- curSelectWofangIndex:number=0; //默认选择下标0的先后手
- curSelectMeibujiashiIndex:number=0; //默认选择下标0的每步加时
- isInitJuShiContent:boolean = false;
- isInitBuShiContent:boolean = false;
- isInitDuMiaoContent:boolean = false;
- isInitWoFangContent:boolean = false;
- isInitMeiBuJiaShiContent:boolean = false;
- color:Color = new Color()
- room:roomData = new roomData();
- static Show(parent?:any){
- UIManager.AddPrefab(GameMng.Instance.createFirend,parent);
- }
- start() {
- this.initBtns();
- this.selectModeChange();
- this.initView();
- }
- onDestroy(){
- }
- selectModeChange(){
- if(this.curSelectMode===room_type._jing_dian_hao_you){
- this.btnJingdian.getComponent(Sprite).spriteFrame = this.sp_jing_dian;
- this.btnMeibujiashi.getComponent(Sprite).spriteFrame = this.sp_mei_bu_0;
- this.nodeMeibujiashi.active = false;
- this.nodeDumiao.active = true;
- }else{
- this.btnJingdian.getComponent(Sprite).spriteFrame = this.sp_jing_dian_0;
- this.btnMeibujiashi.getComponent(Sprite).spriteFrame = this.sp_mei_bu;
- this.nodeMeibujiashi.active = true;
- this.nodeDumiao.active = false;
- }
- }
- initView(){
- this.labJushi.getComponent(Label).string = JU_SHI[this.curSelectJushiIndex];
- this.labBushi.getComponent(Label).string = BU_SHI[this.curSelectBushiIndex];
- this.labMeibujiashi.getComponent(Label).string = MEI_BU_JIA_SHI[this.curSelectMeibujiashiIndex];
- this.labWofang.getComponent(Label).string = WO_FANG[this.curSelectWofangIndex];
- this.labDumiao.getComponent(Label).string = DU_MIAO[this.curSelectDumiaoIndex];
- }
- onCreate(){
- // this.room.butime = BU_SHI_NUM[this.curSelectBushiIndex]
- // this.room.jutime = JU_SHI_NUM[this.curSelectJushiIndex]
- // this.room.meibujiashi = MEI_BU_JIA_SHI_NUM[this.curSelectMeibujiashiIndex]
- // this.room.zhenying = this.curSelectWofangIndex
- //this.room.countdown = DU_MIAO_NUM[this.curSelectDumiaoIndex]
- }
- initBtns(){
- UIButton.BindClick(this.btnClose,()=>{
- this.closeUI();
- },this);
- UIButton.BindClick(this.btnJingdian,()=>{
- if(this.curSelectMode==room_type._jing_dian_hao_you){
- }else{
- this.curSelectMode = room_type._jing_dian_hao_you;
- this.selectModeChange();
- }
- },this);
- UIButton.BindClick(this.btnMeibujiashi,()=>{
- if(this.curSelectMode==room_type._mei_miao_die_jia_hao_you){
- }else{
- this.curSelectMode = room_type._mei_miao_die_jia_hao_you;
- this.selectModeChange();
- }
- },this);
- UIButton.BindClick(this.btn_Jushi_select,()=>{
- this.showJuShiSelectView();
- },this);
- UIButton.BindClick(this.btn_Bushi_select,()=>{
- this.showBuShiSelectView();
- },this);
- UIButton.BindClick(this.btn_Dumiao_select,()=>{
- this.showDumiaoSelectView();
- },this);
- UIButton.BindClick(this.btn_Wofang_select,()=>{
- this.showWofangSelectView();
- },this);
- UIButton.BindClick(this.btn_Meibujiashi_select,()=>{
- this.showMeibujiashiSelectView();
- },this);
- UIButton.BindClick(this.btn_cancel,()=>{
- this.closeUI();
- },this);
- UIButton.BindClick(this.btn_create,()=>{
- msgManager.createRoom(JU_SHI_NUM[this.curSelectJushiIndex],BU_SHI_NUM[this.curSelectBushiIndex],this.curSelectWofangIndex,this.curSelectMode,DU_MIAO_NUM[this.curSelectDumiaoIndex],MEI_BU_JIA_SHI_NUM[this.curSelectMeibujiashiIndex])
- },this);
- }
- hideAllSelectView(){
- this.select_jushi_node.active = false;
- this.select_bushi_node.active = false;
- this.select_meibujiashi_node.active = false;
- this.select_wofang_node.active = false;
- this.select_dumiao_node.active = false;
- }
- showJuShiSelectView(){
- this.select_node.active = true;
- this.hideAllSelectView()
- this.showSelectContenAni(this.select_jushi_node);
- if(!this.isInitJuShiContent){
- let self = this;
- for (let index = 0; index < this.select_jushi_content.children.length; index++) {
- const jushi_item = this.select_jushi_content.children[index] as Node;
- let lab = jushi_item.getChildByName("Label")
- if(JU_SHI[index]){
- lab.getComponent(Label).string = JU_SHI[index];
- }
- jushi_item.on(NodeEventType.TOUCH_END,function(){
- console.log("选中",JU_SHI[index])
- self.curSelectJushiIndex = index;
- self.initView()
- self.onQuitSelectView()
- })
- }
- this.isInitJuShiContent = true;
- }
-
- }
- showBuShiSelectView(){
- this.select_node.active = true;
- this.hideAllSelectView()
- this.showSelectContenAni(this.select_bushi_node);
- if(!this.isInitBuShiContent){
- let self = this;
- for (let index = 0; index < this.select_bushi_content.children.length; index++) {
- const bushi_item = this.select_bushi_content.children[index] as Node;
- let lab = bushi_item.getChildByName("Label")
- if(BU_SHI[index]){
- lab.getComponent(Label).string = BU_SHI[index];
- }
- bushi_item.on(NodeEventType.TOUCH_END,function(){
- console.log("选中",BU_SHI[index])
- self.curSelectBushiIndex = index;
- self.initView()
- self.onQuitSelectView()
- })
- }
- this.isInitBuShiContent = true;
- }
- }
- showMeibujiashiSelectView(){
- this.select_node.active = true;
- this.hideAllSelectView()
- this.showSelectContenAni(this.select_meibujiashi_node);
- if(!this.isInitMeiBuJiaShiContent){
- let self = this;
- for (let index = 0; index < this.select_meibujiashi_content.children.length; index++) {
- const meibujiashi_item = this.select_meibujiashi_content.children[index] as Node;
- let lab = meibujiashi_item.getChildByName("Label")
- if(MEI_BU_JIA_SHI[index]){
- lab.getComponent(Label).string = MEI_BU_JIA_SHI[index];
- }
- meibujiashi_item.on(NodeEventType.TOUCH_END,function(){
- console.log("选中",MEI_BU_JIA_SHI[index])
- self.curSelectMeibujiashiIndex = index;
- self.initView()
- self.onQuitSelectView()
- })
- }
- this.isInitMeiBuJiaShiContent = true;
- }
- }
- showWofangSelectView(){
- this.select_node.active = true;
- this.hideAllSelectView()
- this.showSelectContenAni(this.select_wofang_node);
- if(!this.isInitWoFangContent){
- let self = this;
- for (let index = 0; index < this.select_wofang_content.children.length; index++) {
- const wofang_item = this.select_wofang_content.children[index] as Node;
- let lab = wofang_item.getChildByName("Label")
- if(WO_FANG[index]){
- lab.getComponent(Label).string = WO_FANG[index];
- }
- wofang_item.on(NodeEventType.TOUCH_END,function(){
- console.log("选中",WO_FANG[index])
- self.curSelectWofangIndex = index;
- self.initView()
- self.onQuitSelectView()
- })
- }
- this.isInitWoFangContent = true;
- }
- }
- showDumiaoSelectView(){
- this.select_node.active = true;
- this.hideAllSelectView();
- this.showSelectContenAni(this.select_dumiao_node);
- if(!this.isInitDuMiaoContent){
- let self = this;
- for (let index = 0; index < this.select_dumiao_content.children.length; index++) {
- const dumiao_item = this.select_dumiao_content.children[index] as Node;
- let lab = dumiao_item.getChildByName("Label")
- if(DU_MIAO[index]){
- lab.getComponent(Label).string = DU_MIAO[index];
- }
- dumiao_item.on(NodeEventType.TOUCH_END,function(){
- console.log("选中",DU_MIAO[index])
- self.curSelectDumiaoIndex = index;
- self.initView()
- self.onQuitSelectView()
- })
- }
- this.isInitDuMiaoContent = true;
- }
- }
- showSelectContenAni(node:Node){
- node.scale = new Vec3(1,0.5,1);
- node.active = true;
- tween(node).to(0.1,{scale:new Vec3(1,1,1)}).start()
- }
- onQuitSelectView(){
- this.select_node.active = false;
- }
- update(deltaTime: number) {
-
- }
- }
|