public void TakeFood(FoodBase foodBase) { if(entityBase.entityType == EntityType.Ant) { AntBase antBase = (AntBase)entityBase; if(antBase.capacity < antBase.maxCapacity) { if(antBase.capacity > 0) { int capacityRemaining = antBase.maxCapacity % antBase.capacity; if(foodBase.stockSize >= capacityRemaining) { antBase.capacity += capacityRemaining; foodBase.stockSize -= capacityRemaining; } else { antBase.capacity += foodBase.stockSize; foodBase.stockSize = 0; } } else { if (foodBase.stockSize >= antBase.maxCapacity) { antBase.capacity += antBase.maxCapacity; foodBase.stockSize -= antBase.maxCapacity; } else { antBase.capacity += foodBase.stockSize; foodBase.stockSize = 0; } } } } }
public bool Smells(FoodBase foodBase) { return this.origin.DistanceTo(foodBase.origin) <= foodBase.smellStrength; }
public void spawnFood(FoodBase foodBase) { if (antWorld == null) throw new NullReferenceException("[antWorld] has not been initialized, yet."); int max_x = (int)antWorld.size.X; int max_y = (int)antWorld.size.Y; int random_x = Randomizer.NextInt(0, max_x); int random_y = Randomizer.NextInt(0, max_y); foodBase.position = new Vector2(random_x, random_y); EntityManager.Singleton.entityList.Add(foodBase); }