Skip to content
Snippets Groups Projects
Commit a2560e64 authored by Kent Holt's avatar Kent Holt
Browse files

Merge branch 'master' of prod3.imt.hig.no:Kent/CityGen

parents 90085ae6 40c68b68
Branches
No related tags found
No related merge requests found
......@@ -4,13 +4,94 @@ using UnityEngine;
public class CityGen : MonoBehaviour {
[System.Serializable]
public class Pin {
public Vector2 position;
public Vector2 radius;
}
[System.Serializable]
public class ZoneType {
public string zoneName;
[HideInInspector]
public int prefabsIndex;
public GameObject[] prefabs;
public Pin[] pins;
}
[System.Serializable]
public class Prefab {
[HideInInspector]
public int identifiers;
public Vector2 footprints;
public Vector2 offsetForFootprint;
}
[System.Serializable]
public class LayoutDimension {
public int width;
public int height;
}
[System.Serializable]
public class Tile {
public int height;
public int prefab;
public Transform transform;
}
[System.Serializable]
public class City {
public ZoneType[] zoneTypes;
public Prefab[] prefabs;
public LayoutDimension layoutDimension;
[HideInInspector]
public int[][] layout;
public Tile[] tiles;
/*
City() {
tiles = new Tile[layout.height * layout.width];
} */
void genDemo(){
}
}
public City city;
private string jsonFilePath = "/CityData/data.json";
// Use this for initialization
void Start () {
save();
load();
}
// Update is called once per frame
void Update () {
}
// Save the data about city.
void save (string fileName = "data") {
// Covert city ovject to json.
string cityDataAsJson = JsonUtility.ToJson(this.city);
//print(Application.persistentDataPath + this.jsonFilePath);
// Creates a directory in local disk.
System.IO.Directory.CreateDirectory(Application.persistentDataPath + "/CityData");
// Write all the data to a file.
System.IO.File.WriteAllText(Application.persistentDataPath + this.jsonFilePath, cityDataAsJson);
}
// Load the data about city.
void load(){
string cityDataAsJson = System.IO.File.ReadAllText(Application.persistentDataPath + this.jsonFilePath);
city = JsonUtility.FromJson<City>(cityDataAsJson);
}
}
......@@ -36,7 +36,7 @@
},{
"Identifiers":[
2,
11
0
],
"Footprint":[
[0, 0, 0],
......@@ -47,7 +47,7 @@
},{
"Identifiers":[
3,
13
-3
],
"Footprint":[
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment