wangguan
2020-12-29 452c75675679c44cc39b04bdb7d330d7c5c14d5c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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>
        /// 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);
        }
    }
}