From 2cdb25ac58c12ee32fb51e27598b160bdf1ab995 Mon Sep 17 00:00:00 2001 From: walkpan Date: Fri, 17 Oct 2025 22:02:23 +0800 Subject: [PATCH] =?UTF-8?q?refactor(skillSet):=20=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E5=8A=9F=E5=AE=8C=E6=88=90=20=E6=96=B0buff=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96DBuff=E4=B8=8EAttrs=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E5=8F=8A=E8=BD=AC=E6=8D=A2=E9=80=BB=E8=BE=91=20-=20=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E5=8C=96DBuff=E7=9A=84=E6=9E=9A=E4=B8=BE=E5=91=BD?= =?UTF-8?q?=E5=90=8D=EF=BC=8C=E4=BF=AE=E6=AD=A3=E5=B1=9E=E6=80=A7=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E5=85=B3=E7=B3=BB=20-=20=E7=BB=9F=E4=B8=80DBuff?= =?UTF-8?q?=E4=B8=8EAttrs=E7=9A=84=E5=8F=8C=E5=90=91=E6=98=A0=E5=B0=84?= =?UTF-8?q?=EF=BC=8C=E9=80=9A=E8=BF=87TransformBuffs=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E5=A4=84=E7=90=86=E8=BD=AC=E6=8D=A2=20-=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=97=A7=E7=9A=84getAttrFieldFromDebuff=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E7=94=A8=E6=9B=B4=E7=81=B5=E6=B4=BB=E7=9A=84?= =?UTF-8?q?=E6=98=A0=E5=B0=84=E6=95=B0=E7=BB=84=20-=20=E6=9B=B4=E6=96=B0At?= =?UTF-8?q?trs=E6=9E=9A=E4=B8=BE=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=A2=AB?= =?UTF-8?q?=E6=98=93=E4=BC=A4=E3=80=81=E9=98=B2=E6=8A=A4=E7=9B=BE=E7=AD=89?= =?UTF-8?q?=E6=96=B0=E5=B1=9E=E6=80=A7=20-=20=E9=87=8D=E6=96=B0=E8=B0=83?= =?UTF-8?q?=E6=95=B4AttrsType=E6=98=A0=E5=B0=84=EF=BC=8C=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E7=B1=BB=E5=9E=8B=E4=B8=80=E8=87=B4=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(hero): 重构Hero和Monster初始化属性及buff系统 - Hero初始化时完善基础属性赋值,新增基础移动速度与攻击距离 - Hero使用initAttrs替代initBuffsDebuffs,重构buff/debuff初始化流程 - Monster初始化简化,统一按Hero写法初始化基础属性和Attrs - 实现buff/debuff属性智能覆盖与叠加时长的改进逻辑 - 属性计算改用统一逻辑,支持数值型和百分比型准确计算 - 增加属性值范围限制,确保部分属性在合理区间内 refactor(heroViewComp): 优化buff/debuff管理及状态判断 - 统一buff和debuff的持久与临时管理字典及更新方法 - 优化临时buff/debuff的更新时间处理,自动触发属性重新计算 - 提供isStun和isFrost接口简化眩晕、冰冻状态判断 - 规范注释及代码格式,提升可读性和维护性 refactor(skillConComp): 优化眩晕与冰冻状态判断逻辑 - 移除遍历判断,改用HeroViewComp的isStun和isFrost方法 - 简化技能冷却更新逻辑,提升性能 chore(heroSet): 添加AttrSet枚举定义属性最大值限制 docs(rogueConfig): 更新说明文档中的属性枚举定义说明 - 将属性增强枚举由BuffAttr修改为Attrs,以保持一致性 --- assets/script/game/common/config/SkillSet.ts | 127 ++++----- assets/script/game/common/config/heroSet.ts | 4 +- assets/script/game/hero/Hero.ts | 13 +- assets/script/game/hero/HeroViewComp.ts | 268 +++++++++++-------- assets/script/game/hero/Mon.ts | 69 ++--- assets/script/game/hero/SkillConComp.ts | 6 +- assets/script/game/map/RogueConfig.ts | 36 ++- assets/script/game/skill/SkillEnt.ts | 26 +- assets/script/game/skill/SkillViewCom.ts | 7 +- 9 files changed, 280 insertions(+), 276 deletions(-) diff --git a/assets/script/game/common/config/SkillSet.ts b/assets/script/game/common/config/SkillSet.ts index a8ff847e..5c5182b4 100644 --- a/assets/script/game/common/config/SkillSet.ts +++ b/assets/script/game/common/config/SkillSet.ts @@ -101,17 +101,18 @@ export enum DBuff { SLOW = 2, //减速 - 对应Attrs.AS (攻击速度), BType.RATIO FROST = 3, //冰冻 - 对应Attrs.ICE_RES (冰冻抗性), BType.RATIO BURN = 4, //易伤 - 对应Attrs.DEF/MDEF (防御/魔防), BType.RATIO, 默认次数是5, 技能配置的devC是额外次数 - DEAS = 5, //减速 - 对应Attrs.AS (攻击速度), BType.RATIO, 直接+技能cd - DEHP = 6, //减hp - 对应Attrs.HP_MAX (最大生命值), BType.RATIO - DEAP = 7, //减atk - 对应Attrs.AP (攻击力), BType.RATIO - DEMGP = 8, //减魔法伤害 - 对应Attrs.MAP (魔法攻击力), BType.RATIO - BACK = 9, //击退概率 - 对应Attrs.KNOCKBACK (击退概率), BType.RATIO + AS = 5, //减速 - 对应Attrs.AS (攻击速度), BType.RATIO, 直接+技能cd + HP_MAX = 6, //减hp - 对应Attrs.HP_MAX (最大生命值), BType.RATIO + AP = 7, //减atk - 对应Attrs.AP (攻击力), BType.RATIO + MGP = 8, //减魔法伤害 - 对应Attrs.MAP (魔法攻击力), BType.RATIO + DEBACK = 9, //击退概率 - 对应Attrs.BACK (击退概率), BType.RATIO CRITICAL = 10, //-暴击率 - 对应Attrs.CRITICAL (暴击率), BType.RATIO CRIT_DAMAGE = 11, //-暴击伤害 - 对应Attrs.CRITICAL_DMG (暴击伤害), BType.RATIO DODGE = 12, //-闪避 - 对应Attrs.DODGE (闪避), BType.RATIO DBUFFUP=13, //edbuff效果提升 BUFF_DOWN = 14,// buff效果减弱 SPEED = 15, //移动速度下降 - 对应Attrs.MOVE_SPEED (移动速度), BType.RATIO + DEBURN= 16, //被攻击带易伤 } @@ -131,19 +132,23 @@ export enum Attrs { AS = 12, //攻击速度,直接减技能cd REFLICT = 13, //反伤比率 LIFESTEAL = 14, //吸血比率 - KNOCKBACK = 15, //攻击带击退概率 - CON_RES = 16, //控制抗性 - ICE_RES = 17, //冰冻抗性 - FIRE_RES = 18, //火抗性 - WIND_RES = 19, //风抗性 - ICE_POWER = 20, //冰冻伤害效果提升 - FIRE_POWER = 21,//火伤害效果提升 - WIND_POWER = 22,//风伤害效果提升 - SHIELD_UP = 23, //护盾效果提升 + BACK = 15, //攻击带击退概率 + DEBACK = 16, //被攻击击退概率 + CON_RES = 17, //控制抗性 + ICE_RES = 18, //冰冻抗性 + FIRE_RES = 19, //火抗性 + WIND_RES = 20, //风抗性 + ICE_POWER = 21, //冰冻伤害效果提升 + FIRE_POWER = 22,//火伤害效果提升 + WIND_POWER = 23,//风伤害效果提升 BUFF_UP = 24, //buff效果提升 DBUFF_UP=25, //debuff效果提升 DIS=26, //攻击距离 SPEED = 27, //移动速度加成,默认都是百分比 + SHIELD_UP = 28, //护盾效果提升 + BURN = 29, //攻击带易伤 + DEBURN = 30, //被攻击易伤 + } @@ -184,6 +189,8 @@ export const AttrsType: Record = { [Attrs.DEF]: BType.VALUE, // 防御 - 数值型 [Attrs.MDEF]: BType.VALUE, // 魔法防御 - 数值型 [Attrs.DIS]: BType.VALUE, // 攻击距离 - 数值型 + [Attrs.BURN]: BType.VALUE, // 易伤 - 数值型 + [Attrs.DEBURN]: BType.VALUE, // 被攻击易伤 - 数值型 // ========== 百分比型属性 ========== [Attrs.CRITICAL]: BType.RATIO, // 暴击率 - 百分比型 @@ -194,7 +201,7 @@ export const AttrsType: Record = { [Attrs.AS]: BType.RATIO, // 攻击速度 - 百分比型 [Attrs.REFLICT]: BType.RATIO, // 反伤比率 - 百分比型 [Attrs.LIFESTEAL]: BType.RATIO, // 吸血比率 - 百分比型 - [Attrs.KNOCKBACK]: BType.RATIO, // 击退概率 - 百分比型 + [Attrs.BACK]: BType.RATIO, // 击退概率 - 百分比型 [Attrs.CON_RES]: BType.RATIO, // 控制抗性 - 百分比型 [Attrs.ICE_RES]: BType.RATIO, // 冰冻抗性 - 百分比型 [Attrs.FIRE_RES]: BType.RATIO, // 火抗性 - 百分比型 @@ -202,10 +209,11 @@ export const AttrsType: Record = { [Attrs.ICE_POWER]: BType.RATIO, // 冰冻伤害效果提升 - 百分比型 [Attrs.FIRE_POWER]: BType.RATIO, // 火伤害效果提升 - 百分比型 [Attrs.WIND_POWER]: BType.RATIO, // 风伤害效果提升 - 百分比型 - [Attrs.SHIELD_UP]: BType.RATIO, // 护盾效果提升 - 百分比型 + [Attrs.DEBACK]:BType.RATIO, [Attrs.BUFF_UP]: BType.RATIO, // buff效果提升 - 百分比型 [Attrs.DBUFF_UP]: BType.RATIO, // debuff效果提升 - 百分比型 [Attrs.SPEED]: BType.RATIO, // 移动速度加成 - 百分比型 + [Attrs.SHIELD_UP]: BType.RATIO, // 护盾效果提升 - 百分比型 }; /** @@ -227,61 +235,44 @@ export const getAttrType = (attrType: Attrs): BType => { }; /** - * 获取 debuff 对应的属性字段 - * @param debuffType DBuff 类型 - * @returns 对应的 Attrs 字段,如果是状态类 debuff(只缓存)返回 -1 - * - * 扩展说明: - * 1. 普通 debuff:返回 Attrs 值(会直接修改属性) - * 2. 状态类 debuff:返回 -1(只缓存,不修改属性) - * - * 新增 DBuff 时: - * - 如果需要修改属性,在 debuffAttrMap 中添加映射: [DBuff.NEW]: Attrs.ATTR - * - 如果只需缓存状态,在 stateDebuffSet 中添加: DBuff.NEW + * DBuff 与 Attrs 的双向映射关系表 + * 格式:[DBuff, Attrs 或 -1(状态类)] */ -export const getAttrFieldFromDebuff = (debuffType: DBuff): number => { - // 状态类 debuff(只需缓存,不影响属性) - const stateDebuffSet = new Set([ - DBuff.STUN, - DBuff.FROST, - ]); - - // 检查是否是状态类 debuff - if (stateDebuffSet.has(debuffType)) { - return -1; // 表示只缓存,不影响属性 - } +const DEBUFF_ATTR_MAP: [DBuff, number][] = [ + [DBuff.STUN, -1], // 眩晕 - 状态类 + [DBuff.SLOW, Attrs.SPEED], // 减速 -> 速度 + [DBuff.FROST, -1], // 冰冻 - 状态类 + [DBuff.DEBURN, Attrs.DEBURN], // 被易伤 -> 被易伤 + [DBuff.BURN, Attrs.BURN], // 易伤 -> 易伤效果 + [DBuff.AS, Attrs.AS], // 减cd -> 攻击速度 + [DBuff.HP_MAX, Attrs.HP_MAX], // 减hp -> 最大生命值 + [DBuff.AP, Attrs.AP], // 减atk -> 攻击力 + [DBuff.MGP, Attrs.MAP], // 减魔法 -> 魔法攻击力 + [DBuff.DEBACK, Attrs.DEBACK], // 被击退 -> 被击退概率 + [DBuff.CRITICAL, Attrs.CRITICAL], // -暴击率 -> 暴击率 + [DBuff.CRIT_DAMAGE, Attrs.CRITICAL_DMG], // -暴击伤害 -> 暴击伤害 + [DBuff.DODGE, Attrs.DODGE], // -闪避 -> 闪避 + [DBuff.DBUFFUP, Attrs.DBUFF_UP], // debuff提升 -> debuff提升 + [DBuff.BUFF_DOWN, Attrs.BUFF_UP], // buff减弱 -> buff效果 + [DBuff.SPEED, Attrs.SPEED], // 移动速度下降 -> 移动速度 +]; - // ==================== 普通 Debuff 到 Attrs 的完整映射表 ==================== - // 格式: [DBuff 类型]: Attrs 属性(会直接修改属性值) - // 注意:新增普通 debuff 时,在此添加映射关系即可 - const debuffAttrMap: Record = { - [DBuff.STUN]: Attrs.CON_RES, // 眩晕 -> 控制抗性 - [DBuff.SLOW]: Attrs.AS, // 减速 -> 攻击速度 - [DBuff.FROST]: Attrs.ICE_RES, // 冰冻 -> 冰冻抗性 - [DBuff.BURN]: Attrs.DEF, // 易伤 -> 防御 - [DBuff.DEAS]: Attrs.AS, // 减cd -> 攻击速度 - [DBuff.DEHP]: Attrs.HP_MAX, // 减hp -> 最大生命值 - [DBuff.DEAP]: Attrs.AP, // 减atk -> 攻击力 - [DBuff.DEMGP]: Attrs.MAP, // 减魔法 -> 魔法攻击力 - [DBuff.BACK]: Attrs.KNOCKBACK, // 击退 -> 击退概率 - [DBuff.CRITICAL]: Attrs.CRITICAL, // -暴击率 -> 暴击率 - [DBuff.CRIT_DAMAGE]: Attrs.CRITICAL_DMG, // -暴击伤害 -> 暴击伤害 - [DBuff.DODGE]: Attrs.DODGE, // -闪避 -> 闪避 - [DBuff.DBUFFUP]: Attrs.DBUFF_UP, // debuff提升 -> debuff提升 - [DBuff.BUFF_DOWN]: Attrs.BUFF_UP, // buff减弱 -> buff效果 - [DBuff.SPEED]: Attrs.SPEED, // 移动速度下降 -> 移动速度 - - }; - - const attrField = debuffAttrMap[debuffType]; - - // 如果映射不存在,打印警告信息(方便开发调试) - if (attrField === undefined) { - console.warn(`[SkillSet] 未知的 DBuff 类型: ${debuffType},请在 getAttrFieldFromDebuff 添加映射关系或放入 stateDebuffSet`); - return -1; +/** + * 双向转换:DBuff ⇄ Attrs + * @param key DBuff 或 Attrs 枚举值 + * @param isDebuff true: key 是 DBuff, false: key 是 Attrs + * @returns 对应的转换值,未找到则返回 -1 + */ +export const TransformBuffs = (key: number, isDebuff: boolean): number => { + if (isDebuff) { + // DBuff → Attrs + const found = DEBUFF_ATTR_MAP.find(([debuff]) => debuff === key); + return found ? found[1] : -1; + } else { + // Attrs → DBuff(只返回第一个匹配) + const found = DEBUFF_ATTR_MAP.find(([, attr]) => attr === key); + return found ? found[0] : -1; } - - return attrField; }; /* diff --git a/assets/script/game/common/config/heroSet.ts b/assets/script/game/common/config/heroSet.ts index d70607e7..caf3dea2 100644 --- a/assets/script/game/common/config/heroSet.ts +++ b/assets/script/game/common/config/heroSet.ts @@ -26,7 +26,9 @@ import { debuff } from "../../skills/debuff" * 0:战士 1:远程 2:法师 * * */ - +export enum AttrSet { + ATTR_MAX = 85, +} export enum HType { warrior = 0, remote = 1, diff --git a/assets/script/game/hero/Hero.ts b/assets/script/game/hero/Hero.ts index 05932c69..2c79b9cd 100644 --- a/assets/script/game/hero/Hero.ts +++ b/assets/script/game/hero/Hero.ts @@ -76,16 +76,19 @@ export class Hero extends ecs.Entity { hv.base_def=hero.def hv.base_hp=hero.hp hv.base_mp=hero.mp - hv.hp=hv.base_hp - hv.mp=hv.base_mp + hv.base_dis=hero.dis + hv.base_speed=hero.speed hv.Attrs=getAttrs() - hv.Attrs[Attrs.HP_MAX]=hv.base_hp - hv.Attrs[Attrs.MP_MAX]=hv.base_mp + hv.hp=hv.Attrs[Attrs.HP_MAX]=hv.base_hp + hv.mp=hv.Attrs[Attrs.MP_MAX]=hv.base_mp hv.Attrs[Attrs.DEF]=hv.base_def hv.Attrs[Attrs.AP]=hv.base_ap hv.Attrs[Attrs.MAP]=hv.base_map + hv.Attrs[Attrs.SPEED]=hero.speed + hv.Attrs[Attrs.DIS]=hero.dis + // 初始化 buff/debuff 系统 - hv.initBuffsDebuffs(); + hv.initAttrs(); return hv } } \ No newline at end of file diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index a65b37b4..a19a2b68 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -5,36 +5,36 @@ import { HeroSpine } from "./HeroSpine"; import { BoxSet, FacSet } from "../common/config/BoxSet"; import { smc } from "../common/SingletonModuleComp"; import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; -import { Attrs, DBuff, SkillSet, BType, BuffConf, DbuffConf, getAttrFieldFromDebuff } from "../common/config/SkillSet"; +import { Attrs, DBuff, SkillSet, BType, BuffConf, DbuffConf, TransformBuffs, AttrsType } from "../common/config/SkillSet"; import { BuffComp } from "./BuffComp"; import { oops } from "db://oops-framework/core/Oops"; import { GameEvent } from "../common/config/GameEvent"; import { FightSet, TooltipTypes } from "../common/config/Mission"; import { RandomManager } from "db://oops-framework/core/common/random/RandomManager"; -import { HeroInfo, HeroUpSet } from "../common/config/heroSet"; +import { AttrSet, HeroInfo, HeroUpSet } from "../common/config/heroSet"; const { ccclass, property } = _decorator; /** * ==================== BUFF 系统使用说明 ==================== * - * 1. 系统架构? - * - BUFF_V/BUFFS_V: 数值型 buff(持?临时? - * - BUFF_R/BUFFS_R: 百分比型 buff(持?临时? - * - DBUFF_V/DBUFFS_V: 数值型 debuff(持?临时? - * - DBUFF_R/DBUFFS_R: 百分比型 debuff(持?临时? + * 1. 系统架构 + * - BUFF_V/BUFFS_V: 数值型 buff(持临时 + * - BUFF_R/BUFFS_R: 百分比型 buff(持临时 + * - DBUFF_V/DBUFFS_V: 数值型 debuff(持临时 + * - DBUFF_R/DBUFFS_R: 百分比型 debuff(持临时 * - * 2. 智能覆盖规则? + * 2. 智能覆盖规则 * - 值更小:不添加(弱效果不覆盖强效果) - * - 值相同且临时:叠加时? - * - 值更大:更新为新值(临时则更新值和时间? + * - 值相同且临时:叠加时 + * - 值更大:更新为新值(临时则更新值和时间 * - * 3. 性能优化? - * - 增量计算:添?删除时只重算受影响的属�? - * - 批量计算:initBuffsDebuffs() 中使?recalculateAttrs() 一次性计算所? + * 3. 性能优化 + * - 增量计算:添删除时只重算受影响的属 + * - 批量计算:initBuffsDebuffs() 中使recalculateAttrs() 一次性计算所 */ /** 角色显示组件 */ -@ccclass('HeroViewComp') // 定义?Cocos Creator 组件 -@ecs.register('HeroView', false) // 定义?ECS 组件 +@ccclass('HeroViewComp') // 定义Cocos Creator 组件 +@ecs.register('HeroView', false) // 定义ECS 组件 export class HeroViewComp extends CCComp { BUFFCOMP:BuffComp=null! as: HeroSpine = null! @@ -43,7 +43,7 @@ export class HeroViewComp extends CCComp { hero_name : string = "hero"; lv:number =1; scale: number = 1; /** 角色阵营 1:hero -1 :mon */ - type: number = 0; /**角色类型 0近战-需要贴?1远程-保持距离 2辅助 */ + type: number = 0; /**角色类型 0近战-需要贴1远程-保持距离 2辅助 */ fac:number=0; //阵营 0:hero 1:monster box_group:number = BoxSet.HERO; is_dead:boolean = false; //是否摧毁 @@ -58,27 +58,27 @@ export class HeroViewComp extends CCComp { is_kalami:boolean =false; mp: number = 100; - hp: number = 100; /** 血?*/ - shield:number=0; //当前护甲? -/** 基础属�?有初始值的基础属�?后续Attrs 属性计算时用到*/ - base_ap: number = 0; //基础攻击? + hp: number = 100; /** 血*/ + shield:number=0; //当前护甲 +/** 基础属有初始值的基础属后续Attrs 属性计算时用到*/ + base_ap: number = 0; //基础攻击 base_map: number = 0; base_def: number = 5; base_hp: number = 100; base_mp: number = 100; base_speed: number = 100; /** 角色移动速度 */ - + base_dis: number = 100; Attrs:any=[] - // Buff/Debuff 字典结构,通过属性索引直接访? + // Buff/Debuff 字典结构,通过属性索引直接访 // 结构: { [attrIndex: number]: { value: number, remainTime?: number } } - DBUFF_V: Record = {} // 持久型数?debuff + DBUFF_V: Record = {} // 持久型数debuff DBUFF_R: Record = {} // 持久型百分比 debuff - BUFF_V: Record = {} // 持久型数?buff + BUFF_V: Record = {} // 持久型数buff BUFF_R: Record = {} // 持久型百分比 buff - DBUFFS_V: Record = {} // 临时型数?debuff + DBUFFS_V: Record = {} // 临时型数debuff DBUFFS_R: Record = {} // 临时型百分比 debuff - BUFFS_V: Record = {} // 临时型数?buff + BUFFS_V: Record = {} // 临时型数buff BUFFS_R: Record = {} // 临时型百分比 buff atk_count: number = 0; @@ -102,7 +102,7 @@ export class HeroViewComp extends CCComp { this.on(GameEvent.FightEnd,this.do_fight_end,this) const collider = this.node.getComponent(BoxCollider2D); this.scheduleOnce(()=>{ - if (collider) collider.enabled = true; // 先禁? + if (collider) collider.enabled = true; // 先禁 },1) // let anm = this.node.getChildByName("anm") // anm.setScale(anm.scale.x*0.8,anm.scale.y*0.8); @@ -118,17 +118,17 @@ export class HeroViewComp extends CCComp { if(this.is_boss){ this.node.getChildByName("top").position=v3(this.node.position.x,this.node.position.y+100,0) } - /* 显示角色血?*/ + /* 显示角色血*/ this.node.getChildByName("top").getChildByName("hp").active = true; this.BUFFCOMP.show_shield(this.shield,this.Attrs[Attrs.SHIELD_MAX]) } - // ==================== BUFF系统初始?==================== + // ==================== BUFF系统初始==================== /** - * 初始化角色的 buff ?debuff - * ?HeroInfo 读取初始配置,建立属性系? + * 初始化角色的 buff debuff + * HeroInfo 读取初始配置,建立属性系 */ - initBuffsDebuffs() { + initAttrs() { // 清空现有 buff/debuff this.BUFF_V = {}; this.BUFFS_V = {}; @@ -143,19 +143,28 @@ export class HeroViewComp extends CCComp { if (!heroInfo) return; - // 1. 重置为基础? + // 1. 重置为基础 this.Attrs[Attrs.HP_MAX] = this.base_hp; this.Attrs[Attrs.MP_MAX] = this.base_mp; this.Attrs[Attrs.DEF] = this.base_def; this.Attrs[Attrs.AP] = this.base_ap; this.Attrs[Attrs.MAP] = this.base_map; this.Attrs[Attrs.SPEED] = this.base_speed; - this.Attrs[Attrs.SHIELD_MAX] = 0; // 护盾默认?0 + this.Attrs[Attrs.DIS] = this.base_dis; - // 2. 初始化其他属性(无初始值的? + // 2. 初始化其他属性(无初始值的 for (const attrKey in this.Attrs) { const attrIndex = parseInt(attrKey); - if(attrIndex !== Attrs.HP_MAX && attrIndex !== Attrs.MP_MAX && attrIndex !== Attrs.DEF && attrIndex !== Attrs.AP && attrIndex !== Attrs.MAP && attrIndex !== Attrs.SPEED) { + if( + attrIndex !== Attrs.HP_MAX && + attrIndex !== Attrs.MP_MAX&& + attrIndex !== Attrs.DEF && + attrIndex !== Attrs.AP && + attrIndex !== Attrs.MAP && + attrIndex !== Attrs.SPEED && + attrIndex !== Attrs.DIS + + ) { this.Attrs[attrIndex] = 0; } } @@ -165,7 +174,6 @@ export class HeroViewComp extends CCComp { this.addBuff(buffConf); } } - // 加载初始 debuff if (heroInfo.debuff && heroInfo.debuff.length > 0) { for (const dbuffConf of heroInfo.debuff) { @@ -176,27 +184,27 @@ export class HeroViewComp extends CCComp { // ==================== BUFF管理 ==================== /** * 添加 buff 效果(智能覆盖) - * @param buffConf buff 配置 (来自 SkillSet.BuffConf ?heroSet.buff) + * @param buffConf buff 配置 (来自 SkillSet.BuffConf heroSet.buff) * - * 智能覆盖规则? - * 1. 值更小:不添? - * 2. 值相同且都是临时:叠加时? - * 3. 值更大:更新为新值(临时则更新值和时间? + * 智能覆盖规则 + * 1. 值更小:不添 + * 2. 值相同且都是临时:叠加时 + * 3. 值更大:更新为新值(临时则更新值和时间 */ addBuff(buffConf: BuffConf) { const isValue = buffConf.BType === BType.VALUE; const isPermanent = buffConf.time === 0; const attrIndex = buffConf.buff; - // 根据类型选择对应?buff 字典 + // 根据类型选择对应buff 字典 const permanentBuffs = isValue ? this.BUFF_V : this.BUFF_R; const temporaryBuffs = isValue ? this.BUFFS_V : this.BUFFS_R; if (isPermanent) { - // 添加持久?buff + // 添加持久buff const existing = permanentBuffs[attrIndex]; if (existing) { - // 值更小,不添? + // 值更小,不添 if (buffConf.value <= existing.value) { return; } @@ -207,16 +215,16 @@ export class HeroViewComp extends CCComp { permanentBuffs[attrIndex] = { value: buffConf.value }; } } else { - // 添加临时?buff + // 添加临时buff const existing = temporaryBuffs[attrIndex]; if (existing) { if (buffConf.value < existing.value) { - // 值更小,不添? + // 值更小,不添 return; } else if (buffConf.value === existing.value) { // 值相同,叠加时间 existing.remainTime += buffConf.time; - return; // 时间叠加不需要重算属? + return; // 时间叠加不需要重算属 } else { // 值更大,更新值和时间 existing.value = buffConf.value; @@ -231,44 +239,40 @@ export class HeroViewComp extends CCComp { } } - // 只重新计算受影响的属? this.recalculateSingleAttr(buffConf.buff); } // ==================== DEBUFF管理 ==================== /** * 添加 debuff 效果(智能覆盖) - * @param dbuffConf debuff 配置 (来自 SkillSet.DbuffConf ?heroSet.debuff) + * @param dbuffConf debuff 配置 (来自 SkillSet.DbuffConf heroSet.debuff) * - * 支持两种 debuff? - * 1. 属性型 debuff:直接修改属性值(有对应的 Attrs? + * 支持两种 debuff + * 1. 属性型 debuff:直接修改属性值(有对应的 Attrs * 2. 状态型 debuff:只缓存状态(无对应的 Attrs,用于状态检查) * - * 智能覆盖规则? - * 1. 值更小:不添? - * 2. 值相同且都是临时:叠加时? - * 3. 值更大:更新为新值(临时则更新值和时间? + * 智能覆盖规则 + * 1. 值更小:不添 + * 2. 值相同且都是临时:叠加时 + * 3. 值更大:更新为新值(临时则更新值和时间 */ addDebuff(dbuffConf: DbuffConf) { - // 获取 debuff 对应的属性字? - // attrField = -1 表示状态类 debuff(只缓存,不修改属性) - // attrField >= 0 表示属性类 debuff(会修改属性) - const attrField = getAttrFieldFromDebuff(dbuffConf.debuff); + // 获取 debuff 对应的属性字 + const isValue = dbuffConf.BType === BType.VALUE; const isPermanent = dbuffConf.time === 0; - // 根据类型选择对应?debuff 字典 + // 根据类型选择对应debuff 字典 const permanentDebuffs = isValue ? this.DBUFF_V : this.DBUFF_R; const temporaryDebuffs = isValue ? this.DBUFFS_V : this.DBUFFS_R; - // 状态类 debuff 使用 debuff 类型作为 key,属性类 debuff 使用 attrField 作为 key - const key = attrField >= 0 ? attrField : dbuffConf.debuff; + const key = dbuffConf.debuff; if (isPermanent) { - // 添加持久?debuff + // 添加持久debuff const existing = permanentDebuffs[key]; if (existing) { - // 值更小,不添? + // 值更小,不添 if (dbuffConf.value <= existing.value) { return; } @@ -279,16 +283,16 @@ export class HeroViewComp extends CCComp { permanentDebuffs[key] = { value: dbuffConf.value }; } } else { - // 添加临时?debuff + // 添加临时debuff const existing = temporaryDebuffs[key]; if (existing) { if (dbuffConf.value < existing.value) { - // 值更小,不添? + // 值更小,不添 return; } else if (dbuffConf.value === existing.value) { // 值相同,叠加时间 existing.remainTime += dbuffConf.time; - return; // 时间叠加不需要重算属? + return; // 时间叠加不需要重算属 } else { // 值更大,更新值和时间 existing.value = dbuffConf.value; @@ -302,20 +306,24 @@ export class HeroViewComp extends CCComp { }; } } - + let attrField = TransformBuffs(dbuffConf.debuff,true); // 只重新计算受影响的属性(状态类 debuff 不需要计算) - if (attrField >= 0) { + if (attrField > 0 ) { this.recalculateSingleAttr(attrField); } } - // ==================== 属性计算系?==================== + // ==================== 属性计算系==================== /** - * 重新计算单个属�? - * @param attrIndex 属性索? + * 重新计算单个属性 + * @param attrIndex 属性索引 + * + * 计算公式: + * - 数值型属性:最终值 = (基础值 + 数值型buff - 数值型debuff) × (1 + 百分比buff/100 - 百分比debuff/100) + * - 百分比型属性:最终值 = 基础值 + 数值型buff - 数值型debuff + 百分比buff - 百分比debuff */ private recalculateSingleAttr(attrIndex: number) { - // 1. 重置为基础? + // 1. 获取基础值 const baseValues: Record = { [Attrs.HP_MAX]: this.base_hp, [Attrs.MP_MAX]: this.base_mp, @@ -326,46 +334,68 @@ export class HeroViewComp extends CCComp { [Attrs.SHIELD_MAX]: 0 }; - this.Attrs[attrIndex] = baseValues[attrIndex] !== undefined ? baseValues[attrIndex] : 0; + const baseVal = baseValues[attrIndex] !== undefined ? baseValues[attrIndex] : 0; - // 2. 应用数值型 buff - 直接访问 + // 2. 收集所有数值型 buff/debuff + let totalValue = baseVal; + + // Buff:直接使用 Attrs 索引 if (this.BUFF_V[attrIndex]) { - this.Attrs[attrIndex] += this.BUFF_V[attrIndex].value; + totalValue += this.BUFF_V[attrIndex].value; } if (this.BUFFS_V[attrIndex]) { - this.Attrs[attrIndex] += this.BUFFS_V[attrIndex].value; + totalValue += this.BUFFS_V[attrIndex].value; } - - // 3. 应用百分比型 buff - 直接访问 - const baseVal = baseValues[attrIndex] !== undefined ? baseValues[attrIndex] : this.Attrs[attrIndex]; + + // Debuff:需要通过 DBuff key 查找 + const deKey = TransformBuffs(attrIndex, false); + if (deKey !== -1) { + if (this.DBUFF_V[deKey]) { + totalValue -= this.DBUFF_V[deKey].value; + } + if (this.DBUFFS_V[deKey]) { + totalValue -= this.DBUFFS_V[deKey].value; + } + } + // 3. 收集所有百分比型 buff/debuff + let totalRatio = 0; // 总百分比(可正可负) + + // Buff:直接使用 Attrs 索引 if (this.BUFF_R[attrIndex]) { - this.Attrs[attrIndex] += Math.floor(baseVal * (this.BUFF_R[attrIndex].value / 100)); + totalRatio += this.BUFF_R[attrIndex].value; } if (this.BUFFS_R[attrIndex]) { - this.Attrs[attrIndex] += Math.floor(baseVal * (this.BUFFS_R[attrIndex].value / 100)); + totalRatio += this.BUFFS_R[attrIndex].value; + } + + // Debuff:需要通过 DBuff key 查找 + if (deKey !== -1) { + if (this.DBUFF_R[deKey]) { + totalRatio -= this.DBUFF_R[deKey].value; + } + if (this.DBUFFS_R[deKey]) { + totalRatio -= this.DBUFFS_R[deKey].value; + } + } + + + // 4. 根据属性类型计算最终值 + const attrType = AttrsType[attrIndex]; + const isRatioAttr = attrType === BType.RATIO; + + if (isRatioAttr) { + // 百分比型属性:直接加减 + this.Attrs[attrIndex] = totalValue + totalRatio; + } else { + // 数值型属性:(基础值+数值) × (1 + 百分比/100) + this.Attrs[attrIndex] = Math.floor(totalValue * (1 + totalRatio / 100)); } - // 4. 应用数值型 debuff - 直接访问 - if (this.DBUFF_V[attrIndex]) { - this.Attrs[attrIndex] -= this.DBUFF_V[attrIndex].value; - } - if (this.DBUFFS_V[attrIndex]) { - this.Attrs[attrIndex] -= this.DBUFFS_V[attrIndex].value; - } - - // 5. 应用百分比型 debuff - 直接访问 - if (this.DBUFF_R[attrIndex]) { - this.Attrs[attrIndex] -= Math.floor(baseVal * (this.DBUFF_R[attrIndex].value / 100)); - } - if (this.DBUFFS_R[attrIndex]) { - this.Attrs[attrIndex] -= Math.floor(baseVal * (this.DBUFFS_R[attrIndex].value / 100)); - } - - // 6. 确保属性值合? + // 5. 确保属性值合理 this.clampSingleAttr(attrIndex); } /** - * 确保单个属性值合? + * 确保单个属性值合 */ private clampSingleAttr(attrIndex: number) { switch(attrIndex) { @@ -376,26 +406,25 @@ export class HeroViewComp extends CCComp { case Attrs.DEF: case Attrs.AP: case Attrs.MAP: - this.Attrs[attrIndex] = Math.max(0, this.Attrs[attrIndex]); + this.Attrs[attrIndex] = Math.max(1, this.Attrs[attrIndex]); break; case Attrs.CRITICAL: case Attrs.DODGE: case Attrs.HIT: - this.Attrs[attrIndex] = Math.max(0, Math.min(85, this.Attrs[attrIndex])); + this.Attrs[attrIndex] = Math.max(0, Math.min(AttrSet.ATTR_MAX, this.Attrs[attrIndex])); //AttrSet.ATTR_MAX =85 break; } } // ==================== 临时 BUFF/DEBUFF 更新 ==================== /** - * 更新临时 buff/debuff 的剩余时? - * 应在 update 中定期调? - * @param dt 时间? + * 更新临时 buff/debuff 的剩余时 + * 应在 update 中定期调 + * @param dt 时间 */ updateTemporaryBuffsDebuffs(dt: number) { const affectedAttrs = new Set(); - - // 更新临时型数?buff + // 更新临时型数buff for (const attrIndex in this.BUFFS_V) { const buff = this.BUFFS_V[attrIndex]; buff.remainTime -= dt; @@ -404,7 +433,6 @@ export class HeroViewComp extends CCComp { affectedAttrs.add(parseInt(attrIndex)); } } - // 更新临时型百分比 buff for (const attrIndex in this.BUFFS_R) { const buff = this.BUFFS_R[attrIndex]; @@ -415,13 +443,15 @@ export class HeroViewComp extends CCComp { } } - // 更新临时型数?debuff + // 更新临时型数debuff for (const key in this.DBUFFS_V) { const debuff = this.DBUFFS_V[key]; debuff.remainTime -= dt; if (debuff.remainTime <= 0) { delete this.DBUFFS_V[key]; - affectedAttrs.add(parseInt(key)); + const keyNum = parseInt(key); + const attrField = TransformBuffs(keyNum,true) + if(attrField > 0) affectedAttrs.add(attrField); } } @@ -431,21 +461,23 @@ export class HeroViewComp extends CCComp { debuff.remainTime -= dt; if (debuff.remainTime <= 0) { delete this.DBUFFS_R[key]; - affectedAttrs.add(parseInt(key)); + const keyNum = parseInt(key); + const attrField = TransformBuffs(keyNum,true) + if(attrField > 0) affectedAttrs.add(attrField); } } - // 只重新计算受影响的属? + // 只重新计算受影响的属 affectedAttrs.forEach(attrIndex => { this.recalculateSingleAttr(attrIndex); }); } public isStun() { - return this.DBUFF_V[DBuff.STUN] !== undefined || this.DBUFFS_V[DBuff.STUN] !== undefined + this.DBUFFS_V[DBuff.STUN] !== undefined } public isFrost() { - return this.DBUFF_V[DBuff.FROST] !== undefined || this.DBUFFS_V[DBuff.FROST] !== undefined + this.DBUFFS_V[DBuff.FROST] !== undefined } update(dt: number){ @@ -475,7 +507,7 @@ export class HeroViewComp extends CCComp { get isActive() { return this.ent.has(HeroViewComp) && this.node?.isValid; } - //状态切? + //状态切 status_change(type:string){ this.status=type if(type == "idle"){ @@ -743,7 +775,7 @@ export class HeroViewComp extends CCComp { this.showDamageImmediate(damageInfo.damage, damageInfo.isCrit,damageInfo.anm); - // 设置延时处理下一个伤? + // 设置延时处理下一个伤 this.scheduleOnce(() => { this.isProcessingDamage = false; }, this.damageInterval); @@ -757,7 +789,7 @@ export class HeroViewComp extends CCComp { this.atked_count++; if (isCrit) { this.BUFFCOMP.hp_tip(TooltipTypes.crit, damage.toFixed(0), damage); - // //console.log("暴击伤害? + damage); + // //console.log("暴击伤害 + damage); } else { this.BUFFCOMP.hp_tip(TooltipTypes.life, damage.toFixed(0), damage); // //console.log("普通伤害:" + damage); diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index 1e93d03f..bf83c2cf 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -8,7 +8,7 @@ import { HeroInfo } from "../common/config/heroSet"; import { MonModelComp } from "./MonModelComp"; import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp"; import { SkillConComp } from "./SkillConComp"; -import { BuffAttr, getBuffNum, SkillSet } from "../common/config/SkillSet"; +import { Attrs, getAttrs, SkillSet } from "../common/config/SkillSet"; /** 角色实体 */ @ecs.register(`Monster`) export class Monster extends ecs.Entity { @@ -64,9 +64,11 @@ export class Monster extends ecs.Entity { } hero_init(uuid:number=1001,node:Node,scale:number=1,box_group=BoxSet.HERO,is_boss:boolean=false,is_call:boolean=false,enhancement?: any, stageMultipliers?: any) { var hv = node.getComponent(HeroViewComp)!; - hv.hide_info() + + // console.log("hero_init",buff) let hero= HeroInfo[uuid] // 共用英雄数据 + hv.scale = scale; hv.fac = FacSet.MON; hv.type = hero.type; @@ -77,11 +79,9 @@ export class Monster extends ecs.Entity { hv.box_group = box_group; hv.hero_uuid= uuid; hv.hero_name= hero.name; - - // 初始化Attrs属性系统,参考Hero.ts的实现 - hv.Attrs = getBuffNum(); - - // 计算基础属性(使用关卡倍数) + + // 初始化Attrs属性系统,参考Hero.ts的实 +// 计算基础属性(使用关卡倍数) const baseHp = hero.hp; const baseAp = hero.ap; @@ -93,46 +93,29 @@ export class Monster extends ecs.Entity { finalHp = Math.floor(baseHp * stageMultipliers.hp); finalAp = Math.floor(baseAp * stageMultipliers.attack); // console.log(`[Monster]: 怪物${hero.name} 关卡倍数 - HP: ${baseHp} x ${stageMultipliers.hp.toFixed(2)} = ${finalHp}, AP: ${baseAp} x ${stageMultipliers.attack.toFixed(2)} = ${finalAp}`); - } else { - // console.log(`[Monster]: 怪物${hero.name} 使用基础属性 - HP: ${finalHp}, AP: ${finalAp}`); } + + hv.base_ap=finalAp + hv.base_map=hero.mp + hv.base_def=hero.def + hv.base_hp=finalHp + hv.base_mp=hero.mp + hv.hp=hv.base_hp + hv.mp=hv.base_mp + hv.Attrs=getAttrs() + hv.Attrs[Attrs.HP_MAX]=hv.base_hp + hv.Attrs[Attrs.MP_MAX]=hv.base_mp + hv.Attrs[Attrs.DEF]=hv.base_def + hv.Attrs[Attrs.AP]=hv.base_ap + hv.Attrs[Attrs.MAP]=hv.base_map + hv.Attrs[Attrs.SPEED]=hero.speed + hv.Attrs[Attrs.DIS]=hero.dis + // 初始化 buff/debuff 系统 + hv.initAttrs(); - hv.hp = hv.hp_max = finalHp; - hv.ap = finalAp; - hv.ap_base = finalAp; - // 设置基础属性到Attrs系统 - hv.Attrs[BuffAttr.SPEED] = hv.speed = hv.speed_base = hero.speed; - hv.Attrs[BuffAttr.DIS] = hv.dis = hero.dis; - hv.Attrs[BuffAttr.ATK_CD] = hv.cd = hero.cd; - hv.Attrs[BuffAttr.HP_MAX] = hv.hp_max; - hv.Attrs[BuffAttr.AP] = hv.ap; - hv.Attrs[BuffAttr.DEF] = hv.def; - - // 处理原有Buff,使用统一的apply_buff方法 - hero.buff.forEach((buff:any)=>{ - hv.apply_buff(buff.type, buff.value); - }) - - // 处理肉鸽模式的增强属性 - if (enhancement && enhancement.buffList && enhancement.buffList.length > 0) { - // console.log(`[Monster]: 怪物${hero.name}应用增强属性:`, enhancement.buffList.map((buff: any) => `${buff.name}:+${buff.value}`)); - enhancement.buffList.forEach((buff:any)=>{ - hv.apply_buff(buff.buffType, buff.value); - }) - } - - // 重新计算最终HP(因为buff可能修改了hp_max) - hv.hp = hv.hp_max; - - for(let i=0;i d.debuff === DBuff.STUN); - const hasFrost = this.HeroView.V_DBUFF.some(d => d.debuff === DBuff.FROST); - if(!hasStun && !hasFrost) { + + if(!this.HeroView.isStun() && !this.HeroView.isFrost()) { let skills=this.HeroView.skills for(let i=0;i; + buffs: { [key in Attrs]?: number }; + buffList: Array<{ buffType: Attrs; value: number; name: string }>; } /** @@ -138,7 +136,7 @@ export interface MonsterEnhancementData { * @param excludeTypes 排除的属性类型 * @returns 选中的增强属性数组 */ -export function selectRandomEnhancements(count: number, excludeTypes: BuffAttr[] = []): Array<{buffType: BuffAttr, weight: number, baseValue: number, name: string}> { +export function selectRandomEnhancements(count: number, excludeTypes: Attrs[] = []): Array<{buffType: Attrs, weight: number, baseValue: number, name: string}> { if (count <= 0) return []; // 过滤掉排除的属性类型 @@ -147,7 +145,7 @@ export function selectRandomEnhancements(count: number, excludeTypes: BuffAttr[] if (availablePool.length === 0) return []; const selectedEnhancements = []; - const usedTypes = new Set(); + const usedTypes = new Set(); for (let i = 0; i < count && i < availablePool.length; i++) { // 计算权重总和 @@ -185,7 +183,7 @@ export function getMonsterEnhancement(monsterType: MonsterType, useRandom: boole const baseConfig = MonsterTypeBaseConfig[monsterType]; const enhancementCount = MonsterEnhancementCountConfig[monsterType]; - let selectedEnhancements: Array<{buffType: BuffAttr, weight: number, baseValue: number, name: string}> = []; + let selectedEnhancements: Array<{buffType: Attrs, weight: number, baseValue: number, name: string}> = []; if (useRandom) { // 随机生成增强属性 @@ -198,8 +196,8 @@ export function getMonsterEnhancement(monsterType: MonsterType, useRandom: boole } // 构建buffs对象 - const buffs: { [key in BuffAttr]?: number } = {}; - const buffList: Array<{ buffType: BuffAttr; value: number; name: string }> = []; + const buffs: { [key in Attrs]?: number } = {}; + const buffList: Array<{ buffType: Attrs; value: number; name: string }> = []; selectedEnhancements.forEach(enhancement => { buffs[enhancement.buffType] = enhancement.baseValue; diff --git a/assets/script/game/skill/SkillEnt.ts b/assets/script/game/skill/SkillEnt.ts index b7321d85..34f73ab3 100644 --- a/assets/script/game/skill/SkillEnt.ts +++ b/assets/script/game/skill/SkillEnt.ts @@ -38,7 +38,6 @@ load(startPos: Vec3, parent: Node, uuid: number, targetPos: any[], caster:Hero node.setPosition(startPos); if(caster.fac==FacSet.MON){ node.scale=v3(node.scale.x*-1,1,1) - }else{ if(caster.type==HType.warrior){ if(caster.node.scale.x<0){ @@ -49,21 +48,18 @@ load(startPos: Vec3, parent: Node, uuid: number, targetPos: any[], caster:Hero // 添加技能组件 const SComp = node.getComponent(SkillViewCom); // 初始化技能参数 // 只设置必要的运行时属性,配置信息通过 SkillSet[uuid] 访问 - Object.assign(SComp, { // 核心标识 - s_uuid: uuid, - cName:caster.hero_name, - scale: caster.node.scale.x, - // 位置和施法者信息 - startPos: startPos, - targetPos: targetPos, - group: caster.box_group, - fac: caster.fac, - // 技能数值 - ap: caster.Attrs[Attrs.AP], - caster: caster, - - }); + SComp.s_uuid= uuid + SComp.cName=caster.hero_name + SComp.scale= caster.node.scale.x + // 位置和施法者信息 + SComp.startPos= startPos + SComp.targetPos= targetPos + SComp.group= caster.box_group + SComp.fac= caster.fac, + // 技能数值 + SComp.Attrs= caster.Attrs + SComp.caster= caster, this.add(SComp); } diff --git a/assets/script/game/skill/SkillViewCom.ts b/assets/script/game/skill/SkillViewCom.ts index 9d58fa2d..56a6bdc1 100644 --- a/assets/script/game/skill/SkillViewCom.ts +++ b/assets/script/game/skill/SkillViewCom.ts @@ -40,11 +40,12 @@ export class SkillViewCom extends CCComp { target:HeroViewComp=null; parent:Node=null; target_postions:any[]=null - group:0 - fac: 0 + group:number=0 + fac:number=0 // 战斗相关运行时数据 Attrs:any=null - targetPos:any[]=null + startPos:any=null + targetPos:any=null start() { // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象 this.node.getChildByName("ready").active = this.hasReady