États du jeu et detection du chargement
This commit is contained in:
parent
10f9301d3e
commit
a1277c3e87
@ -784,6 +784,9 @@ MonoBehaviour:
|
|||||||
distances:
|
distances:
|
||||||
- {fileID: 958716517}
|
- {fileID: 958716517}
|
||||||
- {fileID: 0}
|
- {fileID: 0}
|
||||||
|
_messages:
|
||||||
|
- {fileID: 1515287606}
|
||||||
|
- {fileID: 0}
|
||||||
maxSpeedsValues:
|
maxSpeedsValues:
|
||||||
- 0
|
- 0
|
||||||
- 0
|
- 0
|
||||||
@ -1106,11 +1109,11 @@ MonoBehaviour:
|
|||||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||||
m_FontData:
|
m_FontData:
|
||||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
m_FontSize: 70
|
m_FontSize: 300
|
||||||
m_FontStyle: 0
|
m_FontStyle: 0
|
||||||
m_BestFit: 0
|
m_BestFit: 0
|
||||||
m_MinSize: 3
|
m_MinSize: 3
|
||||||
m_MaxSize: 70
|
m_MaxSize: 300
|
||||||
m_Alignment: 4
|
m_Alignment: 4
|
||||||
m_AlignByGeometry: 0
|
m_AlignByGeometry: 0
|
||||||
m_RichText: 1
|
m_RichText: 1
|
||||||
|
|||||||
@ -30,13 +30,13 @@ public class BikeManager : MonoBehaviour {
|
|||||||
void Awake() {
|
void Awake() {
|
||||||
vm = gameObject.GetComponent<VideoManager>();
|
vm = gameObject.GetComponent<VideoManager>();
|
||||||
vm.SetSkin(playerID);
|
vm.SetSkin(playerID);
|
||||||
|
|
||||||
|
gm = GameManager.Instance;
|
||||||
|
gm.RegisterBike(this, playerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
gm = GameManager.Instance;
|
|
||||||
gm.RegisterBike(this, playerID);
|
|
||||||
|
|
||||||
distanceToRun = gm.GetRaceDistance();
|
distanceToRun = gm.GetRaceDistance();
|
||||||
|
|
||||||
taco = gameObject.AddComponent<RAWTachometer>();
|
taco = gameObject.AddComponent<RAWTachometer>();
|
||||||
@ -44,14 +44,12 @@ public class BikeManager : MonoBehaviour {
|
|||||||
|
|
||||||
|
|
||||||
normalSpeed = distanceToRun / vm.raceFinishTime;
|
normalSpeed = distanceToRun / vm.raceFinishTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update () {
|
void Update () {
|
||||||
|
|
||||||
//Speed = getBikeSpeedLegacy(speedIntegrationTime);
|
|
||||||
Speed = taco.GetSpeed();
|
Speed = taco.GetSpeed();
|
||||||
|
|
||||||
vm.speed = Speed / normalSpeed;
|
vm.speed = Speed / normalSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,12 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
public enum States {
|
||||||
|
Menu = 0,
|
||||||
|
RaceSetup = 1,
|
||||||
|
Race = 2
|
||||||
|
}
|
||||||
|
|
||||||
public class GameManager : MonoBehaviour {
|
public class GameManager : MonoBehaviour {
|
||||||
private static GameManager _instance;
|
private static GameManager _instance;
|
||||||
|
|
||||||
@ -14,6 +20,9 @@ public class GameManager : MonoBehaviour {
|
|||||||
private BikeManager bm1;
|
private BikeManager bm1;
|
||||||
private BikeManager bm2;
|
private BikeManager bm2;
|
||||||
|
|
||||||
|
private States _status;
|
||||||
|
public States Status {get {return _status;} }
|
||||||
|
|
||||||
// Skins of the two players
|
// Skins of the two players
|
||||||
private int[] _skins = new int[2];
|
private int[] _skins = new int[2];
|
||||||
|
|
||||||
@ -32,6 +41,10 @@ public class GameManager : MonoBehaviour {
|
|||||||
DontDestroyOnLoad(transform.gameObject);
|
DontDestroyOnLoad(transform.gameObject);
|
||||||
|
|
||||||
conf = new ConfigurationLoader();
|
conf = new ConfigurationLoader();
|
||||||
|
|
||||||
|
_status = States.Menu;
|
||||||
|
|
||||||
|
// TODO: Load Menu
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start() {
|
private void Start() {
|
||||||
@ -92,12 +105,53 @@ public class GameManager : MonoBehaviour {
|
|||||||
return _skins[playerID];
|
return _skins[playerID];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove once menus are ok
|
||||||
void Update() {
|
void Update() {
|
||||||
if (Input.GetButtonDown("SubmitP1")) {
|
if (Input.GetButtonDown("SubmitP1")) {
|
||||||
Debug.Log("Héhé Cancel");
|
Debug.Log("Héhé Cancel");
|
||||||
SetSkins(0, 0);
|
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 Text[] maxSpeeds;
|
||||||
public HUDProgress[] progressions;
|
public HUDProgress[] progressions;
|
||||||
public Text[] distances;
|
public Text[] distances;
|
||||||
|
[SerializeField]
|
||||||
|
|
||||||
|
private GameObject[] _messages;
|
||||||
|
public GameObject[] Messages {get {return _messages;} }
|
||||||
|
|
||||||
public float[] maxSpeedsValues = new float[2];
|
public float[] maxSpeedsValues = new float[2];
|
||||||
|
|
||||||
GameManager gm;
|
GameManager gm;
|
||||||
|
|
||||||
void Awake() {
|
void Awake() {
|
||||||
|
gm = GameManager.Instance;
|
||||||
|
gm.RegisterHUD(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
void Start () {
|
void Start () {
|
||||||
gm = GameManager.Instance;
|
|
||||||
gm.RegisterHUD(this);
|
|
||||||
gm.Hello();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// 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";
|
tachometers[bikeID].text = (s * 3.6f).ToString("#0.0") + "km/h";
|
||||||
maxSpeeds[bikeID].text = "Max : " + (maxSpeedsValues[bikeID] * 3.6f).ToString("#0.0");
|
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() {
|
void Update() {
|
||||||
|
if (GameManager.Instance.Status != States.Race)
|
||||||
|
return;
|
||||||
if (Input.GetButtonDown(inputID))
|
if (Input.GetButtonDown(inputID))
|
||||||
RegisterTic();
|
RegisterTic();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user