144 lines
3.1 KiB
JavaScript
144 lines
3.1 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'a0ab9b1FHJCXL1L4L/IQbCA', 'cmp.hallows.item.main');
|
||
|
|
// Scripts/mod/partner/hallows/cmp/cmp.hallows.item.main.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
var ItemBase = require("nx.fx.sv.expand.item");
|
||
|
|
var HallowsConst = require("hallows_const");
|
||
|
|
cc.Class({
|
||
|
|
"extends": ItemBase,
|
||
|
|
properties: {
|
||
|
|
lock_nd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
lock_icon: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Sprite
|
||
|
|
},
|
||
|
|
lock_name: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Label
|
||
|
|
},
|
||
|
|
off_nd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
on_nd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
off_name: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Label
|
||
|
|
},
|
||
|
|
on_name: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Label
|
||
|
|
},
|
||
|
|
off_lev: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Label
|
||
|
|
},
|
||
|
|
on_lev: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Label
|
||
|
|
},
|
||
|
|
off_icon: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Sprite
|
||
|
|
},
|
||
|
|
on_icon: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Sprite
|
||
|
|
},
|
||
|
|
off_sp: {
|
||
|
|
"default": [],
|
||
|
|
type: cc.SpriteFrame
|
||
|
|
},
|
||
|
|
on_sp: {
|
||
|
|
"default": [],
|
||
|
|
type: cc.SpriteFrame
|
||
|
|
},
|
||
|
|
tipNd: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// LIFE-CYCLE CALLBACKS:
|
||
|
|
|
||
|
|
// onLoad () {},
|
||
|
|
// 数据重置
|
||
|
|
rebind: function rebind(_idx, _data, _key) {
|
||
|
|
this._super(_idx, _data, _key);
|
||
|
|
|
||
|
|
// 刷新
|
||
|
|
this.setData(_data);
|
||
|
|
},
|
||
|
|
start: function start() {},
|
||
|
|
// 聚焦获得
|
||
|
|
onFocus: function onFocus() {
|
||
|
|
if (this.is_lock) {
|
||
|
|
this.on_nd.active = true;
|
||
|
|
this.lock_nd.active = false;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.on_nd.active = true;
|
||
|
|
this.off_nd.active = false;
|
||
|
|
},
|
||
|
|
// 聚焦失去
|
||
|
|
outFocus: function outFocus() {
|
||
|
|
if (this.is_lock) {
|
||
|
|
this.on_nd.active = false;
|
||
|
|
this.lock_nd.active = true;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.on_nd.active = false;
|
||
|
|
this.off_nd.active = true;
|
||
|
|
},
|
||
|
|
setData: function setData(data) {
|
||
|
|
if (nx.dt.objEmpty(data)) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
this.lock_name.string = data.name;
|
||
|
|
this.off_name.string = data.name;
|
||
|
|
this.on_name.string = data.name;
|
||
|
|
this.on_lev.string = 0;
|
||
|
|
this.off_lev.string = 0;
|
||
|
|
|
||
|
|
//表示未解锁当前行星武器
|
||
|
|
if (nx.dt.objEmpty(data.vo)) {
|
||
|
|
this.is_lock = true;
|
||
|
|
this.lock_nd.active = true;
|
||
|
|
this.on_nd.active = false;
|
||
|
|
this.off_nd.active = false;
|
||
|
|
} else {
|
||
|
|
this.is_lock = false;
|
||
|
|
this.lock_nd.active = false;
|
||
|
|
this.off_nd.active = true;
|
||
|
|
if (data.vo.step) {
|
||
|
|
this.on_lev.string = data.vo.step;
|
||
|
|
this.off_lev.string = data.vo.step;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (data.id != null) {
|
||
|
|
this.lock_icon.spriteFrame = this.off_sp[data.id - 1];
|
||
|
|
this.off_icon.spriteFrame = this.off_sp[data.id - 1];
|
||
|
|
this.on_icon.spriteFrame = this.on_sp[data.id - 1];
|
||
|
|
}
|
||
|
|
this.rebindTip();
|
||
|
|
},
|
||
|
|
rebindTip: function rebindTip() {
|
||
|
|
//紅點處理
|
||
|
|
var dot = nx.gui.getComponent(this, "tip", "nx.vb.visible");
|
||
|
|
if (!dot) {
|
||
|
|
nx.gui.setActive(dot, "", false);
|
||
|
|
} else {
|
||
|
|
var key = HallowsConst.TIP_DEFINED[this.mdata.id];
|
||
|
|
dot.setTarget(nx.mTip, key);
|
||
|
|
}
|
||
|
|
} // update (dt) {},
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|