104 lines
3.0 KiB
JavaScript
104 lines
3.0 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'fbe87PNJbBDYaX1PmwbgLGo', 'cmp.element.item');
|
|
// Scripts/mod/pve/element/cmp/cmp.element.item.js
|
|
|
|
"use strict";
|
|
|
|
var _DateTxt;
|
|
var ElementController = require("element_controller");
|
|
var DateTxt = (_DateTxt = {}, _DateTxt[1] = "Num1", _DateTxt[2] = "Num2", _DateTxt[3] = "Num3", _DateTxt[4] = "Num4", _DateTxt[5] = "Num5", _DateTxt[6] = "Num6", _DateTxt[7] = "Num7", _DateTxt);
|
|
cc.Class({
|
|
"extends": cc.Component,
|
|
properties: {
|
|
type: 0,
|
|
tiNd: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
bossNd: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
infoNd: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
title: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
fabPlayer: {
|
|
"default": null,
|
|
type: cc.Prefab
|
|
}
|
|
},
|
|
// LIFE-CYCLE CALLBACKS:
|
|
// onLoad () {},
|
|
start: function start() {
|
|
this.setBase();
|
|
},
|
|
setBase: function setBase() {
|
|
this.base_data = game.configs.element_temple_data.data_base[this.type];
|
|
if (nx.dt.objEmpty(this.base_data)) {
|
|
return;
|
|
}
|
|
nx.gui.setActive(this, "sp", false);
|
|
nx.gui.setString(this.title, "", this.base_data.name);
|
|
var day1 = nx.text.getKey(DateTxt[this.base_data.open_day[0]]);
|
|
nx.gui.setString(this.infoNd, "tips", cc.js.formatStr(nx.text.getKey("EleLiftspan"), day1));
|
|
nx.gui.setSpriteFrame(this.infoNd, "camp", cc.js.formatStr("coms/images/camps%s", this.type));
|
|
},
|
|
setData: function setData(data) {
|
|
if (nx.dt.objEmpty(data)) {
|
|
return;
|
|
}
|
|
this.data = data;
|
|
if (data.endtime > 0) {
|
|
this.bossNd.active = true;
|
|
this.infoNd.active = false;
|
|
this.tiNd.y = -8;
|
|
if (!this.monster) {
|
|
this.monster = cc.instantiate(this.fabPlayer);
|
|
this.monster.parent = this.bossNd;
|
|
}
|
|
var monster_data = game.configs.element_temple_data.data_monster[data.group];
|
|
if (monster_data) {
|
|
var partner_data = game.configs.partner_data.data_partner_base[monster_data.head_id];
|
|
if (partner_data == null) return;
|
|
var cmp = nx.gui.getComponent(this.monster, "", "cmp.item.base");
|
|
if (cmp) {
|
|
nx.gui.setActive(this, "sp", true);
|
|
cmp.setData(partner_data);
|
|
}
|
|
}
|
|
} else {
|
|
this.tiNd.y = -78;
|
|
this.bossNd.active = false;
|
|
this.infoNd.active = true;
|
|
}
|
|
},
|
|
checkIsOpen: function checkIsOpen() {
|
|
var ele_data = ElementController.getInstance().getModel().getElementData();
|
|
var base_data = game.configs.element_temple_data.data_base[this.data.type];
|
|
var is_open = false;
|
|
for (var i in base_data.open_day) {
|
|
if (base_data.open_day[i] == ele_data.day) {
|
|
is_open = true;
|
|
break;
|
|
}
|
|
}
|
|
return is_open;
|
|
},
|
|
onClickItem: function onClickItem() {
|
|
var open = this.checkIsOpen();
|
|
if (!open) {
|
|
return nx.tbox("lab_guild_action_goal_item_tip1");
|
|
}
|
|
nx.bridge.createPanel("WndElemetEctype", {
|
|
group: this.data.group,
|
|
type: this.data.type
|
|
});
|
|
} // update (dt) {},
|
|
});
|
|
|
|
cc._RF.pop(); |