From b61652084d2b17895c6b4cffbf18b6275fbe27a8 Mon Sep 17 00:00:00 2001 From: panw Date: Sat, 8 Feb 2025 10:57:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=8A=80=E8=83=BD=E5=BB=B6?= =?UTF-8?q?=E8=BF=9F=20=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- @Progress.md | 4 ++- @project-status.md | 7 ++++- assets/script/game/skill/HeroSkillSystem.ts | 30 ++++++++++++++------- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/@Progress.md b/@Progress.md index 454db66e..2e73dca4 100644 --- a/@Progress.md +++ b/@Progress.md @@ -8,4 +8,6 @@ - 为固定位置类型技能添加了动画结束(endType.animationEnd)支持 - 实现了动画播放完成后的技能销毁逻辑 - 修改了直线技能的结束条件,改为到达目标点时销毁 -- 移除了不必要的屏幕边界检测 \ No newline at end of file +- 移除了不必要的屏幕边界检测 +- 优化了技能伤害延迟计算逻辑 +- 为抛物线类型技能添加了基于距离和速度的动态延迟计算 \ No newline at end of file diff --git a/@project-status.md b/@project-status.md index c6ff14d6..39391b04 100644 --- a/@project-status.md +++ b/@project-status.md @@ -6,6 +6,8 @@ - 优化了技能销毁逻辑 - 优化了直线技能的结束条件判断 - 确保技能行为符合设计意图 +- 实现了抛物线技能的动态伤害延迟计算 +- 保持了其他类型技能的默认延迟时间 ## 下一步工作建议 - 测试 EndAnmCom 组件在不同类型技能上的表现 @@ -13,4 +15,7 @@ - 确认屏幕尺寸配置是否正确 - 测试直线技能在不同方向上的边界检测 - 测试直线技能到达目标点时的销毁效果 -- 验证不同距离和速度下的技能表现 \ No newline at end of file +- 验证不同距离和速度下的技能表现 +- 测试抛物线技能在不同距离下的伤害延迟表现 +- 验证伤害时机是否与技能动画同步 +- 考虑是否需要为其他类型技能添加自定义延迟计算 \ No newline at end of file diff --git a/assets/script/game/skill/HeroSkillSystem.ts b/assets/script/game/skill/HeroSkillSystem.ts index 2a5a8203..1d09b0d6 100644 --- a/assets/script/game/skill/HeroSkillSystem.ts +++ b/assets/script/game/skill/HeroSkillSystem.ts @@ -31,6 +31,7 @@ import { oops } from "db://oops-framework/core/Oops"; import { GameEvent } from "../common/config/GameEvent"; import { Skill } from "../skills/Skill"; import { SkillCom } from "../skills/SkillCom"; +import { AnimType } from "../common/config/SkillSet"; /** 技能系统 */ @@ -261,17 +262,26 @@ export class HeroSkillSystem extends ecs.ComblockSystem implements ecs.ISystemUp private calculateDamage(caster: ecs.Entity, target: ecs.Entity, config: typeof SkillSet[keyof typeof SkillSet]) { const result = { - value :0, // 确保最小伤害为1 - isCrit : false, - isDodged : false, - delay : 0.3, - ignoreDefense : false, - canCrit : true, + value: 0, + isCrit: false, + isDodged: false, + delay: 0.3, // 默认延迟 + ignoreDefense: false, + canCrit: true, } - - const targetView =target.get(HeroViewComp); - const sourceView =caster.get(HeroViewComp); - let final = sourceView.ap*config.ap/100; + + // 计算延迟时间 + if (config.AnimType === AnimType.parabolic) { + const sourcePos = caster.get(HeroViewComp).node.position; + const targetPos = target.get(HeroViewComp).node.position; + // 计算距离除以速度得到时间 + const distance = Math.abs(targetPos.x - sourcePos.x); + result.delay = distance / config.speed; + } + + const targetView = target.get(HeroViewComp); + const sourceView = caster.get(HeroViewComp); + let final = sourceView.ap * config.ap / 100; // 伤害浮动(±10%) const damageFloat = 0.9 + Math.random() * 0.2; // 0.9~1.1