计算技能延迟 时间

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

@@ -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