Commit 17ee1245 authored by Luke Smith's avatar Luke Smith

Changed map tool to use prefabs

parent d0e3b581
......@@ -19,7 +19,10 @@ public class MapLoader : MonoBehaviour {
int x = int.Parse (coords[0].ToString ());
int y = int.Parse (coords[1].ToString ());
Tile[,] map = GenerateTiles (x, y);
Tile[,] map = new Tile[y, x];
float startx;
float starty;
for (int i = 1; i < lines.Length - 1; i++) {
......@@ -29,14 +32,15 @@ public class MapLoader : MonoBehaviour {
y = int.Parse (args [1]);
map [x, y].walkable = bool.Parse (args [2]);
map [x, y].weight = float.Parse (args [3]);
if(map[x, y].walkable){
Destroy (map [x, y].GetComponent<BoxCollider2D> ());
}
map [x, y] = ((GameObject) Instantiate(Resources.Load<GameObject> ("Prefabs/" + args[4]))).GetComponent<Tile> ();
map [x, y].weight = float.Parse (args [3]);
startx = (float)x - (float)map.GetLength(0) / 2f;
starty = (float)y - (float)map.GetLength(1) / 2f;
map [x, y].transform.position = new Vector3 (startx, starty, 0);
map [x, y].GetComponent<SpriteRenderer> ().sprite = Resources.Load<Sprite> ("Tiles/" + args[4]);
}
Map.map = map;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment