refactor(hero): 重构天赋系统使用统一管理方式
- 将分散的天赋属性管理改为统一的Talents记录 - 添加addTalent和consumeTalent方法来管理天赋状态 - 修改技能系统使用新的天赋管理接口
This commit is contained in:
@@ -3,7 +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 { talConf, TalAttrs } from "../common/config/TalSet";
|
||||
|
||||
|
||||
interface talTrigger{
|
||||
value:number
|
||||
@@ -35,9 +35,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
shield: number = 0; // 当前护盾
|
||||
Attrs: any = []; // 最终属性数组(经过Buff计算后)
|
||||
NeAttrs: any = []; // 负面状态数组
|
||||
//=====================天赋触发标签=====================
|
||||
tal_DSill:talTrigger={value:0,count:0}
|
||||
tal_WFuny:talTrigger={value:0,count:0}
|
||||
Talents: Record<number, talTrigger> = {};
|
||||
BUFFS_TAL: Record<number, {count:number,BType:BType,attrIndex:number,value: number}> = {};
|
||||
|
||||
// ==================== 技能距离缓存 ====================
|
||||
@@ -80,6 +78,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.BUFFS = {};
|
||||
this.BUFFS_TEMP = {};
|
||||
this.BUFFS_TAL = {};
|
||||
this.Talents = {};
|
||||
|
||||
// 获取英雄配置
|
||||
const heroInfo = HeroInfo[this.hero_uuid];
|
||||
@@ -426,7 +425,19 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
delete this.BUFFS_TAL[t_uuid];
|
||||
this.recalculateSingleAttr(attrIndex);
|
||||
}
|
||||
|
||||
|
||||
addTalent(eff: number, value: number) {
|
||||
const t = this.Talents[eff] || { value: 0, count: 0 };
|
||||
t.value = value;
|
||||
t.count += 1;
|
||||
this.Talents[eff] = t;
|
||||
}
|
||||
consumeTalent(eff: number): boolean {
|
||||
const t = this.Talents[eff];
|
||||
if (!t || t.count <= 0) return false;
|
||||
t.count -= 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
reset() {
|
||||
// 重置为初始状态
|
||||
@@ -450,6 +461,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.BUFFS = {};
|
||||
this.BUFFS_TEMP = {};
|
||||
this.BUFFS_TAL = {};
|
||||
this.Talents = {};
|
||||
// 重置技能距离缓存
|
||||
this.maxSkillDistance = 0;
|
||||
this.minSkillDistance = 0;
|
||||
@@ -470,3 +482,5 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user