public void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.GetComponent <DragonProjectile>() != null) { DragonProjectile encounteredProjectile = other.gameObject.GetComponent <DragonProjectile>(); this.HP -= encounteredProjectile.Damage; } }
public void Shoot(Unit target) { Projectile projectile; switch ((int)_projectileType) { case (int)ProjectileType.unvisible: { projectile = new UnvisibleProjectile(target, _dmg, X, Y); break; } case (int)ProjectileType.simple: { projectile = new SimpleProjectile(target, _dmg, X, Y); break; } case (int)ProjectileType.large: { projectile = new LargeProjectile(target, _dmg, X, Y); break; } case (int)ProjectileType.building: { projectile = new BuildingProjectile(target, _dmg, X, Y); break; } case (int)ProjectileType.none: { projectile = new NoProjectile(target, _dmg, X, Y); break; } case (int)ProjectileType.dragon: { projectile = new DragonProjectile(target, _dmg, X, Y); break; } case (int)ProjectileType.priest: { projectile = new PriestProjectile(target, _dmg, X, Y); break; } default: throw new Exception("Unknown weapon type"); } _parent.Add(projectile); }