Skip to content
Snippets Groups Projects
Commit 66b5bb5a authored by Eldar Hauge Torkelsen's avatar Eldar Hauge Torkelsen
Browse files

Fixed nullreference in genDemo

parent 6ef11386
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ public class CityGen : MonoBehaviour { ...@@ -33,6 +33,7 @@ public class CityGen : MonoBehaviour {
//TODO:add prefabs //TODO:add prefabs
this.pins = new Pin[1]; this.pins = new Pin[1];
this.pins[0] = new Pin();
this.pins[0].genDemo(id); this.pins[0].genDemo(id);
} }
} }
...@@ -48,11 +49,11 @@ public class CityGen : MonoBehaviour { ...@@ -48,11 +49,11 @@ public class CityGen : MonoBehaviour {
[System.Serializable] [System.Serializable]
public class Tile { public class Tile {
public int height; public int height;
public Transform transform; public Vector3 orientation;
public void genDemo(int id){ public void genDemo(int id){
this.height = 4 + id; this.height = 4 + id;
this.transform.rotation = new Quaternion(1.0f, 0.0f, 0.0f, 1); this.orientation = new Vector3(1.0f, 0.0f, 0.0f);
} }
} }
...@@ -62,7 +63,7 @@ public class CityGen : MonoBehaviour { ...@@ -62,7 +63,7 @@ public class CityGen : MonoBehaviour {
public Prefab[] prefabs; public Prefab[] prefabs;
public Vector2 layoutDimension; public Vector2 layoutDimension;
[HideInInspector] [HideInInspector]
public int[][] layout; public int[,] layout;
public Tile[] tiles; public Tile[] tiles;
/* /*
...@@ -73,8 +74,9 @@ public class CityGen : MonoBehaviour { ...@@ -73,8 +74,9 @@ public class CityGen : MonoBehaviour {
public void genDemo(){ public void genDemo(){
this.zoneTypes = new ZoneType[3]; this.zoneTypes = new ZoneType[3];
for(int i = 0; i < this.zoneTypes.Length; i++)
{ for(int i =0; i < zoneTypes.Length; i++){
zoneTypes[i] = new ZoneType();
zoneTypes[i].genDemo(i); zoneTypes[i].genDemo(i);
} }
...@@ -83,14 +85,24 @@ public class CityGen : MonoBehaviour { ...@@ -83,14 +85,24 @@ public class CityGen : MonoBehaviour {
this.layoutDimension.x = 5; this.layoutDimension.x = 5;
this.layoutDimension.y = 5; this.layoutDimension.y = 5;
this.layout[2][2] = 1; this.layout = new int[(int) this.layoutDimension.x,(int) this.layoutDimension.y];
this.layout[2][3] = -1; this.layout[2,2] = 1;
this.layout[3][2] = -1; this.layout[2,3] = -1;
this.layout[3][3] = -1; this.layout[3,2] = -1;
this.layout[3,3] = -1;
this.tiles = new Tile[25];
this.tiles[6] = new Tile();
this.tiles[6].genDemo(1); this.tiles[6].genDemo(1);
this.tiles[7] = new Tile();
this.tiles[7].genDemo(-1); this.tiles[7].genDemo(-1);
this.tiles[11] = new Tile();
this.tiles[11].genDemo(-1); this.tiles[11].genDemo(-1);
this.tiles[12] = new Tile();
this.tiles[12].genDemo(-1); this.tiles[12].genDemo(-1);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment