SubRoom_21201.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. cc.Class({
  2. //extends: cc.BaseClass,
  3. extends: cc.SubRoomRules,
  4. properties: {
  5. m_baseNode: cc.Node,
  6. },
  7. //1000-1031 服务器规则 1050-1099 对应规则
  8. //1000 =>AA付 1050 =>房主付
  9. //1001 =>代开 1051 =>房主进入
  10. //1002 =>积分房间 1003 =>金币房间 1052 =>练习房间
  11. ctor: function () {
  12. this.m_bNeedUpdate = false;
  13. this.m_bFirstShow = true;
  14. },
  15. //添加对立规则数组索引
  16. CheckToggle(ArrIndex, JS) {
  17. },
  18. OnShowView: function () {
  19. this.m_bNeedUpdate = true;
  20. },
  21. OnHideView: function () {
  22. this.getRulesEx();
  23. this.getServerRules();
  24. this.node.active = false;
  25. },
  26. SetClubView: function (RoomType) {
  27. //this.$('ClubNode').active = RoomType == 1;
  28. if (this.m_ClubNode != null) this.m_ClubNode.active = (RoomType != 0);
  29. this.m_bNeedUpdate = true;
  30. },
  31. SetKeyView: function (key) {
  32. if (this.m_baseNode) {
  33. this.baseIndexArr = {};
  34. this.baseNodeArr = {};
  35. for (let cNode of this.m_baseNode.children) {
  36. let curName = cNode.name;
  37. if (curName[0] == "1") {
  38. this.baseIndexArr[curName[1]] = 0;
  39. this.baseNodeArr[curName[1]] = cNode;
  40. cNode.getComponent(cc.Toggle).isChecked = true;
  41. }
  42. }
  43. this.updateBaseView();
  44. }
  45. },
  46. OnToggleClick: function (Tag, Data) {
  47. this.m_bNeedUpdate = true;
  48. },
  49. OnUpdateCustomView:function()
  50. {
  51. this.GetPayWay();
  52. this.OnChecTWMJ();
  53. for (var i in this.m_togArr) {
  54. if (!this.m_togArr[i].node.active) continue;
  55. var color = this.m_togArr[i].isChecked ? cc.color(208,185,239) : cc.color(129,95,57);
  56. this.m_togArr[i].node.getChildByName('Label').color = color;
  57. }
  58. },
  59. UpdateBaseScore: function () {
  60. if (this.m_LabBaseScore != null) this.m_LabBaseScore.string = this.m_SitScore;
  61. },
  62. //台湾麻将
  63. OnChecTWMJ: function () {
  64. var RuleBB,RuleNB;
  65. var RuleBB1,RuleNB1;
  66. for (var i in this.m_togArr) {
  67. if (this.m_togArr[i].node.name == 26) RuleBB = i; //台湾北部麻将玩法
  68. if (this.m_togArr[i].node.name == 27) RuleNB = i; //台湾南部麻将玩法
  69. if (this.m_togArr[i].node.name == 28) RuleBB1 = i; //台湾北部呖咕呖咕 玩法
  70. // if (this.m_togArr[i].node.name == 9) RuleNB1 = i; //台湾南部庄家无台 玩法
  71. }
  72. let isShowNorth = this.m_togArr[RuleBB].isChecked;
  73. this.m_togArr[RuleBB1].node.parent.active = isShowNorth;
  74. },
  75. GetPayWay: function () {
  76. var payWayPath = "PayWay/1050@Toggle";
  77. var gameCountPath = "GameCount/";
  78. var labels = [
  79. { node: '1019/Label@Label', text: ['1圈X4', '1圈X6', '1圈X8'] },
  80. { node: '1020/Label@Label', text: ['2圈X6', '2圈X9', '2圈X12'] },
  81. { node: '1021/Label@Label', text: ['4圈X8', '4圈X12', '4圈X16'] }
  82. ];
  83. var alternativeLabels = ['1圈x2', '2圈x3', '4圈x4'];
  84. var renshuIndices = { 1018: null, 1017: null, 1016: null };
  85. var Path = "ScrollView/view/content/";
  86. for (var i in this.m_togArr) {
  87. var nodeName = this.m_togArr[i].node.name;
  88. if (renshuIndices.hasOwnProperty(nodeName)) {
  89. renshuIndices[nodeName] = i;
  90. }
  91. }
  92. var setLabels = function (labelArray, checkedIndex) {
  93. for (var j in labelArray) {
  94. this.$(Path + gameCountPath + labelArray[j].node).string = labelArray[j].text[checkedIndex];
  95. }
  96. }.bind(this);
  97. if (this.$(Path + payWayPath).isChecked) {
  98. if (renshuIndices[1018] !== null && this.m_togArr[renshuIndices[1018]].isChecked) {
  99. setLabels(labels, 0);
  100. } else if (renshuIndices[1017] !== null && this.m_togArr[renshuIndices[1017]].isChecked) {
  101. setLabels(labels, 1);
  102. } else if (renshuIndices[1016] !== null && this.m_togArr[renshuIndices[1016]].isChecked) {
  103. setLabels(labels, 2);
  104. }
  105. }
  106. var alternativePayWayPath = "PayWay/1000@Toggle";
  107. if (this.$(Path + alternativePayWayPath).isChecked) {
  108. for (var k in alternativeLabels) {
  109. this.$(Path + gameCountPath + labels[k].node).string = alternativeLabels[k];
  110. }
  111. }
  112. },
  113. updateBaseView() {
  114. for (let idx in this.baseNodeArr) {
  115. let baseNode = this.baseNodeArr[idx];
  116. let showIndex = this.baseIndexArr[idx];
  117. let config = window.RoomBaseInfo[idx];
  118. baseNode.name = `1${idx}00${showIndex}`
  119. baseNode.getChildByName("Label").getComponent(cc.Label).string = "" + config[showIndex];
  120. baseNode.getChildByName("last").active = showIndex > 0;
  121. baseNode.getChildByName("next").active = showIndex < config.length - 1;
  122. }
  123. },
  124. //key 0-0/1 typeIndex- -/+
  125. onclickNextOrLastBase(event, key) {
  126. let keyArr = key.split("-");
  127. let idx = Number(keyArr[0]);
  128. let config = window.RoomBaseInfo[idx];
  129. let showIndex = this.baseIndexArr[idx];
  130. if ("0" == keyArr[1]) {
  131. showIndex -= 1;
  132. } else if ("1" == keyArr[1]) {
  133. showIndex += 1;
  134. } else {
  135. return;
  136. }
  137. if (showIndex < 0 || showIndex > config.length - 1) {
  138. return;
  139. }
  140. this.baseIndexArr[idx] = showIndex;
  141. this.updateBaseView();
  142. },
  143. resetCheck() {
  144. for (let idx in this.baseNodeArr) {
  145. this.baseNodeArr[idx].getComponent(cc.Toggle).isChecked = true;
  146. }
  147. },
  148. });