Files
fc/dev/project/library/imports/40/406f6dd9-c53c-4ea5-85cd-caed0ba03073.js
2026-05-24 10:21:26 +08:00

169 lines
4.5 KiB
JavaScript

"use strict";
cc._RF.push(module, '406f63ZxTxOpYXNyu0LoDBz', 'cmp.act.partnertrial.wnd');
// Scripts/mod/acts/partnertrial/cmp/cmp.act.partnertrial.wnd.js
"use strict";
/******************************************************************
*
* 星界初體驗
*
******************************************************************/
var ActPopup = require("act.popup.base");
var NxSpine = require("nx.fx.spine");
var PathTool = require("pathtool");
var HeroTrialMod = require("act.partnertrial.mod");
var HeroConst = require("hero_const");
var HeroVo = require("hero_vo");
cc.Class({
"extends": ActPopup,
properties: {
roleSp: {
"default": null,
type: NxSpine
},
tagHero: {
"default": null,
type: cc.Node
},
fabHero: {
"default": null,
type: cc.Prefab
},
ndSmod: {
"default": null,
type: cc.Node
},
fabSmod: {
"default": null,
type: cc.Prefab
},
infoNd: {
"default": null,
type: cc.Node
},
cdTime: {
"default": null,
type: cc.Node
},
ndTry: {
"default": null,
type: cc.Node
},
ndTime: {
"default": null,
type: cc.Node
},
ndTip: {
"default": null,
type: cc.Node
}
},
// 初始化
onLoad: function onLoad() {
this.mod = HeroTrialMod.getInstance();
this.try_data = game.configs.partner_try_data;
this.tag_bid = 0;
this.pv_bid = 0;
// 活动监听
this.mod.vbind(this, [["heroTrialData", this.freshData.bind(this)], ["PVPlayFlag", this.playPv.bind(this)]]);
},
onOpenConfigs: function onOpenConfigs(_params) {
this._super(_params);
this.mod.send31004();
this.mod.send31005();
},
onPreClosed: function onPreClosed() {
// 活动监听解除
if (this.mod) {
this.mod.vunbind(this);
}
},
playPv: function playPv(flag) {
if (flag && flag == 1) {
this.touchPVPlay();
}
},
freshData: function freshData(data) {
var _this = this;
if (nx.dt.objEmpty(data)) return;
//英雄详情
var hero = data.partners[0];
if (!hero) return;
var h_config = game.configs.partner_data.data_partner_base[hero.bid];
if (h_config) {
nx.gui.setString(this.infoNd, "name", h_config.name);
// 职业
var career = h_config.type || 4;
var icon = cc.path.join("coms/images", "career" + career);
var campicon = cc.path.join("coms/images", "camps" + h_config.camp_type);
var name = nx.text.getKey(HeroConst.CareerName[career]) || nx.text.getKey("lab_none");
nx.gui.setString(this.infoNd, "work", name);
nx.gui.setSpriteFrame(this.infoNd, "carcee", icon);
nx.gui.setSpriteFrame(this.infoNd, "camp", campicon);
//模型加载
var res_path = PathTool.getSpinePath(h_config.bustid, "show", false);
this.roleSp.load(res_path, function (_e) {
if (_e) {
_this.roleSp.stop();
} else {
_this.roleSp.action("action1", true);
}
});
var trialHero = new HeroVo();
trialHero.updateHeroVo(hero);
//小模型
if (!this.sHero) {
this.sHero = cc.instantiate(this.fabSmod);
this.sHero.parent = this.ndSmod;
this.sHero.y += 25;
}
var scmp = nx.gui.getComponent(this.sHero, "", "cmp.partner.smod");
if (scmp) {
scmp.setData(trialHero, true, false);
}
//英雄名片
if (!this.tHero) {
this.tHero = cc.instantiate(this.fabHero);
this.tHero.parent = this.tagHero;
}
var tcmp = nx.gui.getComponent(this.tHero, "", "cmp.item.base");
if (tcmp) {
tcmp.rebind(0, trialHero, "");
}
}
//是否领取
if (data.finish == 0) {
this.tag_bid = hero.bid;
nx.gui.setString(this.ndTry, "txt", nx.text.getKey("TryPartBtn"));
} else {
nx.gui.setString(this.ndTry, "txt", nx.text.getKey("Got"));
}
nx.gui.setActive(this.ndTime, "", data.finish == 1);
nx.gui.setActive(this.ndTip, "", data.finish != 1);
this.pv_bid = hero.bid;
//倒计时cd
var cds = data.end_time - client.socket.getTime();
nx.gui.setCdTxt(this.cdTime, "", cds);
},
touchPVPlay: function touchPVPlay() {
nx.bridge.createPanel("WndActPartnertrialPv", {
bid: this.pv_bid
});
},
touchHeroGet: function touchHeroGet() {
var _this2 = this;
if (this.tag_bid == 0) return;
this.mod.send31003(this.tag_bid, function (_data) {
if (_data) {
_this2.tag_bid = 0;
}
});
}
});
cc._RF.pop();