/// <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); }
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()); } }
public Insect GetNearestEnemy(BaseAnt ant) { lock (syncRoot) { return(this.enemyRepo .Where(x => x.CurrentEnergy > 0) .OrderBy(x => Coordinate.GetDistanceBetween((CoreAnt)ant, (Item)x)) .FirstOrDefault()); } }
public Sugar GetNearestSugar(BaseAnt ant) { lock (syncRoot) { return(this.sugarRepo .Where(x => x.Amount > 0) .OrderBy(x => Coordinate.GetDistanceBetween((CoreAnt)ant, (Item)x)) .FirstOrDefault()); } }