Files
fc/dev/project/assets/Scripts/mod/acts/partnertrial/cmp/cmp.act.partnertrial.wnd.js
T
2026-05-23 22:10:14 +08:00

172 lines
4.7 KiB
JavaScript

/******************************************************************
*
* 星界初體驗
*
******************************************************************/
const ActPopup = require( "act.popup.base" );
const NxSpine = require("nx.fx.spine");
const PathTool = require("pathtool");
const HeroTrialMod = require("act.partnertrial.mod");
const HeroConst = require("hero_const");
const 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( ) {
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(_params){
this._super( _params );
this.mod.send31004();
this.mod.send31005();
},
onPreClosed(){
// 活动监听解除
if( this.mod ) {
this.mod.vunbind( this );
}
},
playPv(flag){
if(flag && flag == 1){
this.touchPVPlay();
}
},
freshData(data){
if(nx.dt.objEmpty(data))return;
//英雄详情
let hero = data.partners[0];
if(!hero)return;
let h_config = game.configs.partner_data.data_partner_base[hero.bid];
if(h_config){
nx.gui.setString(this.infoNd,"name",h_config.name);
// 职业
let career = h_config.type || 4;
let icon = cc.path.join( "coms/images", "career" + career );
let campicon = cc.path.join( "coms/images", "camps" + h_config.camp_type );
let 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);
//模型加载
let res_path = PathTool.getSpinePath(h_config.bustid,"show",false);
this.roleSp.load(res_path,(_e)=>{
if(_e){
this.roleSp.stop();
}else{
this.roleSp.action("action1",true);
}
});
let trialHero = new HeroVo();
trialHero.updateHeroVo(hero);
//小模型
if(!this.sHero){
this.sHero = cc.instantiate(this.fabSmod);
this.sHero.parent = this.ndSmod;
this.sHero.y += 25;
}
let 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;
}
let 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
let cds = data.end_time - client.socket.getTime();
nx.gui.setCdTxt( this.cdTime, "", cds );
},
touchPVPlay(){
nx.bridge.createPanel("WndActPartnertrialPv",{bid:this.pv_bid});
},
touchHeroGet(){
if(this.tag_bid == 0)return;
this.mod.send31003(this.tag_bid,(_data)=>{
if(_data){
this.tag_bid = 0;
}
});
}
} );