41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using System.IO;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ConfigurationLoader {
|
|
|
|
private string filename = Application.streamingAssetsPath + "/config.json";
|
|
|
|
public float distance;
|
|
public float normalTime;
|
|
public float[] diameters = new float[2];
|
|
|
|
public ConfigurationLoader() {
|
|
Load();
|
|
Check();
|
|
}
|
|
|
|
private void Load() {
|
|
var sr = new StreamReader(Application.streamingAssetsPath + "/config.json");
|
|
var obj = new JSONObject(sr.ReadToEnd());
|
|
|
|
distance = obj["Course"]["Distance"].n;
|
|
normalTime = obj["Course"]["TempsNormal"].n;
|
|
diameters[0] = obj["Vélos"]["Joueur1"]["DiamètreRoue"].n / 1000f;
|
|
diameters[1] = obj["Vélos"]["Joueur2"]["DiamètreRoue"].n / 1000f;
|
|
}
|
|
|
|
private void Check() {
|
|
// TODO: Throw ? Fallback ?
|
|
if (distance < .01f)
|
|
Debug.Log("WARNING ConfigurationLoader: Distance is 0");
|
|
if (normalTime < .01f)
|
|
Debug.Log("WARNING ConfigurationLoader: NormalTime is 0");
|
|
if (diameters[0] < .001f)
|
|
Debug.Log("WARNING ConfigurationLoader: Diameter for player 1 is 0");
|
|
if (diameters[1] < .001f)
|
|
Debug.Log("WARNING ConfigurationLoader: Diameter for player 2 is 0");
|
|
}
|
|
}
|