Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Level[] levels;
- [System.Serializable]
- public class Level
- {
- public int levelNo;
- public Road[] roads;
- }
- [System.Serializable]
- public class Road
- {
- public int roadNo; //0-1-2 leftmost is 0
- public string[] roadNames;
- public float[] roadYOffsets;
- }
- private void readJson()
- {
- jsonPath = Path.Combine(Application.streamingAssetsPath , "LevelConfig.json");
- string json = File.ReadAllText(jsonPath);
- levels = JsonHelper.FromJson<Level>(json);
- int i = 0;
- Debug.Log(levels[i].roads.Length);
- for(i=0;i<levels[0].roads.Length;i++)
- {
- Debug.Log(levels[0].roads[i].roadNo);
- }
- while(i < levels.Length)
- {
- levels[i].roads = JsonHelper.FromJson<Road>(json);
- i++;
- }
- i = 0;
- int j;
- while (i<levels.Length)
- {
- j=0;
- while (j < levels[i].roads.Length)
- {
- int k = 0;
- while (k < levels[i].roads[j].roadNames.Length)
- {
- Debug.Log(levels[i].levelNo + " roadno" + levels[i].roads[j].roadNo + " roadtype" + levels[i].roads[j].roadNames[k] + " offsets" + levels[i].roads[j].roadYOffsets[k]);
- k++;
- }
- j++;
- }
- i++;
- }
- }
- {
- "Levels":
- [
- {
- "levelNo": 1,
- "roads":
- [
- {
- "roadNo": 0,
- "roadNames": [ "DefaultRoad", "DefaultRoad", "DefaultRoad", "DefaultRoad" ],
- "roadYOffsets": [ 0, 1, -1, 0 ]
- }
- ]
- }
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement