计算技能延迟 时间

This commit is contained in:
2025-02-08 10:57:27 +08:00
parent d4bdc1651f
commit b61652084d
3 changed files with 29 additions and 12 deletions

View File

@@ -9,3 +9,5 @@
- 实现了动画播放完成后的技能销毁逻辑
- 修改了直线技能的结束条件,改为到达目标点时销毁
- 移除了不必要的屏幕边界检测
- 优化了技能伤害延迟计算逻辑
- 为抛物线类型技能添加了基于距离和速度的动态延迟计算

View File

@@ -6,6 +6,8 @@
- 优化了技能销毁逻辑
- 优化了直线技能的结束条件判断
- 确保技能行为符合设计意图
- 实现了抛物线技能的动态伤害延迟计算
- 保持了其他类型技能的默认延迟时间
## 下一步工作建议
- 测试 EndAnmCom 组件在不同类型技能上的表现
@@ -14,3 +16,6 @@
- 测试直线技能在不同方向上的边界检测
- 测试直线技能到达目标点时的销毁效果
- 验证不同距离和速度下的技能表现
- 测试抛物线技能在不同距离下的伤害延迟表现
- 验证伤害时机是否与技能动画同步
- 考虑是否需要为其他类型技能添加自定义延迟计算

View File

@@ -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,14 +262,23 @@ 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
value: 0,
isCrit: false,
isDodged: false,
delay : 0.3,
delay: 0.3, // 默认延迟
ignoreDefense: false,
canCrit: true,
}
// 计算延迟时间
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;