示例#1
0
    public void populateEcosystem()
    {
        SaveLoadController.destroyEcosystem();
        // Populate the system with some organisms
        int numPrey     = 10;
        int numPredator = 10;
        int numFlora    = 64;
        int numWater    = 5;

        for (int i = 0; i < numPrey; i++)
        {
            GameObject prey = Instantiate(preySpecies, new Vector3((float)Random.Range(0, xSize), 0f, (float)Random.Range(0, zSize)), Quaternion.identity);
            prey.transform.parent = gameObject.transform;
            prey.SetActive(true);
            prey.name = preySpecies.name;
        }
        for (int i = 0; i < numPredator; i++)
        {
            GameObject predator = Instantiate(predatorSpecies, new Vector3((float)Random.Range(0, xSize), 0f, (float)Random.Range(0, zSize)), Quaternion.identity);
            predator.transform.parent = gameObject.transform;
            predator.SetActive(true);
            predator.name = predatorSpecies.name;
        }
        for (int i = 0; i < numFlora; i++)
        {
            GameObject flora = Instantiate(floraSpecies, new Vector3((float)Random.Range(0, xSize), 0f, (float)Random.Range(0, zSize)), Quaternion.identity);
            flora.transform.parent = gameObject.transform;
            flora.SetActive(true);
            flora.name = floraSpecies.name;
            flora.GetComponent <Flora>().waterLevel = Random.Range(15f, 100f);
        }
        for (int i = 0; i < numWater; i++)
        {
            GameObject water = Instantiate(waterSource, new Vector3((float)Random.Range(10, xSize - 10), 0f, (float)Random.Range(10, zSize - 10)), Quaternion.identity);
            water.transform.parent = gameObject.transform;
            water.SetActive(true);
            water.name = waterSource.name;
        }
    }
示例#2
0
 public void resetEcosystem()
 {
     SaveLoadController.destroyEcosystem();
 }