public bool IsAlive() { int damagablesNotDestroyed = 0; for (int i = 0; i < this.Damagables.Length; i++) { Damagable d = this.Damagables[i]; if (!d.IsDestroyed()) { damagablesNotDestroyed++; } else if (d.IsShipCritical) { return(false); } } return(damagablesNotDestroyed > 0); }
public void PickTarget() { if ((this.ParentShip != null) && (this.ParentShip.PriorityTarget != null)) { this.CurrentTarget = this.ParentShip.PriorityTarget; return; } float closestDistance = this.MaxRange; Damagable closest = null; for (int i = 0; i < Damagable.All.Count; i++) { Damagable d = Damagable.All[i]; float range = this.GetRangeTo(d); if (!d.IsDestroyed() && (range < closestDistance)) { closest = d; closestDistance = range; } } this.CurrentTarget = closest; }
public virtual void OnProjectileHit(Damagable d) { this.HitCount++; }