refactor(战斗): 重构英雄与怪物属性系统,简化数据结构

- 移除 HeroSkillsComp 组件,将技能逻辑合并到 HeroAttrsComp
- 将属性从 Attrs 枚举映射改为 HeroAttrsComp 中的独立字段
- 为 HeroAttrsComp 添加攻击和技能冷却时间管理功能
- 统一英雄和怪物的属性初始化方式,简化配置数据
- 在 GameSet 中添加击退概率配置项
- 修复 SkillView 中属性名大小写错误
This commit is contained in:
walkpan
2026-03-11 23:13:21 +08:00
parent 9d6075be6e
commit a544f65d73
9 changed files with 85 additions and 202 deletions

View File

@@ -96,7 +96,8 @@ export class HeroAttrsComp extends ecs.Comp {
killed_count:number=0;
atk_id:number=0; //普通攻击技能id
skill_id:number=0; //技能攻击技能id
can_atk=false
can_skill=false
start(){
}
// ==================== BUFF 系统初始化 ====================
@@ -260,7 +261,17 @@ export class HeroAttrsComp extends ecs.Comp {
if (attr === Attrs.hp) this.dirty_hp = true;
if (attr === Attrs.shield) this.dirty_shield = true;
}
//======更新cd========//
updateCD(dt: number){
if(this.atk_id !=0&&!this.can_atk){
this.a_cd+=dt
if(this.a_cd >= this.a_cd_max) this.can_atk = true
}
if(this.skill_id !=0&&this.can_skill){
this.s_cd+=dt
if(this.s_cd >= this.s_cd_max) this.can_skill = true
}
}
// ==================== 临时 BUFF/DEBUFF 更新 ====================
/**
* 更新临时 buff/debuff 的剩余时间
@@ -419,7 +430,8 @@ export class HeroAttrsComp extends ecs.Comp {
this.killed_count =0;
this.atk_id = 0;
this.skill_id = 0;
this.can_atk=false
this.can_skill=false
// 重置脏标签
this.dirty_hp = false;
this.dirty_shield = false;