using ActionGameFramework.Health; using ActionGameFramework.Projectiles; using UnityEngine; using Core.Utilities; namespace TowerDefense.Towers.TowerLaunchers { /// /// Implementation of the tower launcher for Ballistic Projectiles /// public class BallisticLauncher : Launcher { /// /// The particle system used for providing launch feedback /// public GameObject fireParticleObj; /// /// Launches a single projectile at a single enemy from a single firing point /// /// /// The enemy to target /// /// /// The projectile to attack /// /// /// The point to fire from /// public override void Launch(Targetable enemy, GameObject projectile, Transform firingPoint, int idx = 0) { Vector3 startPosition = firingPoint.position; var ballisticProjectile = projectile.GetComponent(); if (ballisticProjectile == null) { Debug.LogError("No ballistic projectile attached to projectile"); DestroyImmediate(projectile); return; } ballisticProjectile.FireAtPoint(startPosition, enemy.position); if (fireParticleObj != null) { GameObject psObj = Poolable.TryGetPoolable(fireParticleObj); ParticleSystem ps = psObj.GetComponent(); if (ps == null) ps = psObj.transform.GetChild(0).GetComponent(); PlayParticles(ps, startPosition, enemy.position); } } } }