gold_sprint_lpr/Assets/Scripts/GameScene/GameManager.cs
2018-03-11 22:47:34 +01:00

60 lines
1.5 KiB
C#

using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour {
private static GameManager _instance;
public static GameManager Instance {get {return _instance; } }
private HUDManager hm;
private BikeManager bm1;
private BikeManager bm2;
private void Awake(){
if (_instance != null && _instance != this) {
Debug.Log("WARNING: Other instance of GameManager found.");
Destroy(gameObject);
} else {
_instance = this;
}
}
private void Start() {
if (hm == null)
Debug.Log("ERROR: HUDManager not registered.");
if (bm1 == null)
Debug.Log("ERROR: BikeManager P1 not registered.");
if (bm2 == null)
Debug.Log("ERROR: BikeManager P2 not registered.");
var sr = new StreamReader(Application.streamingAssetsPath + "/config.json");
JSONObject obj = new JSONObject(sr.ReadToEnd());
Debug.Log(obj["Race"]["Length"]);
}
public void RegisterBike(BikeManager bike, int bikeID) {
if (bikeID == 0)
bm1 = bike;
if (bikeID == 1)
bm2 = bike;
}
public void RegisterHUD(HUDManager hud) {
hm = hud;
}
public BikeManager GetBikeManager(int bikeID) {
if (bikeID == 0)
return bm1;
if (bikeID == 1)
return bm2;
return null;
}
public void Hello() {
Debug.Log("Hello!");
}
}