Files
heros/assets/script/game/map/HInfoComp.ts
panw c86fac4ce7 refactor(hero): 删除英雄属性增长与升级资源相关代码
- 移除 heroSet.ts 中职业属性增长配置和全局属性增长配置
- 删除计算英雄属性等级的相关函数及升级资源配置
- Hero.ts 中初始化英雄属性时,改用静态 HeroInfo 数据赋值
- map/HInfoComp.ts 中移除未使用的属性增长及升级资源相关导入
- 简化英雄属性管理,减少复杂成长逻辑,提高数据维护效率
2025-10-13 09:54:22 +08:00

71 lines
2.8 KiB
TypeScript

import { _decorator, Animation, AnimationClip, Component, Label, Node, resources, Sprite, SpriteFrame } from 'cc';
import { oops } from 'db://oops-framework/core/Oops';
import { UIID } from '../common/config/GameUIConfig';
import { getHeroList, HeroInfo, HType, HTypeName } from '../common/config/heroSet';
import { smc } from '../common/SingletonModuleComp';
import { GameEvent } from '../common/config/GameEvent';
import { NumberFormatter } from '../common/config/BoxSet';
import { Items } from '../common/config/Items';
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_heros[0]
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()
}
}