refactor(SCastSystem): 移除友方技能施放特效逻辑以简化代码
移除playFriendlyCastEffect和doPlayFriendlyCastEffect方法及相关特效播放逻辑,直接调用applyActualFriendlyEffect应用效果。这些特效逻辑与核心功能无关且增加了代码复杂度。
This commit is contained in:
@@ -414,71 +414,11 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
: this.pickRandomFriendlyTargets(targets, sHit);
|
: this.pickRandomFriendlyTargets(targets, sHit);
|
||||||
|
|
||||||
for (const target of applyTargets) {
|
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) {
|
private applyActualFriendlyEffect(target: HeroViewComp, kind: SkillKind, sAp: number, _cAttrsComp: HeroAttrsComp, config: SkillConfig, sUp: any) {
|
||||||
if (!target.ent) return;
|
if (!target.ent) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user