diff --git a/assets/script/game/common/config/SkillSet.ts b/assets/script/game/common/config/SkillSet.ts index ce3ab7c9..21b087da 100644 --- a/assets/script/game/common/config/SkillSet.ts +++ b/assets/script/game/common/config/SkillSet.ts @@ -48,8 +48,9 @@ export enum SkillKind { } export enum BuffRunType { - Attr = 0, - Interval = 1 + Permanent = 0, + Timed = 1, + Interval = 2 } /** @@ -329,9 +330,9 @@ export const BuffsList: Record = { // ========== 治疗与护盾 (转换自原 SType) ========== 10300 - 10399 // 治疗 (基于攻击力百分比) - 10301: { uuid: 10301, name: "治疗", icon: "1292", buff: Attrs.hp, BType: BType.RATIO, value: 30, time: 0, chance: 1, info: "回复30%最大生命值" }, + 10301: { uuid: 10301, name: "治疗", icon: "1292", buff: Attrs.hp, BType: BType.RATIO, value: 30, time: 0, chance: 1, runType: BuffRunType.Permanent, info: "回复30%最大生命值" }, // 护盾 (基于攻击力百分比) - 10302: { uuid: 10302, name: "护盾", icon: "1255", buff: Attrs.shield, BType: BType.RATIO, value: 30, time: 0, chance: 1, info: "获得30%最大生命值护盾" }, + 10302: { uuid: 10302, name: "护盾", icon: "1255", buff: Attrs.shield, BType: BType.RATIO, value: 30, time: 0, chance: 1, runType: BuffRunType.Permanent, info: "获得30%最大生命值护盾" }, 10311: { uuid: 10311, name: "持续治疗", icon: "1292", buff: Attrs.hp, BType: BType.RATIO, value: 5, time: 5, interval: 1, chance: 1, runType: BuffRunType.Interval, info: "每秒回复5%最大生命值,持续5秒" }, 10312: { uuid: 10312, name: "流血", icon: "10211", buff: Attrs.hp, BType: BType.RATIO, value: -4, time: 5, interval: 1, chance: 1, isDebuff: true, runType: BuffRunType.Interval, info: "每秒损失4%最大生命值,持续5秒" }, diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 210dfdae..ad16369d 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -1,6 +1,4 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; -import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; -import { GameEvent } from "../common/config/GameEvent"; import { Attrs, BType } from "../common/config/HeroAttrs"; import { BuffConf, BuffRunType, SkillDisVal, SkillRange } from "../common/config/SkillSet"; import { HeroInfo, HType } from "../common/config/heroSet"; @@ -9,12 +7,7 @@ import { smc } from "../common/SingletonModuleComp"; import { HeroViewComp } from "./HeroViewComp"; import { _decorator } from "cc"; -const { property } = _decorator; -interface talTrigger{ - value:number - count:number -} interface ActiveBuffState { id: number attr: Attrs @@ -180,7 +173,8 @@ export class HeroAttrsComp extends ecs.Comp { */ addBuff(buffConf: BuffConf) { const normalized = this.normalizeBuffValue(buffConf); - if (buffConf.runType === BuffRunType.Interval) { + const runType = this.resolveRunType(buffConf); + if (runType === BuffRunType.Interval) { const interval = buffConf.interval && buffConf.interval > 0 ? buffConf.interval : 1; const remain = buffConf.time > 0 ? buffConf.time : interval; this.INTERVAL_EFFECTS.push({ @@ -195,10 +189,11 @@ export class HeroAttrsComp extends ecs.Comp { }); return; } - if (buffConf.time <= 0) { + if (runType === BuffRunType.Permanent) { this.applyAttrChange(buffConf.buff, normalized.value, normalized.BType); return; } + const duration = buffConf.time > 0 ? buffConf.time : 1; const targetList = buffConf.isDebuff ? this.DEBUFFS : this.BUFFS; const attrKey = buffConf.buff as unknown as number; // 强制转换 key 类型以适配 Record @@ -213,12 +208,18 @@ export class HeroAttrsComp extends ecs.Comp { sourceUuid: buffConf.uuid, value: normalized.value, BType: normalized.BType, - time: buffConf.time + time: duration }); this.applyAttrChange(buffConf.buff, normalized.value, normalized.BType); - mLogger.log(this.debugMode, 'HeroAttrs', `添加Buff: ${buffConf.name}, 属性:${buffConf.buff}, 值:${normalized.value}, 时间:${buffConf.time}`); + mLogger.log(this.debugMode, 'HeroAttrs', `添加Buff: ${buffConf.name}, 属性:${buffConf.buff}, 值:${normalized.value}, 时间:${duration}`); + } + + private resolveRunType(buffConf: BuffConf): BuffRunType { + if (buffConf.runType !== undefined) return buffConf.runType; + if (buffConf.interval && buffConf.interval > 0) return BuffRunType.Interval; + return buffConf.time > 0 ? BuffRunType.Timed : BuffRunType.Permanent; } private normalizeBuffValue(buffConf: BuffConf): { value: number; BType: BType } {