CreateRoom2.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. var SelGame = window.clientName + '_C_G'
  2. cc.Class({
  3. extends: cc.BaseClass,
  4. properties: {
  5. m_groupNode: cc.Node,
  6. m_rulesNode: cc.Node,
  7. m_BtCreate: cc.Node,
  8. m_LabLoadTip: cc.Label,
  9. },
  10. ctor: function () {
  11. this.m_GameViewArr = new Array();
  12. this.m_RoomType = 0;// 0普通 1俱乐部
  13. this.m_nNeedUpdate = 0;
  14. this.m_RoomInfo = null;
  15. this.m_FirstCtrl = null;
  16. this._GameListInfo = {};
  17. // this._GameListInfo['21201'] = [['北部麻将','21201'],['南部麻将','21201_1']];
  18. this._GameListInfo['10011'] = [['明牌搶莊', '10011_0'], ['輪莊模式', '10011_1'], ['自由搶莊', '10011_2']];
  19. this._GameListInfo['10012'] = [['明牌搶莊', '10012_0'], ['輪莊模式', '10012_1'], ['自由搶莊', '10012_2'], ['固定莊家', '10012_3'], ['無花搶莊', '10012_4'], ['明牌通比', '10012_5'], ['通比模式', '10012_6']];
  20. this._GameListInfo['10013'] = [['明牌搶莊', '10013_0'], ['輪莊模式', '10013_1'], ['自由搶莊', '10013_2'], ['大吃小', '10013_3'], ['明牌大吃小', '10013_4']];
  21. this._GameListInfo['21060'] = [['經典玩法', '21060'], ['悶胡血流', '21061'], ['兩丁一房', '21062_2'], ['兩丁兩房', '21062_3'], ['三丁兩房', '21062_4']];
  22. },
  23. onLoad: function () {
  24. },
  25. start: function () {
  26. this.getRoomCread();
  27. },
  28. getRoomCread() {
  29. let RoomCard = this.$('NdGame/Diamond/@RichText');
  30. var pGlobalUserData = g_GlobalUserInfo.GetGlobalUserData();
  31. RoomCard.string = "<color=#876741>擁有鑽石:</c><color=#876741>" + pGlobalUserData.llUserIngot + "</color>"
  32. },
  33. OnShowView: function () {
  34. // if(this.m_FirstCtrl == null){
  35. // this.m_FirstCtrl = this.$('K1@Toggle',this.m_groupNode)s;
  36. // this.m_FirstCtrl.isChecked = false;
  37. // this.m_FirstCtrl.check();
  38. // }
  39. if (this._ListCtrl == null) {
  40. this._ListCtrl = this.$('@CustomListCtrl');
  41. this._ListCtrl.InitList(0, 'GamePlayItem', this);
  42. }
  43. return
  44. },
  45. OnSetGameID: function (KindID) {
  46. this._ListCtrl.InitList(0, 'GamePlayItem', this);
  47. this.$('BGB').active = !(this._GameListInfo[KindID] == null);
  48. // this.$('NdGame').x = (this._GameListInfo[KindID] == null)?-95:0;
  49. if (this._GameListInfo[KindID]) {
  50. for (var i = 0; i < this._GameListInfo[KindID].length; i++) {
  51. this._ListCtrl.InsertListInfo(0, [i, this._GameListInfo[KindID][i]]);
  52. }
  53. } else {
  54. this.OnToggleSelGame(null, KindID.toString());
  55. }
  56. },
  57. update: function () {
  58. if (this.m_nNeedUpdate > 0) {
  59. this.m_nNeedUpdate--;
  60. } else {
  61. return;
  62. }
  63. if (this.m_TagKindChild && this.m_KindChildIndex < this.m_TagKindChild.node.childrenCount) {
  64. var TogCtrl = this.$('@Toggle', this.m_TagKindChild.node.children[this.m_KindChildIndex]);
  65. if (TogCtrl) {
  66. TogCtrl.node.active = true;
  67. if (this.m_KindChildIndex == 1) {
  68. TogCtrl.isChecked = false;
  69. TogCtrl.check();
  70. }
  71. }
  72. this.m_KindChildIndex++;
  73. this.m_nNeedUpdate = 1;
  74. }
  75. },
  76. OnClubAutoView: function (RoomType) {
  77. this.m_RoomType = RoomType;
  78. //this.$('4',this.m_groupNode).active = this.m_RoomType == 1;
  79. // this.m_FirstCtrl.isChecked = false;
  80. // this.m_FirstCtrl.check();
  81. },
  82. OnToggleSelGame: function (Tag, Data) {
  83. // if(Tag.node.name.indexOf('K') >=0 ) this.OnHideAllChild();
  84. this.m_RoomInfo = Data.split('_');
  85. //console.log('OnToggleSelGame ', Data,this.m_RoomInfo[0]);
  86. this.OnShowSubGameView(this.m_RoomInfo[0], this.m_RoomInfo[1]);
  87. },
  88. OnShowSubGameView: function (KindID, ViewIndex) {
  89. try {
  90. var gamedef = new window['CMD_GAME_' + KindID]();
  91. } catch (error) {
  92. for (var i in this.m_GameViewArr) {
  93. this.m_GameViewArr[i].node.active = false;
  94. }
  95. this.$('NdGame').active = false;
  96. this.$('NotFind').active = true;
  97. return;
  98. }
  99. this.$('NdGame').active = true;
  100. this.$('NotFind').active = false;
  101. //刷新当前界面
  102. for (var i in this.m_GameViewArr) {
  103. this.m_GameViewArr[i].node.active = false;
  104. }
  105. this.m_BtCreate.interactable = false;
  106. this.m_LabLoadTip.node.active = true;
  107. console.log("ShowGamePrefab---SubRoom--", KindID)
  108. // if (KindID == "10017") {
  109. // // this.m_GameViewArr[KindID] = null;
  110. // // this.m_GameViewArr[KindID].InitView(KindID, ViewIndex, this.m_RoomType);
  111. // //刷新当前界面
  112. // for (var i in this.m_GameViewArr) {
  113. // this.m_GameViewArr[i].node.active = (i == this.m_RoomInfo[0]);
  114. // }
  115. // this.m_BtCreate.interactable = true;
  116. // this.m_LabLoadTip.node.active = false;
  117. // return;
  118. // }
  119. this.ShowGamePrefab('SubRoom', KindID, this.node, function (Js) {//1020*500
  120. console.log("ShowGamePrefab---SubRoom--2", KindID)
  121. this.m_GameViewArr[KindID] = Js;
  122. this.m_GameViewArr[KindID].InitView(KindID, ViewIndex, this.m_RoomType);
  123. //刷新当前界面
  124. for (var i in this.m_GameViewArr) {
  125. this.m_GameViewArr[i].node.active = (i == this.m_RoomInfo[0]);
  126. }
  127. this.m_BtCreate.interactable = true;
  128. this.m_LabLoadTip.node.active = false;
  129. // if(this.$('BGB').active == false) Js.node.x = -140; else Js.node.x = 120;
  130. }.bind(this));
  131. },
  132. OnBtCreate: function () {
  133. cc.gSoundRes.PlaySound('Button');
  134. if (this.m_RoomInfo == null || window.GameList[this.m_RoomInfo[0]] == null) {
  135. this.ShowTips("遊戲暫未開放!")
  136. return
  137. }
  138. // if (this.m_RoomInfo[0] == "10017") {
  139. // if (this.m_Hook) this.m_Hook.OnCreateRoom(this.m_RoomInfo[0], 0, 0, '快來玩呀', 0, 0);
  140. // this.HideView();
  141. // return;
  142. // }
  143. var KindID = this.m_RoomInfo[0];
  144. this.m_GameViewArr[KindID].resetCheck();
  145. var dwRules = this.m_GameViewArr[KindID].getRulesEx(1);
  146. var dwServerRules = this.m_GameViewArr[KindID].getServerRules();
  147. if (this.m_RoomType) dwServerRules = dwServerRules | 4; //俱乐部模式金币场
  148. var Name = '快來玩呀';
  149. if (this.m_EdRoomName) Name = this.m_EdRoomName.string;
  150. if (this.m_Hook) this.m_Hook.OnCreateRoom(KindID, dwRules, dwServerRules, Name, 0, 0);
  151. this.HideView();
  152. },
  153. });