From dff9983e38bfb12c46ca177061799c8fb793fd1d Mon Sep 17 00:00:00 2001 From: panw Date: Wed, 15 Apr 2026 17:22:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor(SCastSystem):=20=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E5=8F=8B=E6=96=B9=E6=8A=80=E8=83=BD=E6=96=BD=E6=94=BE=E7=89=B9?= =?UTF-8?q?=E6=95=88=E9=80=BB=E8=BE=91=E4=BB=A5=E7=AE=80=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除playFriendlyCastEffect和doPlayFriendlyCastEffect方法及相关特效播放逻辑,直接调用applyActualFriendlyEffect应用效果。这些特效逻辑与核心功能无关且增加了代码复杂度。 --- assets/script/game/hero/SCastSystem.ts | 62 +------------------------- 1 file changed, 1 insertion(+), 61 deletions(-) diff --git a/assets/script/game/hero/SCastSystem.ts b/assets/script/game/hero/SCastSystem.ts index 45ae65ba..9862bd77 100644 --- a/assets/script/game/hero/SCastSystem.ts +++ b/assets/script/game/hero/SCastSystem.ts @@ -414,71 +414,11 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate : this.pickRandomFriendlyTargets(targets, sHit); for (const target of applyTargets) { - const startPos = _heroView?.node?.position || _targetPos; - if (startPos) { - this.playFriendlyCastEffect(startPos, target, isCardSkill, () => { - this.applyActualFriendlyEffect(target, kind, sAp, _cAttrsComp, config, sUp); - }); - } else { - this.applyActualFriendlyEffect(target, kind, sAp, _cAttrsComp, config, sUp); - } + this.applyActualFriendlyEffect(target, kind, sAp, _cAttrsComp, config, sUp); } } - private playFriendlyCastEffect(startPos: Vec3, target: HeroViewComp, isCardSkill: boolean, callback: Function) { - if (!target.node || !target.node.isValid) { - callback(); - return; - } - - const prefabPath = "game/skill/buff/buff"; - const prefab = oops.res.get(prefabPath, Prefab); - if (!prefab) { - oops.res.load(prefabPath, Prefab, (err, res) => { - if (err) { - callback(); - return; - } - this.doPlayFriendlyCastEffect(startPos.clone(), target, res as Prefab, isCardSkill, callback); - }); - } else { - this.doPlayFriendlyCastEffect(startPos.clone(), target, prefab as Prefab, isCardSkill, callback); - } - } - private doPlayFriendlyCastEffect(startPos: Vec3, target: HeroViewComp, prefab: Prefab, isCardSkill: boolean, callback: Function) { - if (!target.node || !target.node.isValid) { - callback(); - return; - } - const scene = smc.map?.MapView?.scene; - const parent = scene?.entityLayer?.node?.getChildByName("SKILL") || target.node.parent; - if (!parent) { - callback(); - return; - } - - const node = instantiate(prefab); - node.parent = parent; - - startPos.y += 15; - node.setPosition(startPos); - - const targetPos = target.node.position.clone(); - targetPos.y += 15; - - const dist = Vec3.distance(startPos, targetPos); - const duration = Math.min(0.6, Math.max(0.3, dist / 800)); - - // 统一走直线 - tween(node) - .to(duration, { position: targetPos, angle: -720 }, { easing: 'sineOut' }) - .call(() => { - if (node.isValid) node.destroy(); - callback(); - }) - .start(); - } private applyActualFriendlyEffect(target: HeroViewComp, kind: SkillKind, sAp: number, _cAttrsComp: HeroAttrsComp, config: SkillConfig, sUp: any) { if (!target.ent) return;