From b094d4632f56fc458f7d81880ecffd65fb3bc67c Mon Sep 17 00:00:00 2001 From: panw Date: Mon, 31 Mar 2025 10:38:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E4=B9=8B=E5=90=8E=20=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E6=8A=80=E8=83=BD=20=E5=A4=9A=E6=AC=A1=E9=87=8A?= =?UTF-8?q?=E6=94=BE=20=E6=8F=90=E4=BE=9B=E5=9F=BA=E7=A1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/script/game/skill/HeroSkillSystem.ts | 29 ++++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/assets/script/game/skill/HeroSkillSystem.ts b/assets/script/game/skill/HeroSkillSystem.ts index 510950e0..a5d37309 100644 --- a/assets/script/game/skill/HeroSkillSystem.ts +++ b/assets/script/game/skill/HeroSkillSystem.ts @@ -42,22 +42,10 @@ export class HeroSkillSystem extends ecs.ComblockSystem implements ecs.ISystemUp /** 施放技能 */ private castSkill(caster: ecs.Entity, skillId: number, config: typeof SkillSet[keyof typeof SkillSet]) { const view = caster.get(HeroViewComp); - const skillEntity = ecs.getEntity(Skill); console.log(view.uuid+"=>"+view.hero_name+"施放技能:"+config.uuid); if (config.TargetGroup === TargetGroup.Enemy) { - const targets = this.selectEnemyTargets(caster, config); - console.log("敌人 targets:"+targets); - if (targets.length === 0) return; - skillEntity.load( - new Vec3(view.node.position.x, view.node.position.y+BoxSet.ATK_Y, 0), // 起始位置 - view.box_group, // 阵营 - view.node.parent, // 父节点 - config.uuid, // 技能ID - new Vec3(targets[0]?.get(HeroViewComp).node.position.x, targets[0]?.get(HeroViewComp).node.position.y, 0), // 目标位置 - view - ); caster.get(HeroViewComp).playSkillEffect(config.uuid); - console.log("技能:"+config.uuid+"=>"+targets[0]?.get(HeroViewComp).hero_name); + this.doSkill(caster,config); } if (config.TargetGroup === TargetGroup.Ally) { @@ -70,6 +58,21 @@ export class HeroSkillSystem extends ecs.ComblockSystem implements ecs.ISystemUp } } + private doSkill(caster: ecs.Entity, config: typeof SkillSet[keyof typeof SkillSet]) { + const view = caster.get(HeroViewComp); + const skillEntity = ecs.getEntity(Skill); + const targets = this.selectEnemyTargets(caster, config); + if (targets.length === 0) return; + skillEntity.load( + new Vec3(view.node.position.x, view.node.position.y+BoxSet.ATK_Y, 0), // 起始位置 + view.box_group, // 阵营 + view.node.parent, // 父节点 + config.uuid, // 技能ID + new Vec3(targets[0]?.get(HeroViewComp).node.position.x, targets[0]?.get(HeroViewComp).node.position.y, 0), // 目标位置 + view + ); + console.log("技能:"+config.uuid+"=>"+targets[0]?.get(HeroViewComp).hero_name); + } private selectEnemyTargets(caster: ecs.Entity, config: typeof SkillSet[keyof typeof SkillSet]): ecs.Entity[] { const casterView = caster.get(HeroViewComp);