Files
fc/dev/project/library/imports/9a/9a84c979-7348-4451-8fa6-8aff77e19492.js
2026-05-24 10:21:26 +08:00

104 lines
2.3 KiB
JavaScript

"use strict";
cc._RF.push(module, '9a84cl5c0hEUY+miv934ZSS', 'cmp.summon.score');
// Scripts/mod/summon/score/cmp.summon.score.js
"use strict";
/******************************************************************
* Copyright(C) 2019 - 2020 Nx Studio
*
* 积分召唤
*
* 2018.05.18
******************************************************************/
var RoleController = require("role_controller");
var SummonMod = require("summon.mod");
cc.Class({
"extends": cc.Component,
properties: {
sumId: {
"default": 0,
displayName: "召唤编号"
},
nodScore: {
"default": null,
type: cc.Node
},
cmpProg: {
"default": null,
type: cc.ProgressBar
}
},
// 显示
onEnable: function onEnable() {
var _this = this;
// 初始化绑定
this.bindId(this.sumId);
var RC = RoleController.getInstance();
this.role = RC.getRoleVo();
if (!this.role) {
this.setEmpty();
return;
}
// 属性监听
if (!this.handler) {
this.handler = this.role.bind(EventId.UPDATE_ROLE_ATTRIBUTE, function (_key, _val) {
if (_key == "recruit_hero") {
_this.updateData();
}
});
}
// 更新数据
this.updateData();
},
// 关闭
onDisable: function onDisable() {
// 监听解除
if (this.role && this.handler) {
this.role.unbind(this.handler);
this.role = null;
this.handler = null;
}
},
// 置空
setEmpty: function setEmpty() {
nx.gui.setString(this.nodScore, "txt", "");
this.cmpProg.progress = 0;
},
// 设置召唤库编号
bindId: function bindId(_id) {
// 置空
if (!nx.dt.numPositive(_id, false)) {
this.setEmpty();
return;
}
this.sumId = _id;
// 更新数据
this.updateData();
},
// 更新数据
updateData: function updateData(_data) {
if (!this.role) {
this.setEmpty();
return;
}
var SC = SummonMod.getInstance();
var SM = SC.getModel();
var cur = this.role.recruit_hero;
var max = SM.getScoreSummonNeedCount();
this.cmpProg.progress = Math.min(1, cur / max);
nx.gui.setString(this.nodScore, "txt", cur + "/" + max);
},
// 点击
onTouchGet: function onTouchGet() {
nx.bridge.createPanel("WndSummonScore", {
gid: this.sumId
});
}
});
cc._RF.pop();