Пример #1
0
    private IEnumerator ReproduceOneAnimalCo(AnimalController animalMother)
    {
        animalMother.IsReproducing = true;

        yield return(new WaitForSeconds(animalMother.ReproductionTime));

        var newAnimal = Instantiate <AnimalController>(animalMother, _animalParent);

        newAnimal.IsReproducing = true;
        newAnimal.Init(animalMother.GetAnimalType());
        newAnimal.transform.position = animalMother.transform.position;

        newAnimal.DoJumpReproduction(false);
        animalMother.DoJumpReproduction(true);

        _allAnimals.Add(newAnimal);

        ++AnimalAmount[animalMother.GetAnimalType()];

        yield return(new WaitForSeconds(animalMother.ReproductionJumpTime));

        animalMother.IsReproducing = false;
        newAnimal.IsReproducing    = false;
    }