private void EatSomeRabbit(World forest) { //IEnumerable<Grass> grass = forest.ObjectsAt(Position).Cast<Grass>(); if (forest.ObjectsCloseTo(Position).Any(o => o is Rabbit && o != this)) { Rabbit rabbit = forest.ObjectsAt(Position).Select(o => o as Rabbit).First(o => o != null); forest.Remove(rabbit); int amount = FOOD_CONSUMPTION * 100; food += amount; } }
private void Breed(World forest)//Tiene Hijos { if (age < ADULTHOOD || food < FOOD_TO_BREED) { return; } //if (forest.ObjectsAt(Position).Any(o => o is Rabbit && o != this))//no hace falta for (int i = 0; i < MAX_CHILDREN; i++) { if (forest.Random(1, 10) <= 10 * BREED_PROBABILITY) { Rabbit bunny = new Rabbit(); bunny.Position = Position; forest.AddRabit(bunny); } } }
private void Breed(World forest) { if (age < ADULTHOOD || food < FOOD_TO_BREED) { return; } if (forest.ObjectsCloseTo(Position).Any(o => o is Rabbit && o != this)) { for (int i = 0; i < MAX_CHILDREN; i++) { if (forest.Random(1, 10) <= 10 * BREED_PROBABILITY) { Rabbit bunny = new Rabbit(); bunny.Position = Position; forest.Add(bunny); } } } }
private void Breed(World forest) { if (age < ADULTHOOD || food < FOOD_TO_BREED) { return; } if (forest.BuscarConejos(Position, ADULTHOOD)) { for (int i = 0; i < MAX_CHILDREN; i++) { if (forest.Random(1, 10) <= 10 * BREED_PROBABILITY) { Rabbit bunny = new Rabbit(); bunny.Position = Position; forest.AddRabit(bunny); } } } }