diff --git a/assets/script/game/skill/HeroSkillSystem.ts b/assets/script/game/skill/HeroSkillSystem.ts index 965403bb..4ab874de 100644 --- a/assets/script/game/skill/HeroSkillSystem.ts +++ b/assets/script/game/skill/HeroSkillSystem.ts @@ -121,46 +121,9 @@ export class HeroSkillSystem extends ecs.ComblockSystem implements ecs.ISystemUp /** 应用技能效果 */ private applySkillEffect(caster: ecs.Entity, target: ecs.Entity, config: typeof SkillSet[keyof typeof SkillSet],skillEntity:ecs.Entity) { const casterView = caster.get(HeroViewComp); - const targetView = target.get(HeroViewComp); - - // 直接计算伤害(包含防御减免) - const damageResult = this.calculateDamage(caster, target, config); - // 播放技能特效 casterView.playSkillEffect(config.uuid); - console.log(`${casterView.hero_name} 对 ${targetView.hero_name} 造成 ${damageResult.value}伤害`); - } - private calculateDamage(caster: ecs.Entity, target: ecs.Entity, config: typeof SkillSet[keyof typeof SkillSet]) { - const result = { - value: 0, - isCrit: false, - isDodged: false, - 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 sourceView = caster.get(HeroViewComp); - let final = sourceView.ap * config.ap / 100; - - // 伤害浮动(±10%) - const damageFloat = 0.9 + Math.random() * 0.2; // 0.9~1.1 - final *= damageFloat; - final = Math.round(final); - - result.value = Math.max(1, final); // 确保最小伤害为1 - result.isCrit = false; - return result; } public clear_timer() { diff --git a/assets/script/game/skill/SkillSystem.ts b/assets/script/game/skill/SkillSystem.ts index 0e871b12..b2d9f4ae 100644 --- a/assets/script/game/skill/SkillSystem.ts +++ b/assets/script/game/skill/SkillSystem.ts @@ -31,8 +31,8 @@ export class SkillSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate if(this.checkSkill(skill)){ if(skill.atk_count < 1){ skill.atk_count++; - console.log("技能命中目标",skill.target.hero_name); - this.applySkillEffect(skill.caster,skill.target,SkillSet[skill.s_uuid],skill); + // console.log("技能命中目标",skill.caster,skill.target,SkillSet[skill.s_uuid]); + this.applySkillEffect(skill.caster,skill.target,SkillSet[skill.s_uuid]); } } this.processDamageQueue(); @@ -63,10 +63,9 @@ export class SkillSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate return isInRange; } /** 应用技能效果 */ - private applySkillEffect(casterView:HeroViewComp, targetView: HeroViewComp, config: typeof SkillSet[keyof typeof SkillSet],skill:SkillCom) { - + private applySkillEffect(casterView:HeroViewComp, targetView: HeroViewComp, config: typeof SkillSet[keyof typeof SkillSet]) { // 直接计算伤害(包含防御减免) - const damageResult = this.calculateDamage(casterView, casterView, config); + const damageResult = this.calculateDamage(casterView, targetView, config); // 将施法者传入applyDamage方法 this.applyDamage(targetView,damageResult); // 播放技能特效 @@ -83,24 +82,11 @@ private calculateDamage(caster: HeroViewComp, target: HeroViewComp, config: type ignoreDefense: false, canCrit: true, } - - // 计算延迟时间 - if (config.AnimType === AnimType.parabolic) { - const sourcePos = caster.node.position; - const targetPos = target.node.position; - // 计算距离除以速度得到时间 - const distance = Math.abs(targetPos.x - sourcePos.x); - result.delay = distance / config.speed; - } - - const sourceView = caster; - let final = sourceView.ap * config.ap / 100; - + let final = caster.ap * config.ap / 100; // 伤害浮动(±10%) const damageFloat = 0.9 + Math.random() * 0.2; // 0.9~1.1 final *= damageFloat; final = Math.round(final); - result.value = Math.max(1, final); // 确保最小伤害为1 result.isCrit = false; return result; diff --git a/assets/script/game/skills/Skill.ts b/assets/script/game/skills/Skill.ts index 81488c5d..03afe72b 100644 --- a/assets/script/game/skills/Skill.ts +++ b/assets/script/game/skills/Skill.ts @@ -44,6 +44,7 @@ export class Skill extends ecs.Entity { console.log("加载预制体:",startPos,targetPos) // 添加技能组件 const skillComp = node.getComponent(SkillCom); // 初始化技能参数 + skillComp.s_uuid = uuid; skillComp.animType = config.AnimType; skillComp.endType = config.endType; skillComp.speed = config.speed;