refactor(hero): 重构英雄属性同步机制和任务组件

- 在HeroAttrsComp中添加smc.updateHeroInfo调用以同步英雄数据
- 移除MissionComp中冗余的UI状态管理代码
- 在SingletonModuleComp中新增updateHeroInfo方法集中处理英雄数据同步
- 调整heroSet中英雄基础防御值为0
- 添加任务时间倒计时功能
This commit is contained in:
walkpan
2026-01-02 22:12:43 +08:00
parent a9e7b5c464
commit f5ded0d314
5 changed files with 2019 additions and 1932 deletions

View File

@@ -3,6 +3,7 @@ import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs";
import { BuffConf } from "../common/config/SkillSet";
import { HeroInfo, AttrSet } from "../common/config/heroSet";
import { HeroSkillsComp } from "./HeroSkills";
import { smc } from "../common/SingletonModuleComp";
interface talTrigger{
@@ -118,8 +119,9 @@ export class HeroAttrsComp extends ecs.Comp {
this.addBuff(buffConf);
}
}
smc.updateHeroInfo(this);
}
/*******************基础属性管理********************/
/*******************基础属性管理********************/
add_hp(value:number,isValue:boolean){
const oldHp = this.hp;
@@ -137,6 +139,7 @@ export class HeroAttrsComp extends ecs.Comp {
this.hp += addValue;
this.hp = Math.max(0, Math.min(this.hp, this.Attrs[Attrs.HP_MAX]));
this.dirty_hp = true; // ✅ 仅标记需要更新
smc.updateHeroInfo(this);
console.log(`[HeroAttrs] HP变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldHp.toFixed(1)} -> ${this.hp.toFixed(1)}`);
}
add_mp(value:number,isValue:boolean){
@@ -587,6 +590,7 @@ export class HeroAttrsComp extends ecs.Comp {
this.dirty_hp = false;
this.dirty_mp = false;
this.dirty_shield = false;
smc.updateHeroInfo(this);
}