93 lines
2.3 KiB
JavaScript
93 lines
2.3 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, 'f4349EQDmdOAYthvAUC39Pg', 'cmp.partner.skin.item');
|
|
// Scripts/mod/partner/cmps/skin/cmp.partner.skin.item.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 伙伴皮肤项
|
|
*
|
|
******************************************************************/
|
|
|
|
var SkinWnd = require("cmp.partner.skin");
|
|
var HeroController = require("hero_controller");
|
|
|
|
// 聚焦偏移
|
|
var ON_Y = -30;
|
|
var OFF_Y = -20;
|
|
cc.Class({
|
|
"extends": cc.Component,
|
|
properties: {
|
|
bindWnd: {
|
|
"default": null,
|
|
type: SkinWnd
|
|
},
|
|
nodFocus: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodInfos: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// 设置
|
|
setSkin: function setSkin(_index, _data) {
|
|
// 重置
|
|
if (nx.dt.objEmpty(this.skin)) {
|
|
nx.gui.setActive(this.nodInfos, "lock", false);
|
|
nx.gui.setActive(this.nodInfos, "way", false);
|
|
this.setFocus(false);
|
|
}
|
|
this.index = _index;
|
|
this.skin = _data;
|
|
if (nx.dt.objEmpty(this.skin)) {
|
|
return;
|
|
}
|
|
|
|
// 图片
|
|
var path = cc.path.join("resDB/models", this.skin.res_id, "half_show4");
|
|
nx.gui.setSpriteFrame(this.nodInfos, "role/img", path, function (_ret) {
|
|
if (!_ret) {
|
|
nx.gui.setSpriteFrame(node, "role/img", "resDB/empty/half_show4");
|
|
}
|
|
});
|
|
|
|
// 名字
|
|
var name = nx.text.getKey(this.skin.skin_name);
|
|
nx.gui.setString(this.nodInfos, "name", name);
|
|
|
|
// 获取途径
|
|
var way = nx.text.getKey(this.skin.source_tip);
|
|
nx.gui.setString(this.nodInfos, "way", way);
|
|
|
|
// 变量刷新
|
|
this.freshVars();
|
|
},
|
|
// 变量刷新
|
|
freshVars: function freshVars() {
|
|
var HC = HeroController.getInstance();
|
|
var HM = HC.getModel();
|
|
var lst = HM.hero_skin_list || {};
|
|
var have = nx.dt.numGood(lst[this.skin.skin_id]);
|
|
nx.gui.setActive(this.nodInfos, "lock", !have);
|
|
nx.gui.setActive(this.nodInfos, "way", !have);
|
|
},
|
|
// 聚焦
|
|
setFocus: function setFocus(_focus) {
|
|
this.nodFocus.active = _focus;
|
|
this.nodInfos.y = _focus ? ON_Y : OFF_Y;
|
|
var clr = _focus ? new cc.color("#21FFC6") : cc.Color.WHITE;
|
|
nx.gui.setColor(this.nodInfos, "way", clr);
|
|
},
|
|
// 点击
|
|
onTouch: function onTouch() {
|
|
if (this.nodFocus.active) {
|
|
return;
|
|
}
|
|
this.bindWnd.setSkin(this.index);
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |