Esempio n. 1
0
        public bool DoTurn(PirateShip ship)
        {
            // Check if halt is needed
            Asteroid[] AsteroidsInRange = Bot.Engine.AllLivingAsteroids.Where(x => Bot.Engine.GetHits(x) == 0 && Filter(x) && x.Distance(ship) - x.Size < (ship.MaxSpeed + x.EffectiveSpeed()) * DangerRange).ToArray();
            if (ship.PushReloadTurns > 0 || AsteroidsInRange.IsEmpty())
            {
                return(false);
            }
            Asteroid NearestAsteroid = AsteroidsInRange.Nearest(ship);

            if (ship.CanPush(NearestAsteroid))
            {
                return(ship.Push(NearestAsteroid, PushLocator(NearestAsteroid, ship)));
            }
            else if (!NearestAsteroid.IsHalted())
            {
                int EffectiveDistance = NearestAsteroid.Distance(ship) - NearestAsteroid.Size;
                if (EffectiveDistance < HaltingRange * (ship.MaxSpeed + NearestAsteroid.EffectiveSpeed()))
                {
                    if (EffectiveDistance < HaltingRange * NearestAsteroid.EffectiveSpeed())
                    {
                        return(ship.Sail(NearestAsteroid.Add(NearestAsteroid.Direction.Normalized().Multiply(NearestAsteroid.EffectiveSpeed() + ship.PushRange))));
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
 public bool DoTurn(PirateShip ship)
 {
     foreach (PirateShip p in ship.GetPiratesInPushRange().Where(x => Filter(x)))
     {
         Mothership closestMothership = Bot.Engine.EnemyMotherships.FirstBy(x => x.Distance(p));
         bool       CanKill           = ((Location)(((Point)p).InDirection(closestMothership, ship.MaxSpeed))).DistanceFromBorder() <= ship.PushDistance;
         if (ship.CanPush(p) && CanKill)
         {
             if (ship.Push(p, p.ClosestBorder()))
             {
                 return(true);
             }
         }
     }
     return(false);
 }