Files
fc/dev/project/library/imports/82/824c4218-3a7b-4301-8351-16222efede57.js
T

278 lines
7.1 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '824c4IYOntDAYNRFiIu/t5X', 'cmp.summon.partner.show.wnd');
// Scripts/mod/summon/com/cmp.summon.partner.show.wnd.js
"use strict";
/******************************************************************
*
* 伙伴获得展示界面
*
******************************************************************/
var BridgeWindow = require("bridge.window");
var NxSpine = require("nx.fx.spine");
var TipsController = require("tips_controller");
var HeroConst = require("hero_const");
var HeroController = require("hero_controller");
// 准备动画
var EID_READY = "E50093";
cc.Class({
"extends": BridgeWindow,
properties: {
spReady: {
"default": null,
type: NxSpine
},
spRole: {
"default": null,
type: NxSpine
},
nodInfo: {
"default": null,
type: cc.Node
},
nodProps: {
"default": null,
type: cc.Node
},
nodNew: {
"default": null,
type: cc.Node
},
lstSkills: {
"default": null,
type: cc.Node
},
spBg: {
"default": null,
type: cc.Node
},
spBars: {
"default": [],
type: cc.Node
}
},
// 重载:参数打开
onOpenConfigs: function onOpenConfigs(_params) {
var _this = this;
/** 单结构
* init_star,is_chips,partner_bid,status
*/
this.queue = _params.bids;
this.cb = _params.cb;
// 空展示
if (nx.dt.arrEmpty(this.queue)) {
this.scheduleOnce(function () {
_this.close();
}, 0.05);
}
// 记录是否是新卡
var Model = HeroController.getInstance().getModel();
for (var i in this.queue) {
var bid = this.queue[i].partner_bid;
var star = Model.getHadHeroStarBybid(bid);
this.queue[i].had = nx.dt.numPositive(star, false);
}
// 展示下一个
this.showNext();
},
// 展示下一个
showNext: function showNext() {
// 空了
if (nx.dt.arrEmpty(this.queue)) {
nx.dt.fnInvoke(this.cb);
this.close();
return;
}
// 弹出
var data = this.queue.shift();
if (nx.dt.objEmpty(data) || !nx.dt.numPositive(data.partner_bid, false)) {
nx.error("无效伙伴展示!");
this.showNext();
return;
}
// 动画
var anim = nx.gui.getComponent(this, "", cc.Animation);
if (anim) {
anim.play("anim_show");
}
// 配置获取
var bid = data.partner_bid;
var cfgs = game.configs.partner_data.data_partner_base[bid];
var star = data.init_star || (cfgs ? cfgs.star : 0);
var scfgs = gdata("partner_data", "data_partner_star", bid + "_" + star);
if (nx.dt.objEmpty(scfgs)) {
nx.error("无效伙伴展示,配置无效:", bid + "_" + star);
this.showNext();
return;
}
// 刷新
this.had = data.had;
this.star = star;
this.cfgs = cfgs;
this.scfgs = scfgs;
this.fresh();
// 如果空了刷新一次图鉴
if (nx.dt.arrEmpty(this.queue)) {
var HC = HeroController.getInstance();
HC.sender11040();
}
},
// 刷新当前信息
fresh: function fresh() {
var _this2 = this;
// 新卡
nx.gui.setActive(this.nodNew, "", !this.had);
// 角色
this.scheduleOnce(function () {
_this2.showRole();
}, 0.2);
// 名字
nx.gui.setString(this.nodInfo, "name", this.cfgs.name);
// 品质
var path = cc.path.join("coms/images", "mk_partner_qa" + this.cfgs.quality);
nx.gui.setSpriteFrame(this.nodInfo, "qa", path);
// 阵营
path = cc.path.join("prefab/partner/ui/camp" + this.cfgs.camp_type);
nx.gui.setSpriteFrame(this.nodInfo, "camp", path);
// 星级
path = cc.path.join("coms/images", "star" + this.star);
nx.gui.setSpriteFrame(this.nodInfo, "stars", path);
// 职业
var career = this.cfgs.type || 4;
var icon = cc.path.join("coms/images", "career" + career);
var name = nx.text.getKey(HeroConst.CareerName[career]) || nx.text.getKey("lab_none");
nx.gui.setActive(this.nodProps, "career", true);
nx.gui.setString(this.nodProps, "career/txt", name);
nx.gui.setSpriteFrame(this.nodProps, "career/icon", icon);
// 定位
var pos = this.cfgs.pos || this.cfgs.introduce_str;
nx.gui.setString(this.nodProps, "pos", nx.text.getKey(pos));
// 技能
nx.gui.setActive(this.lstSkills, "", true);
var chds = this.lstSkills.children;
for (var i = 0; i < chds.length; ++i) {
// 技能数组[0]为普攻,直接忽略,最多4个技能
var item = chds[i];
var sifo = this.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]);
}
}
// SSR皮肤切换
var key = "Normal";
if (this.cfgs.quality >= 4) {
key = "SSR";
} else if (this.cfgs.quality >= 3) {
key = "SR";
}
var bg = cc.path.join("prefab/summon/images", "bg" + key);
nx.gui.setSpriteFrame(this.spBg, "", bg);
var tiao = cc.path.join("prefab/summon/images", "tiao" + key);
this.spBars.forEach(function (_bar) {
nx.gui.setSpriteFrame(_bar, "", tiao);
});
},
// 查看介绍
onTouchStory: function onTouchStory() {
var TC = TipsController.getInstance();
var txt = nx.text.getKey("story" + this.cfgs.bid);
TC.showTextPanel("PartnerStory", txt);
},
// 点击下一个
onTouchNext: function onTouchNext() {
this.showNext();
},
// 角色准备
readyRole: function readyRole() {
this.spRole.stop();
var self = this;
var path = PathTool.getSpinePath(EID_READY, "action", false);
this.spRole.load(path, function (_e) {
if (_e) {
self.showRole();
return;
}
self.spRole.action("action", false, function (_key) {
if (_key == "complete") {
self.showRole();
}
});
});
},
// 角色展示
showRole: function showRole() {
var _this3 = this;
var self = this;
// 准备动画
var path = PathTool.getSpinePath(EID_READY, "action", false);
this.spReady.node.opacity = 255;
this.spReady.load(path, function (_e) {
if (!_e) {
self.spReady.action("action", false);
}
});
// 1秒后渐变切换
this.scheduleOnce(function () {
nx.tween.fadeOut(_this3.spReady, "", 0.5);
}, 1);
// 角色动画
path = PathTool.getSpinePath(this.scfgs.res_id, "show", false);
this.spRole.node.opacity = 0;
this.spRole.stop();
this.spRole.load(path, function (_e) {
if (!_e) {
_this3.spRole.action("action1", true);
} else {
_this3.spRole.stop();
}
});
// 0.8秒后渐变切换
this.scheduleOnce(function () {
nx.tween.fadeIn(_this3.spRole, "", 0.5, function () {
_this3.playVoice();
});
}, 0.8);
},
// 播放语音
playVoice: function playVoice() {
// 语音 SR&&SSR
var cfg = game.configs.partner_data.data_partner_base[this.cfgs.bid];
if (nx.dt.objEmpty(cfg) || nx.dt.strEmpty(cfg.voice)) {
return;
}
var path = cc.path.join("resDB/models", this.scfgs.res_id, "voice");
nx.audio.playVoice(path);
}
});
cc._RF.pop();