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];
|
||||
@@ -427,6 +426,18 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
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 {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -134,8 +134,6 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
*/
|
||||
private executeCast(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp,hset:HSSet): boolean {
|
||||
const heroAttrs=casterEntity.get(HeroAttrsComp)
|
||||
let isDSill=heroAttrs.tal_DSill.count > 0
|
||||
let isWFuny=heroAttrs.tal_WFuny.count > 0
|
||||
const config = SkillSet[s_uuid];
|
||||
if (!config) {
|
||||
console.error("[SACastSystem] 技能配置不存在:", s_uuid);
|
||||
@@ -165,14 +163,13 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
}, delay);
|
||||
|
||||
//风怒wfuny 只针对 普通攻击起效
|
||||
if (hset === HSSet.atk&&isWFuny){
|
||||
if (hset === HSSet.atk && heroAttrs.consumeTalent(TalEffet.WFUNY)){
|
||||
heroView.playSkillEffect(s_uuid);
|
||||
//需要再添加 风怒动画
|
||||
this.createSkill(s_uuid, heroView,targets);
|
||||
heroAttrs.tal_WFuny.count --
|
||||
}
|
||||
// 双技能 只针对 技能起效
|
||||
if(hset === HSSet.skill&&isDSill){
|
||||
if(hset === HSSet.skill && heroAttrs.consumeTalent(TalEffet.D_SKILL)){
|
||||
targets = this.sTargets(heroView, s_uuid);
|
||||
if (targets.length === 0) {
|
||||
console.warn("[SACastSystem] 没有找到有效目标");
|
||||
@@ -183,7 +180,6 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
heroView.scheduleOnce(() => {
|
||||
this.createSkill(s_uuid, heroView,targets);
|
||||
}, delay);
|
||||
heroAttrs.tal_DSill.count --
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +190,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
/**
|
||||
* 创建技能实体
|
||||
*/
|
||||
private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],damage:number=0) {
|
||||
private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],exr_dmg:number=0) {
|
||||
// 检查节点有效性
|
||||
if (!caster.node || !caster.node.isValid) {
|
||||
console.warn("[SACastSystem] 施法者节点无效");
|
||||
@@ -219,7 +215,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
const targetPos = targets[0]; // 使用第一个目标位置
|
||||
// console.log(`[SACastSystem]: ${s_uuid}, 起始位置: ${startPos}, 目标位置: ${targetPos}`);
|
||||
// 加载技能实体(包括预制体、组件初始化等)
|
||||
skill.load(startPos, parent, s_uuid, targetPos, caster,damage);
|
||||
skill.load(startPos, parent, s_uuid, targetPos, caster,exr_dmg);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -193,12 +193,10 @@ export class TalComp extends ecs.Comp {
|
||||
const heroAttrs=this.ent.get(HeroAttrsComp);
|
||||
switch(talent.effet){
|
||||
case TalEffet.WFUNY:
|
||||
heroAttrs.tal_WFuny.count += 1;
|
||||
heroAttrs.tal_WFuny.value = talent.value+talent.value_add;
|
||||
heroAttrs.addTalent(TalEffet.WFUNY, talent.value + talent.value_add);
|
||||
break;
|
||||
case TalEffet.D_SKILL:
|
||||
heroAttrs.tal_DSill.count += 1;
|
||||
heroAttrs.tal_DSill.value = talent.value+talent.value_add;
|
||||
heroAttrs.addTalent(TalEffet.D_SKILL, talent.value + talent.value_add);
|
||||
break;
|
||||
case TalEffet.BUFF:
|
||||
heroAttrs.addTalBuff(talent.uuid, talent.attrs, talent.vType, talent.value + talent.value_add);
|
||||
|
||||
Reference in New Issue
Block a user