Files
fc/dev/project/assets/Scripts/mod/partner/wings/cmp/cmp.wing.scientfic.wnd.js
T

203 lines
5.6 KiB
JavaScript
Raw Normal View History

2026-05-23 22:10:14 +08:00
/******************************************************************
*
* 僚机科研
*
******************************************************************/
const BridgeWindow = require( "bridge.window" );
const HeroController = require( "hero_controller" );
const BackpackController = require( "backpack_controller" );
const ElfinConst = require( "elfin_const" );
const ElfinEvent = require( "elfin_event" );
const ElfinController = require( "elfin_controller" );
const FID = require( "bridge.function.ids" );
cc.Class( {
extends: BridgeWindow,
properties: {
svcScientficList : {
default: [],
type : cc.Node,
displayName: "科研列表",
},
nodVipTip : {
default : null,
type: cc.Node,
displayName: "特权介绍",
},
nodBackMain: {
default : null,
type: cc.Node,
displayName: "返回主界面",
}
},
onLoad: function() {
this.bindGEvent( ElfinEvent.Get_Elfin_Hatch_Data_Event, this.freshWingList.bind( this) );
this.freshWingList();
nx.gui.setActive( this, "panel/vip", false );
let cmp = nx.gui.getComponent( this, "panel/vip", cc.Button );
if( cmp ){
cmp.interactable = false;
}
},
// 重载:参数打开
onOpenConfigs: function( _params ) {
if( this.nodBackMain ){
if( _params ){
nx.gui.setActive( this.nodBackMain, "", false );
}else{
nx.gui.setActive( this.nodBackMain, "", true );
}
}
},
// 重载:关闭前
onPreClosed: function() {
},
// 刷新所有的方案列表
freshWingList : function( _scheme ){
let Elfin = ElfinController.getInstance();
if( Elfin ) {
let model = Elfin.getModel();
let lst = _scheme || model.getElfinHatchList();
for (let i = 0; i < this.svcScientficList.length; i++) {
let item = this.svcScientficList[i];
let cmp = item.getComponent( "cmp.wing.scientfic.item" );
if( cmp ){
cmp.freshAll( lst[i] );
}
}
}
nx.gui.setActive( this.nodVipTip, "", false );
},
// 刷新技能介绍
freshSkillDesc : function( _mdata ){
if( !_mdata ){
return;
}
let key = _mdata;
let sfg = gdata( "sprite_data","data_elfin_data", key );
let cmp = this.skill.getComponent( "cmp.skill.base" );
if (sfg.skill) {
if( cmp ){
cmp.setData( sfg.skill );
}
}else{
if( cmp ){
cmp.setData( [] );
}
}
},
// 返回主场景
onBackToMain: function(){
const BC = BackpackController.getInstance();
if( BC ) {
BC.openMainWindow( false );
}
let HR = HeroController.getInstance();
ElfinController.getInstance().openWingScientfic( false );
HR.openHeroMainInfoWindow( false );
HR.openHeroBagWindow( false );
},
onTouchVip : function(){
nx.gui.setActive( this.nodVipTip, "", !nx.gui.find( this.nodVipTip ).active );
},
// 点击科研槽位
onTouchItem: function( _index ) {
let EC = ElfinController.getInstance();
let index = parseInt( _index );
if( EC ){
let cmp = this.svcScientficList[index].getComponent( "cmp.wing.scientfic.item" );
if( cmp ){
let info = cmp.getInfo();
// console.log( index + "当前的数据点击" + JSON.stringify( info ) );
if( info.is_open != 1 && info.id != 5 && info.id != 6 ){
EC.openElfinHatchUnlockPanel( true, info );
return;
}
if( info.is_open != 1 && ( info.id == 5 || info.id == 6 ) ){
this.onTouchVip();
return;
}
if( info.is_open == 1 && info.state == 0 ){
// 点击打开选择科研僚机面板
let setting = {};
setting.view_type = ElfinConst.Select_Type.Egg;
setting.hatch_id = index + 1;
EC.openElfSelectItemWindow( true, setting );
return;
}
if( info.is_open == 1 && info.state == 1 ){
// 点击提示
nx.tbox( nx.text.getKey( "elfin_hatch_item_1" ) );
return;
}
if( info.is_open == 1 && info.state == 2 ){
// 点击领取
EC.sender26506( ( index + 1 ) );
return;
}
}
}
// [26501]:{"sprite_hatch":[{"id":1,"is_open":1,"state":1,"do_id":10601,"all_end_time":1682555247}]}
// if( this.open == 0 ){
// nx.tbox( "unlocked" );
// }
// [server]#[recv] <<<[09:51:25][26506]:{"result":1,"msg":"","id":1,"awards":[{"item_bid":111002,"item_num":1}]}
// [server]#[recv] <<<[09:51:25][26501]:{"sprite_hatch":[{"id":1,"is_open":1,"state":0,"do_id":0,"all_end_time":1682743273}]}
},
onTouchActiveVip : function(){
this.onTouchVip();
nx.bridge.jumper.jump2Window( FID.Charge, { page: "shop" } );
}
} );