Exemplo n.º 1
0
 static void CreateProceduralTree()
 {
     var procTree = new GameObject(string.Format("Tree_{0:X4}", Random.Range(0, 65536))).AddComponent<ProcTree>();
     procTree.seed = Random.Range(0, 65536);
     procTree.RandomizeSettings();
     procTree.Generate(Random.Range(0f, 1f) <= 0.5f ? true : false);
 }
Exemplo n.º 2
0
 static void CreateProceduralBuilding()
 {
     var procBuilding = new GameObject(string.Format("Building_{0:X4}", Random.Range(0, 65536))).AddComponent<Building>();
     procBuilding.seed = Random.Range(0, 65536);
     procBuilding.RandomizeSettings();
     procBuilding.Generate();
 }
Exemplo n.º 3
0
        public List<GameObject> CreateListOfPrefabs(List<GameObject> prefabList, int cone, int house, float scale)
        {
            List<GameObject> prefabs = new List<GameObject>();

            if (prefabList.Count == 0)
            {
                if (house == -1)
                    Debug.Log("Please choose number of tree types");
                else
                    Debug.Log("Please choose number of building types");
            }
            else
            {
                for (int i = 0; i < prefabList.Count; i++)
                {
                    if (prefabList[i] == null)
                    {
                        if (house == -1)
                        {
                            ProcTree procTree = new GameObject("tree").AddComponent<ProcTree>();
                            procTree.RandomizeSettings();
                            procTree.Generate(cone == 0 ? true : false);
                            prefabs.Add(procTree.gameObject);
                        }
                        else
                        {
                            Building procBuilding = new GameObject("building").AddComponent<Building>();
                            procBuilding.RandomizeSettings();
                            procBuilding.Generate();
                            procBuilding.floors = house == 0 ? Random.Range(1, 5) : Random.Range(5, 9);
                            prefabs.Add(procBuilding.gameObject);
                        }
                    }
                    else
                    {
                        prefabs.Add(prefabList[i]);
                    }
                }
            }
            return prefabs;
        }