Example #1
0
    public void AddPlantToPlantManagerFromParents(int newPlantIndex, int parentIndex1, int parentIndex2, int plantTextureIndex, string plantName)
    {
        while (GameManager.gm.pm.plantsPrefabs.Count < newPlantIndex)
        {
            GameManager.gm.pm.plantsPrefabs.Add(null);
        }

        Plant p = CrossPlants(GameManager.gm.pm.plantsPrefabs [parentIndex1],
                              GameManager.gm.pm.plantsPrefabs [parentIndex2], newPlantIndex);

        p.name = plantName;

        p.parentIndex1 = parentIndex1;
        p.parentIndex2 = parentIndex2;

        p.plantTypeIndex = newPlantIndex;

        p.plantTextureIndex = plantTextureIndex;

        GameManager.gm.pm.plantsPrefabs.Add(p);
        GameManager.gm.pm.crossedPlants.Add(p);

        PlantInformation pinfo = new PlantInformation(plantName);

        pinfo.plantTexture = GameManager.gm.pm.plantInformations[plantTextureIndex].plantTexture;

        pinfo.plantLatinName = GameManager.gm.pm.plantInformations [parentIndex1].plantLatinName
                               + " " + GameManager.gm.pm.plantInformations [parentIndex2].plantLatinName;

        pinfo.plantDescription = "This plant is coss-breeding between " + GameManager.gm.pm.plantInformations [parentIndex1].plantName
                                 + " and " + GameManager.gm.pm.plantInformations [parentIndex2].plantName;

        GameManager.gm.pm.plantInformations.Add(pinfo);
    }
Example #2
0
 public void InitializePlantInfoTab()
 {
     for (int i = 0; i < plantsPrefabs.Count; i++)
     {
         if (plantInformations.Count - 1 < i)
         {
             plantInformations.Add(new PlantInformation());
         }
         plantInformations [i] = new PlantInformation(plantsPrefabs [i].name);
     }
 }
    public void LoadPlants()
    {
        Debug.Log("Creating Plants");

        string plantFolderPath = Application.persistentDataPath + "/Plants/";

        if (!Directory.Exists(plantFolderPath))
        {
            Directory.CreateDirectory(plantFolderPath);
        }

        string[] plantPaths = System.IO.Directory.GetFiles(plantFolderPath);

        for (int i = 0; i < plantPaths.Length; i++)
        {
            string path = plantPaths [i];

            if (path.Contains(".grenplant"))
            {
                string plantName = path.Substring(path.LastIndexOf("/") + 1, path.Length - path.LastIndexOf("/") - 11);
                //string textureName = paths [j].Substring (paths [j].LastIndexOf ("_") + 1, paths [j].Length - paths [j].LastIndexOf ("_") - 5);

                Debug.Log("plantName = " + plantName);

                Plant p = CreatePrefabFromFile(path, plantName);

                pm.plantsPrefabs.Add(p);

                PlantInformation pinfo = new PlantInformation(p.name);
                pinfo.plantTexture     = p.leafPrefab.GetComponent <MeshRenderer> ().material.mainTexture;
                pinfo.plantDescription = "This plant has been created by a player!";

                pm.plantInformations.Add(pinfo);
            }
        }
    }