Files
fc/dev/project/assets/Scripts/mod/pve/adventure/cmp/cmp.adventure.fight.js
T
2026-05-23 22:10:14 +08:00

105 lines
2.6 KiB
JavaScript

const BridgeWindow = require( "bridge.window" );
const ADVCT = require("adventure_controller");
const ADEVT = require("adventure_event");
cc.Class({
extends: BridgeWindow,
properties: {
fabHero:{
default:null,
type:cc.Prefab
},
my:{
default:null,
type:cc.Node
},
monster:{
default:null,
type:cc.Node
},
myPower:{
default:null,
type:cc.Node
},
monsPower:{
default:null,
type:cc.Node
},
title:{
default:null,
type:cc.Node
}
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
this.ctrl = ADVCT.getInstance();
},
start () {
},
onOpenConfigs(params) {
this.model_type = this.ctrl.getPlayModel();
this.room_id = params.room_id;
this.evt_cfg = params.config;
this.monster_data = this.ctrl.getMonsterData();
this.setMyInfos();
if(this.monster_data){
this.setMonsterInfos();
}
},
onPreClosed() {
},
setMyInfos(){
let hero_data = this.ctrl.getFormPartnerByBid(this.ctrl.getCurLeader());
if(!hero_data)return;
let pre = cc.instantiate(this.fabHero);
pre.parent = this.my;
let cmp = pre.getComponent("cmp.adventure.partner");
let cfg = game.configs.partner_data.data_partner_base[hero_data.bid];
if(cmp && cfg.item_id){
hero_data.item_id = cfg.item_id;
hero_data.camp_type = cfg.camp_type;
cmp.rebind(0,hero_data,"");
}
nx.gui.setString(this.myPower,"num",hero_data.power);
},
setMonsterInfos(){
let hero_data = this.monster_data.guards[0];
if(!hero_data)return;
nx.gui.setString(this.title,"",cc.js.formatStr("Lv.%s %s",hero_data.lev,this.evt_cfg.name));
let pre = cc.instantiate(this.fabHero);
pre.parent = this.monster;
let cmp = pre.getComponent("cmp.adventure.partner");
let unit_data = gunitdata( "data_unit", hero_data.bid )
let cfg = game.configs.partner_data.data_partner_base[Number(unit_data.head_icon)];
if(cmp && cfg.item_id){
cfg.hp_per = hero_data.hp_per;
cfg.star = hero_data.star;
cmp.rebind(0,cfg,"");
}
nx.gui.setString(this.monsPower,"num",this.monster_data.guards_power);
},
onCLickFight(){
if(!this.monster_data)return;
this.ctrl.send29520([this.room_id],1,[],this.model_type);
},
// update (dt) {},
});