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

503 lines
18 KiB
JavaScript

/******************************************************************
*
* 伙伴详情
*
******************************************************************/
const BridgeWindow = require( "bridge.window" );
const HeroController = require( "hero_controller" );
const HeroEvent = require( "hero_event" );
const RoleController = require( "role_controller" );
const MenuWnd = require( "cmp.com.menu.wnd" );
const Slider = require( "cmp.slider.prog.selector" );
const HeroCalculate = require( "hero_calculate" );
// 标签页对应关系
const TabPage = [
{ tab: 0, key: "basic" }, // 升级
{ tab: 1, key: "star" }, // 升星
{ tab: 2, key: "inset" }, // 镶嵌
{ tab: 3, key: "artifact" }, // 镶嵌
{ tab: 4, key: "skin" }, // 皮肤
];
cc.Class( {
extends: MenuWnd,
properties: {
nodSwitch: { default: null, type: cc.Node },
nodSkin: { default: null, type: cc.Node },
fabSkin: { default: null, type: cc.Prefab },
cmpCounter: { default: null, type: Slider },
},
// 显示
onEnable: function() {
// 视图监听
this.vbind( [
[ "ShowPartner", this.onPartnerChanged.bind( this ) ]
] );
// 事件监听
// this.bindGEvent( HeroEvent.Hero_Data_Update, this.onUpdatePartner.bind( this ) );
this.bindGEvent( HeroEvent.Equip_Update_Event, this.onUpdateEquipments.bind( this ) );
this.bindGEvent( HeroEvent.Hero_Level_Up_Success_Event, this.onUpdateLevelUp.bind( this ) );
// this.bindGEvent( HeroEvent.Upgrade_Star_Success_Event, this.onUpdateStarUp.bind( this ) );
// this.bindGEvent( HeroEvent.Hero_Lock_Event, this.onUpdatePartner.bind( this ) );
// this.bindGEvent( HeroEvent.Hero_Get_Talent_Event, this.onUpdatePartner.bind( this ) );
},
// 隐藏
onDisable: function() {
// 视图监听解除
this.vunbind();
// 事件监听释放
this.unbindGEvents();
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
this._super( _params );
// 无效关闭
this.partner = _params.hero_vo;
if( nx.dt.objEmpty( this.partner ) ) {
this.scheduleOnce( () => {
this.close();
}, 0.05 );
}
this.partnerList = _params.hero_list;
if( nx.dt.arrEmpty( this.partnerList ) ) {
this.partnerList = [ this.partner ];
}
// 游标计算
let index = 0;
for( let i = 0; i < this.partnerList.length; ++i ) {
let tp = this.partnerList[ i ];
if( tp && tp.id == this.partner.id ) {
index = i;
break;
}
}
// 刷新
this.activeShow( index );
this.nodResult = nx.gui.find( this, "panel/base/clerk" );
this.initPos = this.nodResult.position;
this.initSlider();
this._super( _params );
},
initSlider: function() {
this.max_scale = 1.5;
this.min_scale = 0.5;
this.maxLen = 101;
this.minLen = 1;
this.can = true;
// 设置滚动条
this.cmpCounter.build( 1, 101, 50, ( _count ) => {
this.changeScale( _count );
} );
},
// 展示下一个
activeShow: function( _index ) {
if( this.curIndex == _index ||
_index < 0 ||
_index >= this.partnerList.length ) {
return;
}
// 更新展示
this.partner = this.partnerList[ _index ];
// 空伙伴不展示
if( !this.partner || nx.dt.objEmpty( this.partner ) ) {
return;
}
this.curIndex = _index;
// 菜单更新
// 星级低于3级不支持升星
let canup = ( this.partner.star >= 4 );
nx.gui.setActive( this.menu, "star", canup );
// 皮肤
let SkinPartners = game.configs.partner_skin_data.data_partner_bid_info;
let skins = SkinPartners[ this.partner.bid ];
nx.gui.setActive( this.menu, "skin", nx.dt.objNEmpty( skins ) );
// nx.gui.setActive( this.menu, "skin", false ); // 皮肤按钮 隐藏显示
// 战斗义肢
let need_star = game.configs.partner_holy_eqm_data.data_const.open_star_condition.val;
let need_level = game.configs.partner_holy_eqm_data.data_const.open_lev_condition.val;
let role = RoleController.getInstance().getRoleVo();
let need_world_level = game.configs.partner_holy_eqm_data.data_const.open_worldlev_condition.val;
let world_level = RoleController.getInstance().getModel().getWorldLev();
let canup2 = this.partner.star >= need_star && role.lev >= need_level && world_level >= need_world_level;
nx.gui.setActive( this.menu, "artifact", canup2 );
if( ( !canup && this.curKey == "star" ) || ( !canup2 && this.curKey == "artifact" ) ) {
let cmp = this.menu.getComponent( "nx.fx.togs" );
if( cmp ) {
cmp.togTo( 0 );
}
this.togMenu( this.defPage );
}
// 关注改变
nx.bridge.vset( "ShowPartner", this.partner );
},
onPartnerChanged: function( _vo ) {
if( _vo &&
this.partner &&
_vo.partner_id == this.partner.partner_id ) {
let need_star = game.configs.partner_holy_eqm_data.data_const.open_star_condition.val;
let need_world_level = game.configs.partner_holy_eqm_data.data_const.open_worldlev_condition.val;
let need_level = game.configs.partner_holy_eqm_data.data_const.open_lev_condition.val;
let role = RoleController.getInstance().getRoleVo();
let world_level = RoleController.getInstance().getModel().getWorldLev();
let canup2 = this.partner.star >= need_star && role.lev >= need_level && world_level >= need_world_level;
nx.gui.setActive( this.menu, "artifact", canup2 );
let calculate = HeroCalculate.getInstance();
let reds = calculate.checkPartnerRedPoint( this.partner, [ "lev", "eqm", "star", "insert" ] );
nx.mTip.openTip( "partner.partner.uplevel", ( reds[ 0 ] || reds[ 1 ] ) );
nx.mTip.openTip( "partner.partner.upstar", reds[ 2 ] );
nx.mTip.openTip( "partner.partner.insert", reds[ 3 ] );
}
},
togMenu: function( _key ) {
this._super( _key );
this.curKey = _key;
// 标准页
if( _key != "skin" ) {
nx.gui.setActive( this.nodSkin, "", false );
return;
}
// 新建
if( !this.cmpSkin ) {
let node = cc.instantiate( this.fabSkin );
node.parent = nx.gui.find( this.nodSkin );
this.cmpSkin = node.getComponent( "cmp.partner.skin" );
}
// 更新
nx.gui.setActive( this.nodSkin, "", true );
this.cmpSkin.setPartner( this.partner, () => {
// 皮肤改变手动刷新一下模型,这里不会主动改变
let base = nx.gui.getComponent( this, "panel/base", "cmp.partner.baseinfo" );
if( base ) {
base.freshSpines();
}
} );
},
// 队列切换
onTouchNext: function( _dir ) {
let index = ( _dir == 2 ) ? ( this.curIndex + 1 ) : ( this.curIndex - 1 );
index = ( index + this.partnerList.length ) % this.partnerList.length;
this.activeShow( index );
},
onBackToMain: function() {
let HR = HeroController.getInstance();
HR.openHeroMainInfoWindow( false );
HR.openHeroBagWindow( true );
},
onTouchSingleUpStar: function( _index ) {
let canup = this.partner.star >= 4;
if( canup ) {
this.togMenu( _index );
// this.onTogMenu( _index );
}
},
// 装备
onUpdateEquipments: function() {
nx.audio.playSFX( "audios/effects/equip" );
},
// 升级
onUpdateLevelUp: function() {
nx.audio.playSFX( "audios/effects/levelup" );
},
// // 升星
onUpdateStarUp: function() {
},
onDoAnim: function( _nod, pos, _show ) {
let tween = cc.tween( _nod )
.to( 0.5, { position: pos } )
.call( () => {
nx.gui.setActive( _nod, "", _show )
} )
.start()
return tween;
},
onDoAnimf: function( _nod, pos, _show ) {
nx.gui.setActive( _nod, "", _show );
let tween = cc.tween( _nod )
.to( 0.5, { position: pos } ).start()
return tween;
},
onDoAnimation: function() {
// let nods = [];
this.onDoAnim( this.nodResult, cc.v2( this.nodResult.position.x + 172, this.nodResult.position.y ), true );
let nodBase = nx.gui.find( this, "panel/smod" );
this.nodBasePos = nodBase.position;
// doAni( nodBase, true );
let base = this.onDoAnim( nodBase, cc.v2( nodBase.position.x - 500, nodBase.position.y ), false );
let nodPanel = nx.gui.find( this, "panel/panels" );
this.nodPanel = nodPanel.position;
let panel = this.onDoAnim( nodPanel, cc.v2( nodPanel.position.x + 1000, nodPanel.position.y ), false );
let menuPanel = nx.gui.find( this, "panel/menu" );
this.menuPanel = menuPanel.position;
// nods.push( menuPanel );
let menu = this.onDoAnim( menuPanel, cc.v2( menuPanel.position.x - 500, menuPanel.position.y ), false );
let skinPanel = nx.gui.find( this, "panel/skin" );
// doAni( skinPanel, false );
this.skinPanel = skinPanel.position;
let skin = this.onDoAnim( skinPanel, cc.v2( skinPanel.position.x - 500, skinPanel.position.y ), false );
let nodQa = nx.gui.find( this, "panel/base/qa" );
let touch = nx.gui.find( this, "panel/base/clerk/touch" );
let touchMove = this.onDoAnim( touch, cc.v2( touch.position.x, touch.position.y - 500 ), false );
// doAni( skinPanel, false );
this.nodQa = nodQa.position;
// let qa = this.onDoAnim( nodQa, cc.v2( nodQa.position.x , nodQa.position.y + 500 ), false );
let storyNod = nx.gui.find( this, "panel/base/infos" );
// doAni( skinPanel, false );
this.storyNod = storyNod.position;
let story = this.onDoAnim( storyNod, cc.v2( storyNod.position.x, storyNod.position.y - 200 ), false );
let backNod = nx.gui.find( this, "panel/back" );
// doAni( skinPanel, false );
let back = this.onDoAnim( backNod, cc.v2( backNod.position.x - 500, backNod.position.y ), false );
let backNods = nx.gui.find( this, "panel/base/back" );
// // doAni( skinPanel, false );
// let backs = this.onDoAnimf( backNods, cc.v2( backNods.position.x + 198, backNods.position.y ), true );
nx.tween.fadeIn( backNods, "", 0.3, () => {
nx.gui.getComponent( backNods, "", cc.Button ).interactable = true;
} );
let doNods = nx.gui.find( this, "panel/do" );
// doAni( skinPanel, false );
nx.gui.setActive( doNods, "ops", true );
let doNodsMove = this.onDoAnimf( doNods, cc.v2( doNods.position.x - 398, doNods.position.y ), true );
let opNod = nx.gui.find( this, "panel/base/ops" );
let opNodMove = this.onDoAnim( opNod, cc.v2( opNod.position.x, opNod.position.y + 200 ), false );
// cc.tween().then( base ).then( panel ).then( menu ).then( skin ).then( story ).start();
nx.tween.fadeOut( this, "panel/base/switch", 0.3, () => {
nx.gui.getComponent( this, "panel/base/switch/left", cc.Button ).interactable = false;
nx.gui.getComponent( this, "panel/base/switch/right", cc.Button ).interactable = false;
} );
let nod = nx.gui.find( this, "panel/base/skills/list" );
nx.tween.fadeOut( this, "panel/base/skills", 0.3, () => {
for (let i = 0; i < nod.children.length; i++) {
let nodss = nod.children[i];
let cmp = nx.gui.getComponent( nodss, "bg", cc.Button );
if( cmp ){
cmp.interactable = false;
}
}
} );
nx.tween.fadeOut( this, "panel/base/qa", 0.3 );
nx.tween.fadeOut( this, "panel/coin", 0.3 );
nx.tween.fadeOut( this, "panel/exp", 0.3 );
this.nodResult.on( cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this );
this.nodResult.on( cc.Node.EventType.TOUCH_END, this._onTouchEnd, this );
},
onDoAni: function() {
// let nods = [];
this.onDoAnimf( this.nodResult, cc.v2( this.initPos.x, this.initPos.y ), true );
this.cmpCounter.build( 1, 101, 50, ( _count ) => {
this.changeScale( _count );
} );
let nodBase = nx.gui.find( this, "panel/smod" );
let base = this.onDoAnimf( nodBase, cc.v2( nodBase.position.x + 500, nodBase.position.y ), true );
let nodPanel = nx.gui.find( this, "panel/panels" );
let panel = this.onDoAnimf( nodPanel, cc.v2( nodPanel.position.x - 1000, nodPanel.position.y ), true );
let menuPanel = nx.gui.find( this, "panel/menu" );
// nods.push( menuPanel );
let menu = this.onDoAnimf( menuPanel, cc.v2( menuPanel.position.x + 500, menuPanel.position.y ), true );
let skinPanel = nx.gui.find( this, "panel/skin" );
// doAni( skinPanel, false );
let skin = this.onDoAnimf( skinPanel, cc.v2( skinPanel.position.x + 500, skinPanel.position.y ), false );
let storyNod = nx.gui.find( this, "panel/base/infos" );
// doAni( skinPanel, false );
let story = this.onDoAnimf( storyNod, cc.v2( storyNod.position.x, storyNod.position.y + 200 ), true );
let nodQa = nx.gui.find( this, "panel/base/qa" );
// doAni( skinPanel, false );
let touch = nx.gui.find( this, "panel/base/clerk/touch" );
let touchMove = this.onDoAnimf( touch, cc.v2( touch.position.x, touch.position.y + 500 ), true );
let backNod = nx.gui.find( this, "panel/back" );
// doAni( skinPanel, false );
let back = this.onDoAnimf( backNod, cc.v2( backNod.position.x + 500, backNod.position.y ), true );
let opNod = nx.gui.find( this, "panel/base/ops" );
let opNodMove = this.onDoAnimf( opNod, cc.v2( opNod.position.x, opNod.position.y - 200 ), true );
let backNods = nx.gui.find( this, "panel/base/back" );
// doAni( skinPanel, false );
// let backs = this.onDoAnim( backNods, cc.v2( backNods.position.x - 198, backNods.position.y ), false );
nx.tween.fadeOut( backNods, "", 0.1, () => {
nx.gui.getComponent( backNods, "", cc.Button ).interactable = false;
} );
let doNods = nx.gui.find( this, "panel/do" );
// doAni( skinPanel, false );
let doNodsMove = this.onDoAnim( doNods, cc.v2( doNods.position.x + 398, doNods.position.y ), false );
nx.tween.fadeIn( this, "panel/base/switch", 0.3, () => {
nx.gui.getComponent( this, "panel/base/switch/left", cc.Button ).interactable = true;
nx.gui.getComponent( this, "panel/base/switch/right", cc.Button ).interactable = true;
} );
let nod = nx.gui.find( this, "panel/base/skills/list" );
nx.tween.fadeIn( this, "panel/base/skills", 0.3, () => {
for (let i = 0; i < nod.children.length; i++) {
let nodss = nod.children[i];
let cmp = nx.gui.getComponent( nodss, "bg", cc.Button );
if( cmp ){
cmp.interactable = true;
}
}
} );
nx.tween.fadeIn( this, "panel/base/qa", 0.3 );
nx.tween.fadeIn( this, "panel/coin", 0.3 );
nx.tween.fadeIn( this, "panel/exp", 0.3 );
},
_onTouchMove( touchEvent ) {
// let location = touchEvent.getLocation();
// // this.nodResult.anchor =
// this.nodResult.position = this.nodResult.parent.convertToNodeSpaceAR( location ); // 确定位置
// 偏移移动
let offset = touchEvent.getDelta();
let pos = this.nodResult.position;
this.nodResult.position = cc.v2( pos.x + offset.x, pos.y + offset.y );
this.can = false;
},
_onTouchEnd( touchEvent ) {
// 放下
this.can = true;
},
// 点击动画
onTouchSpine: function() {
if( this.can ) {
let cmp = nx.gui.getComponent( this.nodResult, "role", "nx.fx.spine" );
if( cmp ) {
// 屏蔽频繁点击打断
if( cmp.spAction != "action1" ) {
return;
}
// 播放 -> 常态
cmp.action( "action2", false, ( _event ) => {
if( _event == "complete" ) {
cmp.action( "action1", true );
}
} );
}
}
},
onTouchHide: function() {
let doNods = nx.gui.find( this, "panel/do/ops" );
nx.gui.setActive( doNods, "", !doNods.active );
},
changeScale: function( _count ) {
let scale = 0;
let dec = ( this.maxLen - this.minLen );
let rate = ( this.max_scale - this.min_scale ) / dec; // 计算比率 最大减去最小
// 计算滑动条值
let progress = _count * rate + + this.min_scale;
// 当滑动条数值为 最小时 显示的当前ui的缩放比例是0.1 (101 x 0.01)x + y = 1 (50 X 0.01)x + y = 0.5
if( progress <= this.min_scale ) {
scale = this.min_scale;
} else {
if( progress >= this.max_scale ) {
scale = this.max_scale;
} else {
scale = progress;
}
}
this.nodResult.scale = scale * 1;
},
} );