123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- import GameConstant from 'GameConstant'
- var Global = require("Global");
- var BaseDefine = require("BaseDefine");
- var UIHelper = require("UIHelper");
- cc.Class({
- extends: cc.Component,
- properties: {//局数 规则 人数 支付方式
- _mGameBtnNodeObj:null, //存放游戏选择按钮节点,当服务器都开启时,此结构体为空
- mGameListContent: cc.Node,
- _mPlayCoutIdex: null, //局数
- _mPlayPersonCoutIdex: null, //人数
- _mPlayRulesIdex: null, //规则
- _bPYQ:false,
- _pyqID:0,
- _userID:0,
- _buildType: 2, //正常,AA
- },
-
- onLoad :function() {
- UIHelper.addButtonListener(this.node.getChildByName("TopInfo").getChildByName("btn_createClose"), this.node, "createRoom", "onBtnCloseClicked");
- UIHelper.addButtonListener(this.node.getChildByName("TopInfo").getChildByName("playerFK"), cc.find("Canvas"), "homeStart", "onClickRoomCard","FK");
- this.node.active = false;
- this._mGameBtnNodeObj = {};
- },
- onBtnCloseClicked :function(){
- cc.vv.GetHallScript().playButtonEffect("close");
- this.node.active = false;
- cc.vv.GetHallScript().showAniBottomNode();
- },
- //创建房间入口
- showCreatRoom: function(bPYQ,pyqID,userID) {
- this.node.active = true;
- this._bPYQ = bPYQ;
- this._pyqID = pyqID;
- this._userID = userID;
-
- this.node.getChildByName("TopInfo").getChildByName("playerFK").getChildByName("fk").getComponent(cc.Label).string = cc.vv.globalUserInfo.getUserInsure();
- this.node.getChildByName("rootNode").getChildByName("DDZPanel").getComponent("RoomPanleDDZ").initRoom(bPYQ,pyqID,userID);
- this.node.getChildByName("rootNode").getChildByName("GJMJPanel").getComponent("RoomPanleGJMJ").initRoom(bPYQ,pyqID,userID);
- this.node.getChildByName("rootNode").getChildByName("LYCPanel").getComponent("RoomPanleLYC").initRoom(bPYQ,pyqID,userID);
- this.node.getChildByName("rootNode").getChildByName("XLCHPanel").getComponent("RoomPanleXLCH").initRoom(bPYQ,pyqID,userID);
- this.node.getChildByName("rootNode").getChildByName("XZDDPanel").getComponent("RoomPanleXZDD").initRoom(bPYQ,pyqID,userID);
- this.node.getChildByName("rootNode").getChildByName("PSPanel").getComponent("RoomPanlePS").initRoom(bPYQ,pyqID,userID);
- this.node.getChildByName("rootNode").getChildByName("JSMJPanel").getComponent("RoomPanleJSMJ").initRoom(bPYQ,pyqID,userID);
- this.node.getChildByName("rootNode").getChildByName("CTPKPanel").getComponent("RoomPanleCTPK").initRoom(bPYQ,pyqID,userID);
- this.node.getChildByName("rootNode").getChildByName("SPMJPanel").getComponent("RoomPanleSPMJ").initRoom(bPYQ,pyqID,userID);
- this.node.getChildByName("rootNode").getChildByName("SDYPKPanel").getComponent("RoomPanleSDYPK").initRoom(bPYQ,pyqID,userID);
- this.node.getChildByName("rootNode").getChildByName("QXZBPanel").getComponent("RoomPanleQXZB").initRoom(bPYQ,pyqID,userID);
- //根据服务器状态,显示创建房间显示状态
- this.setGameItemStateByServer();
- //选择游戏
- this.seleceGame(null, this.sureInitCurrentGame());
- var ani = this.node.getComponent(cc.Animation);
- if (ani) {
- ani.play();
- }
- //this.node.getChildByName("TopInfo").getComponent(cc.Animation).play();
- },
- //回收选择游戏按钮节点
- recycleGameBtnNode: function(gametype) {
- let content = this.node.getChildByName("rootNode").getChildByName("gameList").getChildByName("view").getChildByName("content");
- if (this._mGameBtnNodeObj[gametype]) return;
- var btn = content.getChildByName(gametype);
- if (btn) {
- this._mGameBtnNodeObj[gametype] = btn;
- btn.removeFromParent(false);
- }
- },
- //放出选择游戏按钮节点
- popGameBtnNode: function(gametype) {
- let gameBtnNode = this._mGameBtnNodeObj[gametype];
- if (gameBtnNode) {
- delete this._mGameBtnNodeObj[gametype];
- return gameBtnNode;
- }
- },
- //决定点开创建房间时显示哪个创建界面
- sureInitCurrentGame: function() {
- let currentGame = Global.getLocalStorageVaule("PrivateCurrentGame", "GJMJ");
- var gamekind = GameConstant.getGameKindIdByKey(currentGame);
- if (this.checkServering(gamekind)) {
- return currentGame;
- } else {
- for (let index = 0; index < GameConstant.Game_List.length; index++) {
- const element = GameConstant.Game_List[index];
- if (this.checkServering(element.KindId)) {
- currentGame = element.Key;
- }
- }
- }
- return currentGame;
- },
- //检查服务器开启状态
- checkServering: function(gamekind) {
- return cc.vv.serverListData.getGameServerByKind(gamekind, BaseDefine.GAME_GENRE_EDUCATE)
- },
- setGameItemStateByServerEX: function(key, gamekind) {
- var btnname = "Btn" + key;
- var panelname = key + "Panel";
- var panel = this.node.getChildByName("rootNode").getChildByName(panelname);
- if (panel) {
- var itemServer = this.checkServering(gamekind);
- if (itemServer) { //服务器开启
- panel.active = true;
- if (!this.mGameListContent.getChildByName(btnname)) {
- this.mGameListContent.addChild(this.popGameBtnNode(btnname), 0, btnname);
- }
- UIHelper.addButtonListener(this.mGameListContent.getChildByName(btnname), this.node, "createRoom", "seleceGame", key); //添加游戏选择按钮事件
- if (itemServer.GameKindItem.TypeID == 0) { //限时免费
- var playCntNode = panel.getChildByName("playCntNode").getChildByName("playCntGroup");
- for(var i = 0;i < playCntNode.children.length;i++){
- playCntNode.children[i].getChildByName("FK").active = false;
- playCntNode.children[i].getChildByName("freeFK").active = true;
- }
- panel.getChildByName("btn_freeCreate").active = true
- panel.getChildByName("btn_create").active = false
- }
- } else {
- panel.active = false;
- this.recycleGameBtnNode(btnname);
- }
- }
-
- },
- //根据服务器状态,显示创建房间显示状态
- setGameItemStateByServer: function() {
- GameConstant.Game_List.forEach(element => {
- this.setGameItemStateByServerEX(element.Key, element.KindId);
- });
- },
- //选择游戏
- seleceGame: function(event,optdata) {
- if (event) {
- cc.vv.GetHallScript().playButtonEffect("open");
- }
- this.setGameShow(optdata);
- if (event == null) {
- var content = this.node.getChildByName("rootNode").getChildByName("gameList").getChildByName("view").getChildByName("content");
- if (content.getChildByName("Btn" + optdata).getComponent(cc.Toggle).isChecked) {
- if(content.getChildByName("Btn" + optdata).y < 0 - this.node.getChildByName("rootNode").getChildByName("gameList").getChildByName("view").getContentSize().height)
- {
- this.node.getChildByName("rootNode").getChildByName("gameList").getComponent(cc.ScrollView).scrollToBottom(0.1);
- }
- }
- }
- },
- //设置游戏显示隐藏
- setGameShow: function(currentgame) {
- var content = this.node.getChildByName("rootNode").getChildByName("gameList").getChildByName("view").getChildByName("content");
- GameConstant.Game_List.forEach(element => {//element.Key
- var gameName = element.Key;
- var panel = this.node.getChildByName("rootNode").getChildByName(gameName + "Panel");
- if (panel) {
- if (currentgame == gameName) {
- panel.active = true;
- panel.getComponent("RoomPanle"+gameName).initRoom(this._bPYQ,this._pyqID,this._userID);
- if (content.getChildByName("Btn" + gameName)) {
- content.getChildByName("Btn" + gameName).getComponent(cc.Toggle).check();
- }
- } else {
- panel.active = false;
- }
- }
- });
- },
- });
|