294 lines
7.6 KiB
JavaScript
294 lines
7.6 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '4f269NV0nlJ1LEArnp0ifph', 'cmp.act.summon.limit');
|
|
// Scripts/mod/acts/summonLimit/cmp/cmp.act.summon.limit.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 限定招募
|
|
*
|
|
******************************************************************/
|
|
|
|
var ActPage = require("act.page.base");
|
|
var NxSpine = require("nx.fx.spine");
|
|
var ItemLayout = require("cmp.item.layout");
|
|
var BridgeItemBinder = require("bridge.binder.item.icon.count");
|
|
var TipsController = require("tips_controller");
|
|
var FID = require("bridge.function.ids");
|
|
cc.Class({
|
|
"extends": ActPage,
|
|
properties: {
|
|
nodOps: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
spRole: {
|
|
"default": null,
|
|
type: NxSpine
|
|
},
|
|
spMini: {
|
|
"default": null,
|
|
type: NxSpine
|
|
},
|
|
nodInfo: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodDate: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodLogo: {
|
|
"default": null,
|
|
type: cc.Node
|
|
},
|
|
nodCoin: {
|
|
"default": null,
|
|
type: BridgeItemBinder
|
|
},
|
|
nodScore: {
|
|
"default": null,
|
|
type: BridgeItemBinder
|
|
},
|
|
nodRewards: {
|
|
"default": null,
|
|
type: ItemLayout
|
|
}
|
|
},
|
|
// 初始化
|
|
build: function build(_data) {
|
|
this._super(_data);
|
|
|
|
// 置空
|
|
if (!this.mod || nx.dt.objEmpty(this.data)) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
// 配置查询
|
|
this.configs = this.mod.queryConfigs();
|
|
if (!this.configs) {
|
|
nx.error("$SummonLimit:\u914D\u7F6E\u7F3A\u5931! " + this.data.camp_id);
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
// 基本信息
|
|
this.freshBasic();
|
|
},
|
|
// 显示
|
|
onEnable: function onEnable() {
|
|
var _this = this;
|
|
// console.log( "Show:" + this.data.camp_id );
|
|
|
|
// 刷新
|
|
if (this.mod) {
|
|
this.mod.reqBaseData(function (_ret, _data) {
|
|
if (_ret) {
|
|
_this.freshDate(_data.remain_sec);
|
|
_this.freshRewards(_data.item_effect_list);
|
|
_this.freshOps();
|
|
}
|
|
});
|
|
}
|
|
},
|
|
// 关闭
|
|
onDisable: function onDisable() {
|
|
// console.log( "Hide:" + this.data.camp_id );
|
|
},
|
|
// 置空
|
|
setEmpty: function setEmpty() {
|
|
nx.gui.setActive(this, "right", false);
|
|
},
|
|
// 基本信息
|
|
freshBasic: function freshBasic() {
|
|
var _this2 = this;
|
|
// 置空
|
|
if (!this.mod || !this.configs || nx.dt.objEmpty(this.data)) {
|
|
this.setEmpty();
|
|
return;
|
|
}
|
|
|
|
// 背景刷新
|
|
var bg = cc.path.join("resDB/bigs", this.configs.bg || "bg005");
|
|
nx.gui.setSpriteFrame(this, "bg", bg);
|
|
nx.gui.setActive(this, "right", true);
|
|
|
|
// 标签刷新
|
|
var tags = cc.path.join("locals/{lang}/images/limitrecruit", this.configs.effect);
|
|
nx.gui.setSpriteFrame(this.nodInfo, "desc", nx.res.fmtPath(tags));
|
|
|
|
// Logo刷新
|
|
var logo = cc.path.join("locals/{lang}/images/limitrecruit", this.configs.title);
|
|
nx.gui.setSpriteFrame(this.nodLogo, "", nx.res.fmtPath(logo));
|
|
|
|
// 道具绑定
|
|
this.nodCoin.setID(this.configs.prop_id, function () {
|
|
_this2.freshOps();
|
|
});
|
|
|
|
// 积分绑定
|
|
this.nodScore.setID(this.configs.point_id);
|
|
|
|
// 角色信息刷新
|
|
this.freshPartner(this.configs.partner_id);
|
|
|
|
// 红点绑定
|
|
var tip1 = nx.gui.getComponent(this.nodOps, "once/tip", "nx.vb.visible");
|
|
if (tip1) {
|
|
tip1.setTarget(nx.mTip, this.mod.getTipKey("once"));
|
|
}
|
|
var tip2 = nx.gui.getComponent(this.nodOps, "ten/tip", "nx.vb.visible");
|
|
if (tip2) {
|
|
tip2.setTarget(nx.mTip, this.mod.getTipKey("ten"));
|
|
}
|
|
},
|
|
// 刷新角色
|
|
freshPartner: function freshPartner(_bid) {
|
|
var _this3 = this;
|
|
var dat = game.configs.partner_data.data_partner_base[_bid];
|
|
var scfgs = gdata("partner_data", "data_partner_star", _bid + "_" + dat.init_star);
|
|
if (nx.dt.objEmpty(scfgs)) {
|
|
nx.error("刷新角色失败,无效伙伴:", _bid);
|
|
return;
|
|
}
|
|
|
|
// 名字
|
|
nx.gui.setString(this.nodInfo, "base/name", nx.text.getKey(dat.name));
|
|
|
|
// 品质
|
|
var path = cc.path.join("coms/images", "mk_partner_qa" + dat.quality);
|
|
nx.gui.setSpriteFrame(this.nodInfo, "qa", path);
|
|
|
|
// 阵营
|
|
path = cc.path.join("prefab/partner/ui/camp" + dat.camp_type);
|
|
nx.gui.setSpriteFrame(this.nodInfo, "base/camp", path);
|
|
|
|
// 星级
|
|
path = cc.path.join("coms/images/star" + dat.init_star);
|
|
nx.gui.setSpriteFrame(this.nodInfo, "stars", path);
|
|
|
|
// 角色动画
|
|
path = PathTool.getSpinePath(scfgs.res_id, "show", false);
|
|
this.spRole.load(path, function (_e) {
|
|
if (!_e) {
|
|
_this3.spRole.action("action1", true);
|
|
} else {
|
|
_this3.spRole.stop();
|
|
}
|
|
});
|
|
|
|
// MINI动画
|
|
path = PathTool.getSpinePath(scfgs.res_id, scfgs.res_id, false);
|
|
this.spMini.load(path, function (_e) {
|
|
if (!_e) {
|
|
_this3.spMini.action("stand2", true);
|
|
} else {
|
|
_this3.spMini.stop();
|
|
}
|
|
});
|
|
|
|
// 技能
|
|
var sknode = nx.gui.find(this.nodInfo, "skills");
|
|
for (var i = 0; i < sknode.children.length; ++i) {
|
|
// 技能数组[0]为普攻,直接忽略,最多4个技能
|
|
var item = sknode.children[i];
|
|
var sifo = scfgs.skills[i + 1];
|
|
if (!sifo) {
|
|
item.active = false;
|
|
continue;
|
|
}
|
|
item.active = true;
|
|
var cmp = nx.gui.getComponent(item, "", "cmp.skill.base");
|
|
if (cmp) {
|
|
cmp.setData(sifo[1]);
|
|
}
|
|
}
|
|
},
|
|
// 刷新活动日期
|
|
freshDate: function freshDate(_secs) {
|
|
var time = nx.bridge.time.toNeedSeconds(_secs);
|
|
nx.gui.setString(this.nodDate, "txt", time);
|
|
},
|
|
// 刷新奖励
|
|
freshRewards: function freshRewards(_list) {
|
|
var rewards = [];
|
|
if (nx.dt.arrNEmpty(_list)) {
|
|
for (var i = 0; i < _list.length; ++i) {
|
|
rewards.push([_list[i].bid, 1]);
|
|
}
|
|
}
|
|
this.nodRewards.rebuild(rewards);
|
|
},
|
|
// 变化信息
|
|
freshOps: function freshOps() {
|
|
// 置空
|
|
if (!this.mod || !this.configs || nx.dt.objEmpty(this.data)) {
|
|
return;
|
|
}
|
|
|
|
// 按钮设置
|
|
var autoOp = function autoOp(_node, _draw) {
|
|
var tinfo = gitemdata(_draw[0]);
|
|
if (!tinfo) {
|
|
nx.error("$SummonLimit:\u9053\u5177\u65E0\u6548! " + _draw[0]);
|
|
return;
|
|
}
|
|
nx.bridge.setIcon(_node, "btn/list/icon", tinfo.icon);
|
|
nx.gui.setString(_node, "btn/list/num", _draw[1]);
|
|
};
|
|
|
|
// 操作刷新
|
|
autoOp(nx.gui.find(this.nodOps, "once"), this.configs.draw_one[0]);
|
|
autoOp(nx.gui.find(this.nodOps, "ten"), this.configs.draw_ten[0]);
|
|
},
|
|
// 点击单抽
|
|
onTouchOnce: function onTouchOnce() {
|
|
var _this4 = this;
|
|
if (!this.configs || !this.mod) {
|
|
return;
|
|
}
|
|
this.mod.reqRaffle(this.configs.group_id, true, function (_ret, _msg, _code) {
|
|
// 道具不足
|
|
if (!_ret && _code == 101) {
|
|
nx.tbox(_msg);
|
|
_this4.onTouchCoin();
|
|
}
|
|
});
|
|
},
|
|
// 点击十抽
|
|
onTouchTen: function onTouchTen() {
|
|
var _this5 = this;
|
|
if (!this.configs || !this.mod) {
|
|
return;
|
|
}
|
|
this.mod.reqRaffle(this.configs.group_id, false, function (_ret, _msg, _code) {
|
|
// 道具不足
|
|
if (!_ret && _code == 101) {
|
|
nx.tbox(_msg);
|
|
_this5.onTouchCoin();
|
|
}
|
|
});
|
|
},
|
|
// 点击规则
|
|
onTouchRule: function onTouchRule() {
|
|
var rule = this.mod ? this.mod.queryRule() : "";
|
|
if (nx.dt.strNEmpty(rule)) {
|
|
var TC = TipsController.getInstance();
|
|
TC.showTextPanel("tip", rule);
|
|
}
|
|
},
|
|
// 点击道具
|
|
onTouchCoin: function onTouchCoin() {
|
|
if (this.actRoot && this.configs) {
|
|
this.actRoot.jumpToMenu(this.configs.jump);
|
|
}
|
|
},
|
|
// 点击兑换
|
|
onTouchShop: function onTouchShop() {
|
|
nx.bridge.jumper.jump2Window(FID.PartnerExChange);
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |