Exemplo n.º 1
0
        // Event for the person to signal that they have become pregnant.
        // Schedule the birth event.
        public void OnGiveBirth(Person person, BirthEventArgs e)
        {
            //Console.WriteLine("Adding {0} to game", e.Child.FirstName);
            EntitiesAdd(e.Child);

            e.Child.OnScheduleEvent(e.Child, new ScheduleEventArgs(Person.ageSeconds, new AgeAction()));
            person.Abort();
            person.GiveBirth -= OnGiveBirth; // Remove the listener.
        }
Exemplo n.º 2
0
        public void BirthHandler <T>(object sender, BirthEventArgs args) where T : IAnimal
        {
            var randomRange        = new Vector(1, 1);
            var availablePositions = _emptyCellProvider.GetCellsFromFieldRegion(_field, args.Position - randomRange,
                                                                                args.Position + randomRange);


            if (availablePositions.Count > 0)
            {
                var chosenPosition = availablePositions[_random.Next(0, availablePositions.Count)];
                AddAnimal <T>(chosenPosition, _animalsToBeBorn);
            }
        }
Exemplo n.º 3
0
 public void GibBirth(BirthEventArgs e)
 {
     Birth?.Invoke(this, e);
 }