| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- cc.Class({
- //extends: cc.BaseClass,
- extends: cc.SubRoomRules,
- properties: {
- m_baseNode: cc.Node,
- },
- //1000-1031 服务器规则 1050-1099 对应规则
- //1000 =>AA付 1050 =>房主付
- //1001 =>代开 1051 =>房主进入
- //1002 =>积分房间 1003 =>金币房间 1052 =>练习房间
- ctor: function () {
- this.m_bNeedUpdate = false;
- this.m_bFirstShow = true;
-
- },
- //添加对立规则数组索引
- CheckToggle(ArrIndex, JS) {
- },
- OnShowView: function () {
- this.m_bNeedUpdate = true;
- },
- OnHideView: function () {
- this.getRulesEx();
- this.getServerRules();
- this.node.active = false;
- },
- SetClubView: function (RoomType) {
- //this.$('ClubNode').active = RoomType == 1;
- if (this.m_ClubNode != null) this.m_ClubNode.active = (RoomType != 0);
- this.m_bNeedUpdate = true;
- },
- SetKeyView: function (key) {
- if (this.m_baseNode) {
- this.baseIndexArr = {};
- this.baseNodeArr = {};
- for (let cNode of this.m_baseNode.children) {
- let curName = cNode.name;
- if (curName[0] == "1") {
- this.baseIndexArr[curName[1]] = 0;
- this.baseNodeArr[curName[1]] = cNode;
- cNode.getComponent(cc.Toggle).isChecked = true;
- }
- }
- this.updateBaseView();
- }
- },
- OnToggleClick: function (Tag, Data) {
- this.m_bNeedUpdate = true;
- },
-
- OnUpdateCustomView:function()
- {
- this.GetPayWay();
- this.OnChecTWMJ();
- for (var i in this.m_togArr) {
- if (!this.m_togArr[i].node.active) continue;
- var color = this.m_togArr[i].isChecked ? cc.color(208,185,239) : cc.color(129,95,57);
- this.m_togArr[i].node.getChildByName('Label').color = color;
- }
- },
- UpdateBaseScore: function () {
- if (this.m_LabBaseScore != null) this.m_LabBaseScore.string = this.m_SitScore;
- },
- //台湾麻将
- OnChecTWMJ: function () {
-
- var RuleBB,RuleNB;
- var RuleBB1,RuleNB1;
- for (var i in this.m_togArr) {
- if (this.m_togArr[i].node.name == 26) RuleBB = i; //台湾北部麻将玩法
- if (this.m_togArr[i].node.name == 27) RuleNB = i; //台湾南部麻将玩法
- if (this.m_togArr[i].node.name == 28) RuleBB1 = i; //台湾北部呖咕呖咕 玩法
- // if (this.m_togArr[i].node.name == 9) RuleNB1 = i; //台湾南部庄家无台 玩法
- }
- let isShowNorth = this.m_togArr[RuleBB].isChecked;
- this.m_togArr[RuleBB1].node.parent.active = isShowNorth;
-
- },
- GetPayWay: function () {
- var payWayPath = "PayWay/1050@Toggle";
- var gameCountPath = "GameCount/";
- var labels = [
- { node: '1019/Label@Label', text: ['1圈X4', '1圈X6', '1圈X8'] },
- { node: '1020/Label@Label', text: ['2圈X6', '2圈X9', '2圈X12'] },
- { node: '1021/Label@Label', text: ['4圈X8', '4圈X12', '4圈X16'] }
- ];
- var alternativeLabels = ['1圈x2', '2圈x3', '4圈x4'];
- var renshuIndices = { 1018: null, 1017: null, 1016: null };
- var Path = "ScrollView/view/content/";
-
- for (var i in this.m_togArr) {
- var nodeName = this.m_togArr[i].node.name;
- if (renshuIndices.hasOwnProperty(nodeName)) {
- renshuIndices[nodeName] = i;
- }
- }
-
- var setLabels = function (labelArray, checkedIndex) {
- for (var j in labelArray) {
- this.$(Path + gameCountPath + labelArray[j].node).string = labelArray[j].text[checkedIndex];
- }
- }.bind(this);
-
- if (this.$(Path + payWayPath).isChecked) {
- if (renshuIndices[1018] !== null && this.m_togArr[renshuIndices[1018]].isChecked) {
- setLabels(labels, 0);
- } else if (renshuIndices[1017] !== null && this.m_togArr[renshuIndices[1017]].isChecked) {
- setLabels(labels, 1);
- } else if (renshuIndices[1016] !== null && this.m_togArr[renshuIndices[1016]].isChecked) {
- setLabels(labels, 2);
- }
- }
-
- var alternativePayWayPath = "PayWay/1000@Toggle";
- if (this.$(Path + alternativePayWayPath).isChecked) {
- for (var k in alternativeLabels) {
- this.$(Path + gameCountPath + labels[k].node).string = alternativeLabels[k];
- }
- }
- },
- updateBaseView() {
- for (let idx in this.baseNodeArr) {
- let baseNode = this.baseNodeArr[idx];
- let showIndex = this.baseIndexArr[idx];
- let config = window.RoomBaseInfo[idx];
- baseNode.name = `1${idx}00${showIndex}`
- baseNode.getChildByName("Label").getComponent(cc.Label).string = "" + config[showIndex];
- baseNode.getChildByName("last").active = showIndex > 0;
- baseNode.getChildByName("next").active = showIndex < config.length - 1;
- }
- },
- //key 0-0/1 typeIndex- -/+
- onclickNextOrLastBase(event, key) {
- let keyArr = key.split("-");
- let idx = Number(keyArr[0]);
- let config = window.RoomBaseInfo[idx];
- let showIndex = this.baseIndexArr[idx];
- if ("0" == keyArr[1]) {
- showIndex -= 1;
- } else if ("1" == keyArr[1]) {
- showIndex += 1;
- } else {
- return;
- }
- if (showIndex < 0 || showIndex > config.length - 1) {
- return;
- }
- this.baseIndexArr[idx] = showIndex;
- this.updateBaseView();
- },
- resetCheck() {
- for (let idx in this.baseNodeArr) {
- this.baseNodeArr[idx].getComponent(cc.Toggle).isChecked = true;
- }
- },
- });
|