From 887ba6064c1efc3a238c50d54beca1747e92066d Mon Sep 17 00:00:00 2001 From: panw Date: Fri, 13 Mar 2026 10:41:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8A=80=E8=83=BD=E7=B3=BB=E7=BB=9F):=20?= =?UTF-8?q?=E6=89=A9=E5=B1=95Buff=E8=BF=90=E8=A1=8C=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E5=A4=8D=E6=B2=BB=E7=96=97=E4=B8=8E=E6=8A=A4?= =?UTF-8?q?=E7=9B=BE=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 扩展BuffRunType枚举,新增Permanent和Timed类型,明确区分永久、定时和间隔效果 - 在HeroAttrsComp中重构addBuff方法,根据配置智能解析运行类型 - 为治疗(10301)和护盾(10302)配置显式添加runType: Permanent,确保逻辑一致性 - 修复定时Buff的持续时间处理,避免time为0时使用默认值1 --- assets/script/game/common/config/SkillSet.ts | 9 ++++---- assets/script/game/hero/HeroAttrsComp.ts | 23 ++++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) 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 } {