Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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;
        }