| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- var SelGame = window.clientName + '_C_G'
- const LobbyListInfoUtil = require('./utils/LobbyListInfoUtil');
- cc.Class({
- extends: cc.BaseClass,
- properties: {
- m_ldiamond: cc.Label,
- m_personT: [cc.Toggle],
- //开房间按钮
- createRoomBtn: {
- default: null,
- type: cc.Button,
- displayName: '创建房间按钮'
- },
- //加入房间按钮
- inputRoomBtn: {
- default: null,
- type: cc.Button,
- displayName: '输入房间号按钮'
- },
- },
- ctor: function () {
- this.m_RoomType = 0;// 0普通 1俱乐部
- this.m_personIndex = 1;
- this.m_playMethod = 0;
- //房间列表
- this.m_AllRoomList = [];
- // 两人房且是北部玩法房间列表
- this.twoPlayerAndNorthPlayRoomList = [];
- // 两人房且是南部玩法房间列表
- this.twoPlayerAndSouthPlayRoomList = [];
- // 四人房且是北部玩法房间列表
- this.fourPlayerAndNorthPlayRoomList = [];
- // 四人房且是南部玩法房间列表
- this.fourPlayerAndSouthPlayRoomList = [];
- },
- onLoad: function () {
- this._Sub = [];
- this._Sub.push(this.$('NewNode/Sub1'));
- // this._Sub.push(this.$('NewNode/Sub2'));
- // this._Sub.push(this.$('NewNode/Sub3'));
- this.updateDiamond()
- this.m_personIndex = cc.sys.localStorage.getItem("personIndex", 1);
- if (this.m_personIndex == null || this.m_personIndex == undefined) {
- this.m_personIndex = 1;
- }
- if (this.m_personT && this.m_personT.length > this.m_personIndex && this.m_personT[this.m_personIndex]) {
- this.m_personT[this.m_personIndex].isChecked = true;
- } else {
- // 如果索引无效,使用默认索引 0
- if (this.m_personT && this.m_personT.length > 0 && this.m_personT[0]) {
- this.m_personT[0].isChecked = true;
- this.m_personIndex = 0;
- }
- }
- this.initListCtrl();
- setTimeout(() => {
- //默认展示四人且是北部玩法房间列表
- this.showFourPlayerAndNorthPlayRoomList()
- }, 4000);
- },
- // 初始化列表控制器
- initListCtrl: function () {
- if (!this.m_ListCtrl) {
- this.m_ListCtrl = this.$('@CustomListCtrl');
- if (this.m_ListCtrl) {
- this.m_ListCtrl.InitList(0, 'roomListItem', this);
- }
- }
- },
- // 显示界面
- OnShowView: function () {
- if (this.m_FirstCtrl == null) {
- this.m_FirstCtrl = this.$('LeftBG/Layout/T0@Toggle');
- this.m_FirstCtrl.isChecked = false;
- this.m_FirstCtrl.check();
- }
- return
- },
- // 设置房间类型
- OnSetRoomType: function (type) {
- this.m_RoomType = type;
- this.FilterGame(type);
- },
- FilterGame: function (type) {
- // this.$('NewNode/Sub2/view/content/63500').active = type>0;
- },
- OnTogClick: function (tag, data) {
- // console.log('data:'+data);
- // for(let i =0;i<3;i++){
- // this._Sub[i].active = false;
- // }
- // this._Sub[data].active = true;
- },
- // 点击玩法
- onClickPlayMethod: function (data, tag) {
- this.initListCtrl();
- this.m_AllRoomList = window.currentLobbyList
- if (this.m_AllRoomList && this.m_AllRoomList.ListInfo && this.m_AllRoomList.ListInfo.length > 0) {
- this.twoPlayerAndNorthPlayRoomList = LobbyListInfoUtil.getTwoPlayerAndNorthPlayRoomList(this.m_AllRoomList.ListInfo);//两人北部玩法房间列表
- this.twoPlayerAndSouthPlayRoomList = LobbyListInfoUtil.getTwoPlayerAndSouthPlayRoomList(this.m_AllRoomList.ListInfo);//两人南部玩法房间列表
- this.fourPlayerAndNorthPlayRoomList = LobbyListInfoUtil.getFourPlayerAndNorthPlayRoomList(this.m_AllRoomList.ListInfo);//四人北部玩法房间列表
- this.fourPlayerAndSouthPlayRoomList = LobbyListInfoUtil.getFourPlayerAndSouthPlayRoomList(this.m_AllRoomList.ListInfo);//四人南部玩法房间列表
- }
- if (tag == 0) {//北部玩法
- if (this.m_personIndex == 0) {//四人且是北部玩法
- this.m_ListCtrl.RemoveListPre(0)
- this.showFourPlayerAndNorthPlayRoomList()
- } else {//两人且是北部玩法
- this.m_ListCtrl.RemoveListPre(0)
- this.showTwoPlayerAndNorthPlayRoomList()
- }
- } else {//南部玩法
- // this.m_ListCtrl.RemoveListPre(0)
- if (this.m_personIndex == 0) {//四人且是南部玩法
- this.m_ListCtrl.RemoveListPre(0)
- this.showFourPlayerAndSouthPlayRoomList()
- } else {//两人且是南部玩法
- this.m_ListCtrl.RemoveListPre(0)
- this.showTwoPlayerAndSouthPlayRoomList()
- }
- }
- console.log(tag == 0 ? "点击北部玩法" : "点击南部玩法")
- this.m_playMethod = tag;
- cc.sys.localStorage.setItem("playMethodIndex", this.m_playMethod)
- },
- // 点击玩家人数
- OnClickButtonPerson: function (data, tag) {
- // 确保列表控件已初始化
- this.initListCtrl();
- this.m_AllRoomList = window.currentLobbyList
- if (this.m_AllRoomList && this.m_AllRoomList.ListInfo && this.m_AllRoomList.ListInfo.length > 0) {
- this.twoPlayerAndNorthPlayRoomList = LobbyListInfoUtil.getTwoPlayerAndNorthPlayRoomList(this.m_AllRoomList.ListInfo);//两人北部玩法房间列表
- this.twoPlayerAndSouthPlayRoomList = LobbyListInfoUtil.getTwoPlayerAndSouthPlayRoomList(this.m_AllRoomList.ListInfo);//两人南部玩法房间列表
- this.fourPlayerAndNorthPlayRoomList = LobbyListInfoUtil.getFourPlayerAndNorthPlayRoomList(this.m_AllRoomList.ListInfo);//四人北部玩法房间列表
- this.fourPlayerAndSouthPlayRoomList = LobbyListInfoUtil.getFourPlayerAndSouthPlayRoomList(this.m_AllRoomList.ListInfo);//四人南部玩法房间列表
- }
- //0 ===>四人 1 ===>两人
- console.log(tag == 0 ? "点击四人房间" : "点击两人房间")
- if (tag == 0) {//四人房间
- // this.m_ListCtrl.RemoveListPre(0)
- if (this.m_playMethod == 0) {//四人且是北部玩法
- this.m_ListCtrl.RemoveListPre(0)
- this.showFourPlayerAndNorthPlayRoomList()
- } else {//四人且是南部玩法
- this.m_ListCtrl.RemoveListPre(0)
- this.showFourPlayerAndSouthPlayRoomList()
- }
- } else {//两人
- //展示两人房间列表之前,要先清空现有的所有列表
- this.m_ListCtrl.RemoveListPre(0)
- if (this.m_playMethod == 0) {//两人且是北部玩法
- this.showTwoPlayerAndNorthPlayRoomList()
- } else {//两人且是南部玩法
- this.showTwoPlayerAndSouthPlayRoomList()
- }
- }
- console.log("点击Person", tag)
- this.m_personIndex = tag;
- cc.sys.localStorage.setItem("personIndex", this.m_personIndex)
- },
- //展示两人且是北部玩法列表
- showTwoPlayerAndNorthPlayRoomList: function () {
- //展示北部玩法列表
- // this.m_ListCtrl.InitList(0, 'roomListItem', this);
- console.log("两人且是北部玩法房间列表", this.twoPlayerAndNorthPlayRoomList)
- for (var i = 0; i < this.twoPlayerAndNorthPlayRoomList.length; i++) {
- this.m_ListCtrl.InsertListInfo(0, this.twoPlayerAndNorthPlayRoomList[i]);
- }
- },
- //展示两人且是南部玩法列表
- showTwoPlayerAndSouthPlayRoomList: function () {
- //展示南部玩法列表
- // this.m_ListCtrl.InitList(0, 'roomListItem', this);
- for (var i = 0; i < this.twoPlayerAndSouthPlayRoomList.length; i++) {
- this.m_ListCtrl.InsertListInfo(0, this.twoPlayerAndSouthPlayRoomList[i]);
- }
- },
- //展示四人且是北部玩法列表
- showFourPlayerAndNorthPlayRoomList: function () {
- //展示北部玩法列表
- // this.m_ListCtrl.InitList(0, 'roomListItem', this);
- console.log("四人且是北部玩法房间列表", this.fourPlayerAndNorthPlayRoomList)
- for (var i = 0; i < this.fourPlayerAndNorthPlayRoomList.length; i++) {
- this.m_ListCtrl.InsertListInfo(0, this.fourPlayerAndNorthPlayRoomList[i]);
- }
- },
- //展示四人且是南部玩法列表
- showFourPlayerAndSouthPlayRoomList: function () {
- //展示南部玩法列表
- // this.m_ListCtrl.InitList(0, 'roomListItem', this);
- console.log("四人且是南部玩法房间列表", this.fourPlayerAndSouthPlayRoomList)
- for (var i = 0; i < this.fourPlayerAndSouthPlayRoomList.length; i++) {
- this.m_ListCtrl.InsertListInfo(0, this.fourPlayerAndSouthPlayRoomList[i]);
- }
- },
- // 进入比赛房间
- OnClickButtonMatch: function (data, tag) {
- console.log("点击data", tag)
- this.m_Hook.matchRoom(this.m_personIndex, tag, this.m_playMethod)
- // this.ShowPrefabDLG('CreateRoom2',null,(Js)=>{
- // Js.OnSetGameID(tag.currentTarget.name);
- // Js.OnClubAutoView(this.m_RoomType);
- // });
- },
- //创建房间
- OnCreateRoom: function (KindID, dwRules, dwServerRules, Name) {
- this.m_Hook.OnCreateRoom(KindID, dwRules, dwServerRules, Name, 0, 0);
- this.HideView();
- },
- //更新钻石
- updateDiamond: function () {
- let diamond = g_GlobalUserInfo.GetGlobalUserData().llUserIngot;
- this.m_ldiamond.string = diamond;
- },
- // 创建房间按钮点击事件
- OnBtCreateRoom: function () {
- cc.gSoundRes.PlaySound('Button');
- this.ShowPrefabDLG('SelectGame', this.m_DlgNode, function (Js) {
- Js.OnSetRoomType(0);
- }.bind(this));
- },
- OnBtJoinRoom: function () {
- cc.gSoundRes.PlaySound('Button');
- this.ShowPrefabDLG('JoinRoom', this.m_DlgNode);
- },
- // 查询房间方法
- OnQueryRoom: function (roomID, clubID) {
- console.log("查询房间:", roomID, clubID);
- g_Lobby.OnQueryRoom(roomID, clubID)
- }
- });
|