138 lines
3.8 KiB
JavaScript
138 lines
3.8 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, '208f4kalFZLoIHq/h/qyNzy', 'cmp.heaven.item.main');
|
||
|
|
// Scripts/mod/pve/heaven/cmp/cmp.heaven.item.main.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var ItemBase = require("nx.fx.sv.expand.item");
|
||
|
|
var HEACT = require("heaven_controller");
|
||
|
|
cc.Class({
|
||
|
|
"extends": ItemBase,
|
||
|
|
properties: {
|
||
|
|
mainNd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
normal: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
boss: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
stars: {
|
||
|
|
"default": [],
|
||
|
|
type: [cc.Node]
|
||
|
|
},
|
||
|
|
lockNd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
powerNd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
levNum: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
rebind: function rebind(_index, _data, _key) {
|
||
|
|
this._super(_index, _data, _key);
|
||
|
|
this.setData(_data);
|
||
|
|
},
|
||
|
|
setData: function setData(data) {
|
||
|
|
if (nx.dt.objEmpty(data)) return;
|
||
|
|
this.data = data;
|
||
|
|
nx.gui.setString(this.levNum, "", cc.js.formatStr("%s-%s", data.id, data.order_id));
|
||
|
|
if (data.order_id % 2 == 0) {
|
||
|
|
this.mainNd.y = -75;
|
||
|
|
} else {
|
||
|
|
this.mainNd.y = 75;
|
||
|
|
}
|
||
|
|
this.is_pass = false;
|
||
|
|
this.updateInfo();
|
||
|
|
},
|
||
|
|
updateInfo: function updateInfo() {
|
||
|
|
this.custom_data = HEACT.getInstance().getModel().getCustomsDataById(this.data.id, this.data.order_id);
|
||
|
|
if (nx.dt.objEmpty(this.custom_data)) return;
|
||
|
|
var star_info = this.custom_data.star_info;
|
||
|
|
for (var i = 0; i < star_info.length; i++) {
|
||
|
|
var nd = this.stars[i];
|
||
|
|
var info = star_info[i];
|
||
|
|
if (info && nd) {
|
||
|
|
nx.gui.setActive(nd, "star", info.flag == 1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//判斷最大通關id
|
||
|
|
var max_id = HEACT.getInstance().getModel().getMaxDunId();
|
||
|
|
//判斷是否通關
|
||
|
|
var is_done = HEACT.getInstance().getModel().checkCustomsIsPassByDunId(this.data.dun_id);
|
||
|
|
var btnCmp = nx.gui.getComponent(this.normal, "", cc.Button);
|
||
|
|
var bossCmp = nx.gui.getComponent(this.boss, "", cc.Button);
|
||
|
|
this.lockNd.active = false;
|
||
|
|
this.powerNd.active = true;
|
||
|
|
// this.levNum.active = true;
|
||
|
|
if (is_done) {
|
||
|
|
//已通過且當前關卡不是最大通關關卡
|
||
|
|
if (this.custom_data.star < 3) {
|
||
|
|
this.is_pass = false;
|
||
|
|
} else {
|
||
|
|
this.is_pass = true;
|
||
|
|
}
|
||
|
|
if (this.data.order_id == 10) {
|
||
|
|
//boss關卡
|
||
|
|
bossCmp.interactable = true;
|
||
|
|
this.boss.active = true;
|
||
|
|
this.normal.active = false;
|
||
|
|
} else {
|
||
|
|
btnCmp.interactable = true;
|
||
|
|
this.boss.active = false;
|
||
|
|
this.normal.active = true;
|
||
|
|
// nx.gui.setActive(this.normal,"select",false);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
this.is_pass = false;
|
||
|
|
if (max_id == 0 && this.data.order_id == 1 || this.data.dun_id == max_id + 1) {
|
||
|
|
//未通關可挑戰
|
||
|
|
if (this.data.order_id == 10) {
|
||
|
|
//boss關卡
|
||
|
|
bossCmp.interactable = true;
|
||
|
|
this.boss.active = true;
|
||
|
|
this.normal.active = false;
|
||
|
|
} else {
|
||
|
|
btnCmp.interactable = true;
|
||
|
|
this.boss.active = false;
|
||
|
|
this.normal.active = true;
|
||
|
|
// nx.gui.setActive(this.normal,"select",true);
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
if (this.data.order_id == 10) {
|
||
|
|
//boss關卡
|
||
|
|
this.boss.active = true;
|
||
|
|
this.normal.active = false;
|
||
|
|
bossCmp.interactable = false;
|
||
|
|
} else {
|
||
|
|
this.boss.active = false;
|
||
|
|
this.normal.active = true;
|
||
|
|
btnCmp.interactable = false;
|
||
|
|
}
|
||
|
|
this.lockNd.active = true;
|
||
|
|
this.powerNd.active = false;
|
||
|
|
// this.levNum.active = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
clickFightInfo: function clickFightInfo() {
|
||
|
|
if (!this.data) return;
|
||
|
|
nx.bridge.createPanel("WndHeavenFightinfo", {
|
||
|
|
cfg: this.data,
|
||
|
|
is_pass: this.is_pass
|
||
|
|
});
|
||
|
|
} // update (dt) {},
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|