États du jeu et detection du chargement
This commit is contained in:
parent
10f9301d3e
commit
a1277c3e87
@ -784,6 +784,9 @@ MonoBehaviour:
|
||||
distances:
|
||||
- {fileID: 958716517}
|
||||
- {fileID: 0}
|
||||
_messages:
|
||||
- {fileID: 1515287606}
|
||||
- {fileID: 0}
|
||||
maxSpeedsValues:
|
||||
- 0
|
||||
- 0
|
||||
@ -1106,11 +1109,11 @@ MonoBehaviour:
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 70
|
||||
m_FontSize: 300
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 0
|
||||
m_MinSize: 3
|
||||
m_MaxSize: 70
|
||||
m_MaxSize: 300
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 1
|
||||
|
@ -30,13 +30,13 @@ public class BikeManager : MonoBehaviour {
|
||||
void Awake() {
|
||||
vm = gameObject.GetComponent<VideoManager>();
|
||||
vm.SetSkin(playerID);
|
||||
|
||||
gm = GameManager.Instance;
|
||||
gm.RegisterBike(this, playerID);
|
||||
}
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
gm = GameManager.Instance;
|
||||
gm.RegisterBike(this, playerID);
|
||||
|
||||
distanceToRun = gm.GetRaceDistance();
|
||||
|
||||
taco = gameObject.AddComponent<RAWTachometer>();
|
||||
@ -44,14 +44,12 @@ public class BikeManager : MonoBehaviour {
|
||||
|
||||
|
||||
normalSpeed = distanceToRun / vm.raceFinishTime;
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
//Speed = getBikeSpeedLegacy(speedIntegrationTime);
|
||||
Speed = taco.GetSpeed();
|
||||
|
||||
vm.speed = Speed / normalSpeed;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,12 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public enum States {
|
||||
Menu = 0,
|
||||
RaceSetup = 1,
|
||||
Race = 2
|
||||
}
|
||||
|
||||
public class GameManager : MonoBehaviour {
|
||||
private static GameManager _instance;
|
||||
|
||||
@ -14,6 +20,9 @@ public class GameManager : MonoBehaviour {
|
||||
private BikeManager bm1;
|
||||
private BikeManager bm2;
|
||||
|
||||
private States _status;
|
||||
public States Status {get {return _status;} }
|
||||
|
||||
// Skins of the two players
|
||||
private int[] _skins = new int[2];
|
||||
|
||||
@ -32,6 +41,10 @@ public class GameManager : MonoBehaviour {
|
||||
DontDestroyOnLoad(transform.gameObject);
|
||||
|
||||
conf = new ConfigurationLoader();
|
||||
|
||||
_status = States.Menu;
|
||||
|
||||
// TODO: Load Menu
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
@ -92,12 +105,53 @@ public class GameManager : MonoBehaviour {
|
||||
return _skins[playerID];
|
||||
}
|
||||
|
||||
// TODO: Remove once menus are ok
|
||||
void Update() {
|
||||
if (Input.GetButtonDown("SubmitP1")) {
|
||||
Debug.Log("Héhé Cancel");
|
||||
SetSkins(0, 0);
|
||||
SceneManager.LoadScene("GameScene");
|
||||
}
|
||||
Debug.Log("azee");
|
||||
}
|
||||
|
||||
public void LaunchRace() {
|
||||
_status = States.RaceSetup;
|
||||
StartCoroutine(LoadGameScene());
|
||||
}
|
||||
|
||||
void OnLevelFinishedLoading(Scene scene, LoadSceneMode mode) {
|
||||
// TODO: Check game status
|
||||
if (_status == States.RaceSetup) {
|
||||
StartCoroutine(SetupRace());
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable() {
|
||||
SceneManager.sceneLoaded += OnLevelFinishedLoading;
|
||||
}
|
||||
|
||||
void OnDisable() {
|
||||
SceneManager.sceneLoaded -= OnLevelFinishedLoading;
|
||||
}
|
||||
|
||||
IEnumerator SetupRace() {
|
||||
hm.SetMessageActive(false);
|
||||
// Timer
|
||||
//yield return new WaitForSeconds(3f);
|
||||
hm.SetMessageActive(true);
|
||||
hm.SetMessage("Prêts ?");
|
||||
// Timer
|
||||
yield return new WaitForSeconds(2f);
|
||||
hm.SetMessage("Pédalez !");
|
||||
_status = States.Race;
|
||||
// Timer
|
||||
yield return new WaitForSeconds(1f);
|
||||
hm.SetMessageActive(false);
|
||||
}
|
||||
|
||||
|
||||
IEnumerator LoadGameScene() {
|
||||
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("GameScene");
|
||||
while (!asyncLoad.isDone)
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
@ -9,19 +9,22 @@ public class HUDManager : MonoBehaviour {
|
||||
public Text[] maxSpeeds;
|
||||
public HUDProgress[] progressions;
|
||||
public Text[] distances;
|
||||
[SerializeField]
|
||||
|
||||
private GameObject[] _messages;
|
||||
public GameObject[] Messages {get {return _messages;} }
|
||||
|
||||
public float[] maxSpeedsValues = new float[2];
|
||||
|
||||
GameManager gm;
|
||||
|
||||
void Awake() {
|
||||
gm = GameManager.Instance;
|
||||
gm.RegisterHUD(this);
|
||||
}
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
gm = GameManager.Instance;
|
||||
gm.RegisterHUD(this);
|
||||
gm.Hello();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@ -48,4 +51,14 @@ public class HUDManager : MonoBehaviour {
|
||||
tachometers[bikeID].text = (s * 3.6f).ToString("#0.0") + "km/h";
|
||||
maxSpeeds[bikeID].text = "Max : " + (maxSpeedsValues[bikeID] * 3.6f).ToString("#0.0");
|
||||
}
|
||||
|
||||
public void SetMessageActive(bool status) {
|
||||
Messages[0].SetActive(status);
|
||||
// Messages[1].SetActive(status);
|
||||
}
|
||||
|
||||
public void SetMessage(string message) {
|
||||
Messages[0].GetComponent<Text>().text = message;
|
||||
// Messages[1].GetComponent<Text>().text = message;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ public abstract class Tachometer : MonoBehaviour {
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (GameManager.Instance.Status != States.Race)
|
||||
return;
|
||||
if (Input.GetButtonDown(inputID))
|
||||
RegisterTic();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user