CreateRoom.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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.m_ClubView = new Array();
  17. this.m_ClubView.push('K0/3');
  18. },
  19. OnShowView:function(){
  20. if(this.m_FirstCtrl == null){
  21. this.OnHideAllChild();
  22. this.m_FirstCtrl = this.$('K1@Toggle',this.m_groupNode);
  23. this.m_FirstCtrl.isChecked = false;
  24. this.m_FirstCtrl.check();
  25. }
  26. return
  27. },
  28. OnHideAllChild:function(){
  29. this.m_TagKindChild = null;
  30. for(var i=0; i<this.m_groupNode.childrenCount; i++){
  31. for(var j=1; j<this.m_groupNode.children[i].childrenCount; j++ ){
  32. this.m_groupNode.children[i].children[j].active = false;
  33. }
  34. }
  35. },
  36. OnClick_HideKindChild:function(Tag){
  37. var NdList = Tag.currentTarget.parent.parent;// mark .. Background .. k?
  38. if(NdList == null || NdList.children[1] == null) return
  39. var bShow = !NdList.children[1].active;
  40. for(var i=1; i<NdList.childrenCount; i++){
  41. NdList.children[i].active = bShow;
  42. }
  43. },
  44. OnClick_ShowKindChild:function(Tag){
  45. this.OnHideAllChild();
  46. var FirstCtrl = null;
  47. this.m_TagKindChild = Tag;
  48. this.m_KindChildIndex = 1;
  49. this.m_nNeedUpdate = 1;
  50. for(var i=1; i<Tag.node.childrenCount; i++){
  51. var TogCtrl = this.$('@Toggle',Tag.node.children[i]);
  52. if(FirstCtrl == null ) FirstCtrl = TogCtrl;
  53. if(TogCtrl) TogCtrl.node.active = false;
  54. }
  55. if(this.m_RoomType == 0){
  56. for(var i in this.m_ClubView){
  57. this.$(this.m_ClubView[i], this.m_groupNode).active = false;
  58. }
  59. }
  60. // if(FirstCtrl){
  61. // FirstCtrl.isChecked = false;
  62. // FirstCtrl.check();
  63. // }
  64. },
  65. update: function(){
  66. if(this.m_nNeedUpdate > 0) {
  67. this.m_nNeedUpdate --;
  68. } else {
  69. return;
  70. }
  71. if(this.m_TagKindChild && this.m_KindChildIndex < this.m_TagKindChild.node.childrenCount) {
  72. var TogCtrl = this.$('@Toggle', this.m_TagKindChild.node.children[this.m_KindChildIndex]);
  73. if (TogCtrl) {
  74. TogCtrl.node.active = true;
  75. if (this.m_KindChildIndex == 1) {
  76. TogCtrl.isChecked = false;
  77. TogCtrl.check();
  78. }
  79. }
  80. this.m_KindChildIndex ++;
  81. this.m_nNeedUpdate = 1;
  82. }
  83. },
  84. OnClubAutoView:function(RoomType){
  85. this.m_RoomType = RoomType;
  86. //this.$('4',this.m_groupNode).active = this.m_RoomType == 1;
  87. this.m_FirstCtrl.isChecked = false;
  88. this.m_FirstCtrl.check();
  89. },
  90. OnToggleSelGame:function(Tag, Data){
  91. if(Tag.node.name.indexOf('K') >=0 ) this.OnHideAllChild();
  92. this.m_RoomInfo = Data.split('_');
  93. //console.log('OnToggleSelGame ', Data,this.m_RoomInfo[0]);
  94. this.OnShowSubGameView(this.m_RoomInfo[0], this.m_RoomInfo[1]);
  95. },
  96. OnShowSubGameView:function(KindID, ViewIndex){
  97. try {
  98. var gamedef = new window['CMD_GAME_'+KindID]();
  99. } catch (error) {
  100. for(var i in this.m_GameViewArr){
  101. this.m_GameViewArr[i].node.active = false;
  102. }
  103. this.$('NdGame').active = false;
  104. this.$('NotFind').active = true;
  105. return;
  106. }
  107. this.$('NdGame').active = true;
  108. this.$('NotFind').active = false;
  109. //刷新当前界面
  110. for(var i in this.m_GameViewArr){
  111. this.m_GameViewArr[i].node.active = false;
  112. }
  113. this.m_BtCreate.interactable = false;
  114. this.m_LabLoadTip.node.active = true;
  115. this.ShowGamePrefab('SubRoom',KindID,this.node,function(Js){//1020*500
  116. this.m_GameViewArr[KindID] = Js;
  117. this.m_GameViewArr[KindID].InitView(KindID, ViewIndex, this.m_RoomType);
  118. //刷新当前界面
  119. for(var i in this.m_GameViewArr){
  120. this.m_GameViewArr[i].node.active = (i == this.m_RoomInfo[0]);
  121. }
  122. this.m_BtCreate.interactable = true;
  123. this.m_LabLoadTip.node.active = false;
  124. }.bind(this));
  125. },
  126. OnBtCreate:function(){
  127. cc.gSoundRes.PlaySound('Button');
  128. if(this.m_RoomInfo == null || window.GameList[this.m_RoomInfo[0]] == null){
  129. this.ShowTips("遊戲暫未開放!")
  130. return
  131. }
  132. var KindID = this.m_RoomInfo[0];
  133. this.m_GameViewArr[KindID]
  134. var dwRules = this.m_GameViewArr[KindID].getRulesEx(1);
  135. var dwServerRules = this.m_GameViewArr[KindID].getServerRules();
  136. if(this.m_RoomType) dwServerRules = dwServerRules|4; //俱乐部模式金币场
  137. var Name = '快來玩呀';
  138. if(this.m_EdRoomName) Name = this.m_EdRoomName.string;
  139. if(this.m_Hook) this.m_Hook.OnCreateRoom(KindID, dwRules, dwServerRules, Name, 0, 0);
  140. this.HideView();
  141. },
  142. });