using ActionGameFramework.Health;
|
using ActionGameFramework.Projectiles;
|
using UnityEngine;
|
using Core.Utilities;
|
|
namespace TowerDefense.Towers.TowerLaunchers
|
{
|
/// <summary>
|
/// Implementation of the tower launcher for Ballistic Projectiles
|
/// </summary>
|
public class BallisticLauncher : Launcher
|
{
|
/// <summary>
|
/// The particle system used for providing launch feedback
|
/// </summary>
|
public GameObject fireParticleObj;
|
|
/// <summary>
|
/// Launches a single projectile at a single enemy from a single firing point
|
/// </summary>
|
/// <param name="enemy">
|
/// The enemy to target
|
/// </param>
|
/// <param name="projectile">
|
/// The projectile to attack
|
/// </param>
|
/// <param name="firingPoint">
|
/// The point to fire from
|
/// </param>
|
public override void Launch(Targetable enemy, GameObject projectile, Transform firingPoint, int idx = 0)
|
{
|
Vector3 startPosition = firingPoint.position;
|
var ballisticProjectile = projectile.GetComponent<BallisticProjectile>();
|
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<ParticleSystem>();
|
// if (ps == null)
|
// ps = psObj.transform.GetChild(0).GetComponent<ParticleSystem>();
|
// PlayParticles(ps, startPosition, enemy.position);
|
// }
|
}
|
}
|
}
|