Created
January 28, 2014 03:06
-
-
Save wmiller/8661658 to your computer and use it in GitHub Desktop.
XML Database for Unity (Part 1) PlaceTile Method 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void PlaceTile(x, y, height) | |
{ | |
string path; | |
if (height == 0) | |
{ | |
path = "Tiles/WaterTile"; | |
} | |
else if (height == 1) | |
{ | |
path = "Tiles/GrassTile"; | |
} | |
else if (height == 2) | |
{ | |
path = "Tiles/DirtTile"; | |
} | |
else if (height == 3) | |
{ | |
path = "Tiles/StoneTile"; | |
} | |
else | |
{ | |
throw new System.Exception("Invalid height value"); | |
} | |
Instantiate(Resources.Load(path) as GameObject, | |
new Vector3(x * tileWidth, 0.0f, y * tileHeight), Quaternion.identity); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment