Files
heros/assets/script/game/map/HInfoComp.ts
walkpan 3f6b94af0e refactor(mission): 优化肉鸽关卡及怪物生成逻辑
- 将出战英雄配置由数组改为单个英雄编号,简化相关接口和数据结构
- 统一出战英雄设置和获取方法,移除冗余多英雄管理逻辑
- 增加怪物生成时的强度倍率参数,支持怪物属性随关卡进度递增调整
- 扩展肉鸽模式配置,实现关卡类型区分及怪物数量动态计算
- 新增随机事件系统,支持事件关卡随机触发宝箱、陷阱、增益、减益等事件
- 优化怪物生成流程,整合怪物配置、等级和强度倍率信息,增强游戏体验
2025-10-19 17:18:22 +08:00

67 lines
2.6 KiB
TypeScript

import { _decorator, Animation, AnimationClip, Component, Label, Node, resources, Sprite, SpriteFrame } from 'cc';
import { oops } from 'db://oops-framework/core/Oops';
import { getHeroList, HeroInfo, HType, HTypeName } from '../common/config/heroSet';
import { smc } from '../common/SingletonModuleComp';
const { ccclass, property } = _decorator;
@ccclass('HInfoComp')
export class HInfoComp extends Component {
h_uuid:number=0
name_node:any=null
type_node:any=null
ap_node:any=null
hp_node:any=null
def_node:any=null
start() {
this.name_node=this.node.getChildByName("hero").getChildByName("hname").getChildByName("name")
this.type_node=this.node.getChildByName("hero").getChildByName("hname").getChildByName("type")
this.ap_node=this.node.getChildByName("info").getChildByName("base").getChildByName("ap").getChildByName("num")
this.hp_node=this.node.getChildByName("info").getChildByName("base").getChildByName("hp").getChildByName("num")
this.def_node=this.node.getChildByName("info").getChildByName("base").getChildByName("def").getChildByName("num")
this.h_uuid=smc.fight_hero
this.update_data(this.h_uuid)
}
update(deltaTime: number) {
}
update_data(uuid:number){
this.h_uuid=uuid
let hero_data = HeroInfo[uuid]
console.log("[HInfoComp]:update_data",uuid,hero_data,this.node)
this.name_node.getComponent(Label).string=hero_data.name
this.type_node.getComponent(Label).string=HTypeName[hero_data.type]
this.ap_node.getComponent(Label).string=hero_data.ap.toString()
this.hp_node.getComponent(Label).string=hero_data.hp.toString()
this.def_node.getComponent(Label).string=hero_data.def.toString()
let anm_path=hero_data.path
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
this.node.getChildByName("hero").getComponent(Animation).addClip(clip);
this.node.getChildByName("hero").getComponent(Animation).play("idle");
});
}
next_hero(){
let heros=getHeroList()
let index = heros.indexOf(this.h_uuid);
index++
if(index==heros.length) index=0
let nextHero = heros[index];
this.update_data(nextHero)
}
prev_hero(){
let heros=getHeroList()
let index = heros.indexOf(this.h_uuid);
index--
if(index==-1) index=heros.length-1
let prevHero = heros[index];
this.update_data(prevHero)
}
close(){
oops.gui.removeByNode(this.node)
}
reset() {
this.node.destroy()
}
}