73 lines
1.7 KiB
C#
73 lines
1.7 KiB
C#
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;
|
|
|
|
ConfigurationLoader conf;
|
|
|
|
private void Awake(){
|
|
// Singleton
|
|
if (_instance != null && _instance != this) {
|
|
Debug.Log("WARNING: Other instance of GameManager found.");
|
|
Destroy(gameObject);
|
|
} else {
|
|
_instance = this;
|
|
}
|
|
|
|
conf = new ConfigurationLoader();
|
|
}
|
|
|
|
private void Start() {
|
|
// Quick Check
|
|
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.");
|
|
}
|
|
|
|
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!");
|
|
}
|
|
|
|
public float GetRaceDistance() {
|
|
return conf.distance;
|
|
}
|
|
|
|
public float GetRaceNormalTime() {
|
|
return conf.normalTime;
|
|
}
|
|
|
|
public float GetBikeWheelDiameter(int bikeID) {
|
|
return conf.diameters[bikeID];
|
|
}
|
|
}
|