private void GenerateAnimals()
    {
        int x;
        int y;

        Vector3 offset = new Vector3(0, 0.5f, 0);

        for (int i = 0; i < rabbitCount; i++)
        {
            do
            {
                x = Random.Range(0, terrainData.size);
                y = Random.Range(0, terrainData.size);
            } while (!terrainData.walkable[x, y]);


            GameObject rabbit = Instantiate(rabbitPrefab, terrainData.tileCentres[x, y] + offset, Quaternion.identity);
            ecosystem.AddAnimal(rabbit);
        }

        for (int i = 0; i < foxCount; i++)
        {
            do
            {
                x = Random.Range(0, terrainData.size);
                y = Random.Range(0, terrainData.size);
            } while (!terrainData.walkable[x, y]);


            GameObject fox = Instantiate(foxPrefab, terrainData.tileCentres[x, y] + offset, Quaternion.identity);
            ecosystem.AddAnimal(fox);
        }
    }
Esempio n. 2
0
    public void InstantiateNewAnimal(GenesData childGenes)
    {
        GameObject son = Instantiate(gameObject);

        ecosystem.AddAnimal(son);
        son.GetComponent <Genes>().genesData = childGenes;
        Destroy(son.GetComponent <Pregnant>());
    }