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

Merge branch 'Simulation' of http://prod3.imt.hig.no/Kent/CityGen into Simulation

parents db4e9be9 a6badd4f
No related branches found
No related tags found
No related merge requests found
...@@ -31,6 +31,8 @@ public partial class CityGen : MonoBehaviour { ...@@ -31,6 +31,8 @@ public partial class CityGen : MonoBehaviour {
this.prefabsIndex = id; this.prefabsIndex = id;
//TODO:add prefabs //TODO:add prefabs
this.prefabs = new GameObject[1];
this.prefabs[0] = Resources.Load<GameObject>("House/House");
this.pins = new Pin[1]; this.pins = new Pin[1];
this.pins[0] = new Pin(); this.pins[0] = new Pin();
...@@ -41,9 +43,19 @@ public partial class CityGen : MonoBehaviour { ...@@ -41,9 +43,19 @@ public partial class CityGen : MonoBehaviour {
[System.Serializable] [System.Serializable]
public class Prefab { public class Prefab {
[HideInInspector] [HideInInspector]
public int identifiers; public int identifier;
public Vector2 footprints; public Vector2 footprint;
public Vector2 offsetForFootprint; public Vector2 offsetForFootprint;
public void genDemo(GameObject prefab, int id){
this.identifier = id;
this.footprint.x = prefab.GetComponentInChildren<Renderer>().bounds.max.x - prefab.GetComponentInChildren<Renderer>().bounds.min.x;
this.footprint.y = prefab.GetComponentInChildren<Renderer>().bounds.max.y - prefab.GetComponentInChildren<Renderer>().bounds.min.y;
this.offsetForFootprint.x = prefab.GetComponentInChildren<Renderer>().bounds.min.x;
this.offsetForFootprint.y = prefab.GetComponentInChildren<Renderer>().bounds.min.y;
}
} }
[System.Serializable] [System.Serializable]
...@@ -60,7 +72,7 @@ public partial class CityGen : MonoBehaviour { ...@@ -60,7 +72,7 @@ public partial class CityGen : MonoBehaviour {
[System.Serializable] [System.Serializable]
public class City { public class City {
public ZoneType[] zoneTypes; public ZoneType[] zoneTypes;
public Prefab[] prefabs; public List<Prefab> prefabs;
public Vector2 layoutDimension; public Vector2 layoutDimension;
[HideInInspector] [HideInInspector]
public int[,] layout; public int[,] layout;
...@@ -81,7 +93,22 @@ public partial class CityGen : MonoBehaviour { ...@@ -81,7 +93,22 @@ public partial class CityGen : MonoBehaviour {
} }
//TODO: add prefabs //TODO: add prefabs
int id = 0;
foreach(ZoneType zone in zoneTypes){
foreach(GameObject prefab in zone.prefabs){
prefabs.Add(new Prefab());
prefabs[prefabs.Count - 1].genDemo(prefab, id);
}
id++;
}
/*
this.prefabs = new Prefab[4];
for(int i = 0; i < prefabs.Length; i++){
prefabs[i] = new Prefab();
prefabs[i].genDemo(i);
}
*/
this.layoutDimension.x = 5; this.layoutDimension.x = 5;
this.layoutDimension.y = 5; this.layoutDimension.y = 5;
......
...@@ -121,11 +121,12 @@ public partial class CityGen : MonoBehaviour { ...@@ -121,11 +121,12 @@ public partial class CityGen : MonoBehaviour {
//house.GetComponent<Renderer>().material.color = new Color(1, 0, 0, 1); //house.GetComponent<Renderer>().material.color = new Color(1, 0, 0, 1);
//print(cube.GetComponent<Renderer>().bounds.max); //print(cube.GetComponent<Renderer>().bounds.max);
Instantiate(house, Vector3.zero, Quaternion.identity);
house.transform.position = new Vector3(house.transform.position.x + j + house.GetComponentInChildren<Renderer>().bounds.max.x, Vector3 position = new Vector3 (transform.position.x + j + house.GetComponentInChildren<Renderer>().bounds.max.x,
house.transform.position.y, transform.position.y,
house.transform.position.z + i + house.GetComponentInChildren<Renderer>().bounds.max.z); transform.position.z + i + house.GetComponentInChildren<Renderer>().bounds.max.z);
Instantiate(house, position, Quaternion.identity);
//print(cube.GetComponent<Renderer>().bounds.max); //print(cube.GetComponent<Renderer>().bounds.max);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment