Пример #1
0
        /// <summary>
        /// Creates a new coordinate instance.
        /// </summary>
        /// <param name="anthill">The anthill as reference object.</param>
        /// <param name="ant">The ant for the coordinate.</param>
        public RelativeCoordinate(Anthill anthill, BaseAnt ant)
        {
            // Calculate distance and degree
            double distance = Coordinate.GetDistanceBetween(anthill, ant);
            double degrees  = Coordinate.GetDegreesBetween(anthill, ant);

            // Calculate coordinates with distance and degree
            SetCoordinatesBeDegrees(distance, degrees);
        }
Пример #2
0
 public Fruit GetNearestFruit(BaseAnt ant)
 {
     lock (syncRoot)
     {
         return(this.fruitRepo
                .Where(x => x.Amount > 0 && ant.NeedsCarrier(x))
                .OrderBy(x => Coordinate.GetDistanceBetween((CoreAnt)ant, (Item)x))
                .FirstOrDefault());
     }
 }
Пример #3
0
 public Insect GetNearestEnemy(BaseAnt ant)
 {
     lock (syncRoot)
     {
         return(this.enemyRepo
                .Where(x => x.CurrentEnergy > 0)
                .OrderBy(x => Coordinate.GetDistanceBetween((CoreAnt)ant, (Item)x))
                .FirstOrDefault());
     }
 }
Пример #4
0
 public Sugar GetNearestSugar(BaseAnt ant)
 {
     lock (syncRoot)
     {
         return(this.sugarRepo
                .Where(x => x.Amount > 0)
                .OrderBy(x => Coordinate.GetDistanceBetween((CoreAnt)ant, (Item)x))
                .FirstOrDefault());
     }
 }