// Generate Map Values private void GenerateValues() { // Get the Holder for all the map tiles if (tMapHolder != null) { // Check if the tree at the start is spawned yet or not if (iTree < refMapValue.GetMapValue(1)) { ++iTree; // Random generated position out of tile map size int iRandom = Mathf.RoundToInt(Random.Range(1.0f, tMapHolder.childCount)); // Loop Random Generation till tile is not obstructed while (tMapHolder.GetChild(iRandom).GetComponent <TileBehaviour>().GetInteraction(5) == true) { iRandom = Mathf.RoundToInt(Random.Range(1.0f, tMapHolder.childCount)); } // Get the tile of the randomized location and create a Tree on said position Transform tRandomTransform = tMapHolder.GetChild(iRandom).transform; Transform tTree = Instantiate(refMapValue.GetMapObject(1) as Object, tRandomTransform.position, Quaternion.identity) as Transform; tTree.parent = tEnvironmentHolder; // Set Tree's Parent Tile to set Tile as Obstructed tTree.GetComponent <Environment>().SetParentTile(tRandomTransform); // Setting Instantiated Values tTree.GetComponent <Environment>().SetReferences(refCore, refMapValue); tTree.GetComponent <Environment>().SetReferenceName("Wood"); tTree.GetComponent <Environment>().SetStageMax(3); tTree.GetComponent <Environment>().SetStageChange(5); tTree.GetComponent <Environment>().SetStageLevel(1); } // Check if the stone at the start is spawned yet or not if (iStone < refMapValue.GetMapValue(2)) { ++iStone; // Random generated position out of tile map size int iRandom = Mathf.RoundToInt(Random.Range(1.0f, tMapHolder.childCount)); // Loop Random Generation till tile is not obstructed while (tMapHolder.GetChild(iRandom).GetComponent <TileBehaviour>().GetInteraction(5) == true) { iRandom = Mathf.RoundToInt(Random.Range(1.0f, tMapHolder.childCount)); } // Get the tile of the randomized location and create a Stone on said position Transform tRandomTransform = tMapHolder.GetChild(iRandom).transform; Transform tStone = Instantiate(refMapValue.GetMapObject(2) as Object, tRandomTransform.position, Quaternion.identity) as Transform; tStone.parent = tEnvironmentHolder; // Set Tree's Parent Tile to set Tile as Obstructed tStone.GetComponent <Environment>().SetParentTile(tRandomTransform); // Setting Instantiated Values tStone.GetComponent <Environment>().SetReferences(refCore, refMapValue); tStone.GetComponent <Environment>().SetReferenceName("Stone"); tStone.GetComponent <Environment>().SetStageMax(2); tStone.GetComponent <Environment>().SetStageChange(8); tStone.GetComponent <Environment>().SetStageLevel(1); } } }