public Ant(int x, int y, AntHill a) : base(x,y, "Ant") { hasFood = false; status = ""; anthill = a; ant_id = init_id++; nearestFood = null; hasObjects = false; current_job = new Job(); }
public void AddFood(int col, int row) { var food = new Food { X = col, Y = row }; var index = Foods.BinarySearch(food); if (index < 0) { Foods.Insert(~index, food); index = ~index; food.DistanceMap = new int[Width, Height]; food.NeedRecalcDistanceMap = true; } Foods[index].IsVisible = true; Map[col, row] = Tile.Food; }
private void doJob() { if(current_job.getName() == "Food") { if(hasFood) { moveTo(anthill.getX(), anthill.getY()); status = "Moving to anthill"; if(atLoc(anthill.getX(), anthill.getY())) { hasFood = false; anthill.incFood(food_capacity); current_job = new Job(); status = ""; } } else { findnearestfood(); status = "Moving to nearest food"; nearestFood = findnearestfood(); moveTo(nearestFood.getX(), nearestFood.getY()); } if(atLoc(nearestFood.getX(), nearestFood.getY()) && !hasFood) { gatherFood(); } } }