/// <summary>
/// Ons the trigger enter2 d.
/// </summary>
/// <param name="collision">Collision.</param>
protected override void OnTriggerEnter2D(Collider2D collision)
{
// In respawn mode, don't interact
if (respawning)
{
return;
}
// If collision was with an enemy
EnemyBase enemyPlane = collision.GetComponent <EnemyBase>();
if (enemyPlane != null)
{
Damage();
enemyPlane.Damage();
}
// If collision was with a projectile
Projectile shoot = collision.GetComponent <Projectile>();
if (shoot != null)
{
// Return projectile to pool
collision.gameObject.SetActive(false);
Damage(shoot.damage);
}
}