예제 #1
0
    // Start is called before the first frame update
    void Start()
    {
        GameObject[] flora    = GameObject.FindGameObjectsWithTag("flora");
        SavedFlora   testSave = SavedFlora.saveFlora(flora[0]);

        GameObject testLoad = SavedFlora.loadFlora(testSave);

        Instantiate(testLoad);
    }
예제 #2
0
    // This function nukes the entire ecosystem and reinstantiates everything based
    // on the SavedEcosystem passed in
    public static void loadEntireEcosystem(SavedEcosystem saveToLoad)
    {
        // Clear the old, to make way for the new
        destroyEcosystem();

        Debug.Log("Loading " + saveToLoad.waterSources.Count + " water sources!");

        // Now we loop through the lists in the SavedEcosystem to instantiate them into the simulation
        for (int i = 0; i < saveToLoad.prey.Count; i++)
        {
            GameObject tempPrey = Instantiate(SavedPrey.loadPrey(saveToLoad.prey[i]));
            tempPrey.transform.parent = ecosystem.transform;
        }

        for (int i = 0; i < saveToLoad.predators.Count; i++)
        {
            GameObject tempPred = Instantiate(SavedPredator.loadPredator(saveToLoad.predators[i]));
            tempPred.transform.parent = ecosystem.transform;
        }

        for (int i = 0; i < saveToLoad.flora.Count; i++)
        {
            GameObject tempFlora = Instantiate(SavedFlora.loadFlora(saveToLoad.flora[i]));
            tempFlora.transform.parent = ecosystem.transform;
        }
        for (int i = 0; i < saveToLoad.floraNutrients.Count; i++)
        {
            GameObject tempNutrients = Instantiate(SavedFloraNutrient.loadNutrient(saveToLoad.floraNutrients[i]));
            tempNutrients.transform.parent = ecosystem.transform;
        }
        for (int i = 0; i < saveToLoad.faunaNutrients.Count; i++)
        {
            GameObject tempNutrients = Instantiate(SavedFaunaNutrient.loadNutrient(saveToLoad.faunaNutrients[i]));
            tempNutrients.transform.parent = ecosystem.transform;
        }

        for (int i = 0; i < saveToLoad.waterSources.Count; i++)
        {
            GameObject tempWater = Instantiate(Resources.Load("Prefabs/WaterSource") as GameObject, SavedWater.loadWaterPos(saveToLoad.waterSources[i]), Quaternion.identity);
            tempWater.transform.parent = ecosystem.transform;
            tempWater.tag = "waterSource";
        }
    }