Files
fc/dev/project/assets/Scripts/mod/partner/cmps/basic/cmp.partner.baseinfo.js
T
2026-05-23 22:10:14 +08:00

297 lines
9.1 KiB
JavaScript

/******************************************************************
*
* 伙伴信息页 --- 基础展示
*
******************************************************************/
const BridgeComponent = require( "bridge.component" );
const NxSpine = require( "nx.fx.spine" );
const CpartnerBody = require( "cmp.partner.body.show" );
const HeroConst = require( "hero_const" );
const HeroEvent = require( "hero_event" );
const TipsController = require( "tips_controller" );
const HeroController = require( "hero_controller" );
const HomeMod = require( "home.mod" );
const FID = require( "bridge.function.ids" );
cc.Class( {
extends: BridgeComponent,
properties: {
spRole: { default: null, type: CpartnerBody },
spMini: { default: null, type: NxSpine },
nodInfo: { default: null, type: cc.Node },
nodLike: { default: null, type: cc.Node },
nodOps: { default: null, type: cc.Node },
nodTrial: { default: null, type: cc.Node },
},
// 显示
onLoad: function() {
this.partner = {};
// 视图监听
this.vbind( [
[ "ShowPartner", this.onPartnerChanged.bind( this ) ]
] );
// 事件监听
// this.bindGEvent( HeroEvent.Hero_Data_Update, this.onPartnerUpdate.bind( this ) );
},
onDestroy: function() {
this.partner = {};
nx.bridge.vset( "ShowPartner", {} );
this._super();
},
// 置空
setEmpty: function() {
if( this.spRole.spRole ) {
this.spRole.spRole.stop();
this.spRole.spRole.node.active = false;
this.spMini.stop();
this.spMini.node.active = false;
nx.gui.setActive( this, "qa", false );
nx.gui.setActive( this.nodInfo, "", false );
nx.gui.setActive( this.nodLike, "", false );
nx.gui.setActive( this.nodOps, "", false );
}
},
// 有伙伴数据更新
onPartnerUpdate: function( _vo ) {
if( _vo &&
this.partner &&
_vo.partner_id == this.partner.partner_id ) {
this.onPartnerChanged( _vo, true );
}
},
// 更新伙伴
onPartnerChanged: function( _partner, _update ) {
let update = false;
if( nx.dt.objNEmpty( this.partner ) ) {
if( this.partner.bid == _partner.bid ) {
update = true;
} else {
update = false;
}
}
this.partner = _partner;
// 置空
if( nx.dt.objEmpty( this.partner ) ) {
this.setEmpty();
return;
}
// if( this.spRole.spRole.node.active ) {
// update = true;
// }else{
// update = false;
// }
nx.gui.setActive( this.nodInfo, "", true );
nx.gui.setActive( this.nodLike, "", true );
nx.gui.setActive( this.nodOps, "", true );
nx.gui.setActive( this.nodOps, "like/like_popup", false );
nx.gui.setActive( this.nodInfo, "camp/img", false );
nx.gui.setActive( this.nodOps, "lock/off", this.partner.is_lock == 0 );
nx.gui.setActive( this.nodOps, "lock/on", this.partner.is_lock != 0 );
nx.gui.setActive( this.nodOps, "back", this.partner.lev != 1 );
let desc = game.configs.partner_data.data_partner_base[this.partner.bid];
// 单次设置
if( update != true ) {
// 名字
nx.gui.setString( this.nodInfo, "names/name", this.partner.name );
nx.gui.setString( this.nodInfo, "names/ename", this.partner.e_name );
// 品质
let path = cc.path.join( "coms/images", "mk_partner_qa" + this.partner.quality );
nx.gui.setSpriteFrame( this, "qa/qa", path );
let noddd = nx.gui.find( this, "qa/qa/spine" );
if( noddd ){
nx.gui.setActive( noddd, "", this.partner.quality == 5 );
}
// 職業
let career = this.partner.type || 4;
let icon = cc.path.join( "coms/images", "career" + career );
let name = nx.text.getKey( HeroConst.CareerName[ career ]) || nx.text.getKey( "lab_none" );
nx.gui.setString( this, "qa/career/career", nx.text.getKey( name ) );
nx.gui.setSpriteFrame( this, "qa/career/ico", icon );
// 描述
nx.gui.setString( this, "qa/desc/txt", desc ? desc.introduce_str : "" );
nx.gui.setActive( this, "qa/desc", desc );
// 阵营
path = cc.path.join( "prefab/partner/ui/camp" + this.partner.camp_type );
nx.gui.setString( this.nodInfo, "camp/img/txt", nx.text.getKey( "AnyNameCampName" + this.partner.camp_type ) );
nx.gui.setSpriteFrame( this.nodInfo, "camp", path );
// 动画
this.freshSpines();
}
// 等级
nx.gui.setString( this.nodInfo, "lv", "Lv." + this.partner.lev || 1 );
// 星级
let path = cc.path.join( "coms/images", "star" + this.partner.star );
nx.gui.setSpriteFrame( this.nodInfo, "stars", path );
nx.gui.setString( this.nodInfo, "power/nod/power", this.partner.power );
// 亲密度
if( !game.configs.favor_data ) {
nx.gui.setActive( this.nodOps, "gift", false );
nx.gui.setActive( this.nodOps, "like", false );
}
else {
let girl = HomeMod.getInstance().queryGirl( this.partner.bid );
if( girl ) {
nx.gui.setActive( this.nodOps, "gift", true );
nx.gui.setActive( this.nodOps, "like", true );
nx.gui.setString( this.nodOps, "like/count/txt", girl.intimacy_lev );
nx.gui.setString( this.nodOps, "like/like_popup/like_txts/lev", girl.intimacy_lev );
} else {
nx.gui.setActive( this.nodOps, "gift", false );
nx.gui.setActive( this.nodOps, "like", false );
}
}
nx.gui.setActive( this, "qa", true );
// 試用英雄
if(this.partner.trial_end_time > 0){
nx.gui.setActive(this.nodTrial,"",true);
let cds = this.partner.trial_end_time - client.socket.getTime();
nx.gui.setCdTxt( this.nodTrial, "txt", cds );
}else{
nx.gui.setActive(this.nodTrial,"",false);
}
},
// 刷新模型显示
freshSpines: function() {
let sinfo = nx.bridge.partner.getShowInfo( this.partner );
if( !sinfo ) {
this.spRole.spRole.stop();
this.spRole.spRole.node.active = false;
this.spMini.stop();
this.spMini.node.active = false;
return;
}
// 展示
this.spRole.setPartner( this.partner );
// 战斗迷你
this.spMini.load( sinfo.sp_model, ( _e ) => {
if( !_e ) {
this.spMini.action( "stand2", true );
this.spMini.node.active = true;
} else {
this.spMini.stop();
this.spMini.node.active = false;
}
} );
},
// 鎖定
onTouchLock: function() {
if( this.partner.resonate_lev != 0 ){
nx.tbox( "HomeCenterTip" );
return;
}
let lock = this.partner.is_lock;
HeroController.getInstance().sender11015( this.partner.partner_id, lock == 0 );
},
// 点赞
onTouchLike: function() {
nx.gui.setString( nx.gui.find( this.nodOps, "like/like_popup/like_txts/title" ), "", nx.text.getKey( "Current intimacy level" ) );
nx.gui.setActive( this.nodOps, "like/like_popup", !nx.gui.find( this.nodOps, "like/like_popup" ).active );
},
// 点赞
onTouchBack: function() {
this.unscheduleAllCallbacks();
if( this.partner.is_lock ){
nx.tbox( "LockTip" );
return;
}
nx.bridge.vset( "PartnerBack", this.partner );
nx.bridge.jumper.jump2Window( FID.Back );
let cmp = nx.gui.getComponent( this.node.parent.parent, "", "cmp.partner.info.wnd" );
if( cmp ) {
this.scheduleOnce( () => {
cmp.close();
}, 0.3 );
}
},
// 观察
onTouchWatch: function() {
HeroController.getInstance().openHeroLookDrawWindowTest( true, this.partner );
},
// 礼物
onTouchGift: function() {
nx.bridge.createPanel( "WndHome" );
this.scheduleOnce( () => {
nx.bridge.createPanel( "WndBedroom" );
}, 0.2 );
},
// 皮肤
onTouchSkin: function() {
},
// 人物介绍
onTouchStory: function() {
// const TC = TipsController.getInstance();
// let txt = nx.text.getKey( "story" + this.partner.bid );
// TC.showTextPanel( "PartnerStory", txt );
nx.bridge.createPanel( "WndLibraryPartner", {
bid: this.partner.bid,
auto: false
} );
},
onTouchCamp: function() {
this.unscheduleAllCallbacks();
nx.gui.setActive( this.nodInfo, "camp/img", true );
this.scheduleOnce( () => {
nx.gui.setActive( this.nodInfo, "camp/img", false );
}, 2 );
},
} );