diff --git a/Assets/Resources/Prefab/HUDGuiPanel.prefab b/Assets/Resources/Prefab/HUDGuiPanel.prefab index c4bf204..b40c550 100644 --- a/Assets/Resources/Prefab/HUDGuiPanel.prefab +++ b/Assets/Resources/Prefab/HUDGuiPanel.prefab @@ -180,7 +180,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!1 &1528636508113776 GameObject: m_ObjectHideFlags: 0 @@ -747,7 +747,7 @@ MonoBehaviour: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1611160567533310} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} m_Name: diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index 1baac71..55acf17 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -504,7 +504,9 @@ MonoBehaviour: distances: - {fileID: 35645299} - {fileID: 35645298} - _messages: [] + _messages: + - {fileID: 809585328} + - {fileID: 1221836132} loadingScreens: {fileID: 1823713982} --- !u!1 &333802245 stripped GameObject: @@ -2412,6 +2414,11 @@ GameObject: m_PrefabParentObject: {fileID: 1051963178499332, guid: d5df03a0612222947a30c5be4549acdb, type: 2} m_PrefabInternal: {fileID: 769513574} +--- !u!1 &809585328 stripped +GameObject: + m_PrefabParentObject: {fileID: 1611160567533310, guid: ff612e4aca9ee264abcb6222d1827faa, + type: 2} + m_PrefabInternal: {fileID: 35645296} --- !u!1 &810324921 GameObject: m_ObjectHideFlags: 0 @@ -2828,6 +2835,80 @@ Canvas: m_SortingLayerID: 0 m_SortingOrder: 0 m_TargetDisplay: 0 +--- !u!1 &969461825 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 969461826} + - component: {fileID: 969461828} + - component: {fileID: 969461827} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &969461826 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 969461825} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1714708930} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 0} + m_AnchoredPosition: {x: 0, y: 120} + m_SizeDelta: {x: 1600, y: 900} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &969461827 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 969461825} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.92156863, g: 0.91764706, b: 0.7019608, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 12800000, guid: 8a697d283fb701b4a9a210c0e58f6a5e, type: 3} + m_FontSize: 100 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 100 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 1 + m_LineSpacing: 1 + m_Text: New Text +--- !u!222 &969461828 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 969461825} --- !u!1 &1010512803 GameObject: m_ObjectHideFlags: 0 @@ -2914,6 +2995,7 @@ RectTransform: m_LocalScale: {x: 0, y: 0, z: 0} m_Children: - {fileID: 1709902429} + - {fileID: 1543364354} m_Father: {fileID: 0} m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -3708,6 +3790,11 @@ GameObject: m_PrefabParentObject: {fileID: 1051963178499332, guid: d5df03a0612222947a30c5be4549acdb, type: 2} m_PrefabInternal: {fileID: 1219135225} +--- !u!1 &1221836132 stripped +GameObject: + m_PrefabParentObject: {fileID: 1611160567533310, guid: ff612e4aca9ee264abcb6222d1827faa, + type: 2} + m_PrefabInternal: {fileID: 46136831} --- !u!1001 &1233904144 Prefab: m_ObjectHideFlags: 0 @@ -4465,6 +4552,7 @@ MonoBehaviour: - {fileID: 1143442403} PseudoText: {fileID: 0} TimeText: {fileID: 516481042} + WaitText: {fileID: 969461827} TransportImage: {fileID: 355284124} rank: 0 Player2: 0 @@ -4842,6 +4930,80 @@ GameObject: m_PrefabParentObject: {fileID: 1051963178499332, guid: d5df03a0612222947a30c5be4549acdb, type: 2} m_PrefabInternal: {fileID: 759881876} +--- !u!1 &1543364353 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1543364354} + - component: {fileID: 1543364356} + - component: {fileID: 1543364355} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &1543364354 +RectTransform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1543364353} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1010512807} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0} + m_AnchorMax: {x: 0.5, y: 0} + m_AnchoredPosition: {x: 0, y: 120} + m_SizeDelta: {x: 1600, y: 900} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1543364355 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1543364353} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.92156863, g: 0.91764706, b: 0.7019608, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 12800000, guid: 8a697d283fb701b4a9a210c0e58f6a5e, type: 3} + m_FontSize: 100 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 100 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 1 + m_LineSpacing: 1 + m_Text: New Text +--- !u!222 &1543364356 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1543364353} --- !u!1 &1575000530 GameObject: m_ObjectHideFlags: 0 @@ -4985,6 +5147,7 @@ MonoBehaviour: - {fileID: 651808758} PseudoText: {fileID: 0} TimeText: {fileID: 1435436163} + WaitText: {fileID: 1543364355} TransportImage: {fileID: 576874148} rank: 0 Player2: 0 @@ -5294,6 +5457,7 @@ RectTransform: m_LocalScale: {x: 0, y: 0, z: 0} m_Children: - {fileID: 1840779489} + - {fileID: 969461826} m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/GameScene/BikeManager.cs b/Assets/Scripts/GameScene/BikeManager.cs index a6e61d4..ded7700 100644 --- a/Assets/Scripts/GameScene/BikeManager.cs +++ b/Assets/Scripts/GameScene/BikeManager.cs @@ -24,6 +24,7 @@ public class BikeManager : MonoBehaviour { private GameManager gm; public bool finished = false; + public float finishTime; void Awake() { vm = gameObject.GetComponent(); diff --git a/Assets/Scripts/GameScene/GameManager.cs b/Assets/Scripts/GameScene/GameManager.cs index 5c110fc..ba5e12b 100644 --- a/Assets/Scripts/GameScene/GameManager.cs +++ b/Assets/Scripts/GameScene/GameManager.cs @@ -74,6 +74,8 @@ public class GameManager : MonoBehaviour private ConfigurationLoader conf; + private float startTime; + private void Awake() { // Singleton @@ -194,10 +196,12 @@ public class GameManager : MonoBehaviour } else if (_status == States.Race) { if (bm1.GetProgress () >= 1 && ! bm1.finished) { bm1.finished = true; + bm1.finishTime = GetChrono (); StartCoroutine(PlayerFinished(0)); } if (bm2.GetProgress () >= 1 && ! bm2.finished) { bm2.finished = true; + bm2.finishTime = GetChrono (); StartCoroutine(PlayerFinished(1)); } } @@ -225,7 +229,7 @@ public class GameManager : MonoBehaviour } public float GetChrono() { - return Time.time; + return Time.time - startTime; } void OnEnable() @@ -249,6 +253,8 @@ public class GameManager : MonoBehaviour // Timer yield return new WaitForSeconds(2f); hm.SetMessage("Pédalez !"); + startTime = Time.time; + hm.SetActiveChrono (true); _status = States.Race; // Timer yield return new WaitForSeconds(1f); @@ -271,6 +277,11 @@ public class GameManager : MonoBehaviour yield return new WaitForSeconds(2f); + if (playerID == 0) + EntryP1.time = TimeSpan.FromSeconds(bm1.finishTime); + else + EntryP2.time = TimeSpan.FromSeconds(bm2.finishTime); + hm.SetHighScore (playerID); } diff --git a/Assets/Scripts/GameScene/HUDManager.cs b/Assets/Scripts/GameScene/HUDManager.cs index f6da5fc..6ce32a2 100644 --- a/Assets/Scripts/GameScene/HUDManager.cs +++ b/Assets/Scripts/GameScene/HUDManager.cs @@ -54,6 +54,11 @@ public class HUDManager : MonoBehaviour { flags [bikeID].SetActive (gm.GetFirst () == bikeID); } + public void SetActiveChrono(bool active) { + chronos [0].gameObject.SetActive (active); + chronos [1].gameObject.SetActive (active); + } + void UpdateChrono(int bikeID) { float time = gm.GetChrono (); TimeSpan timeSpan = TimeSpan.FromSeconds(time); diff --git a/Assets/Scripts/HighscoreRecordMenuManager.cs b/Assets/Scripts/HighscoreRecordMenuManager.cs index 60a06c9..f3d6f66 100644 --- a/Assets/Scripts/HighscoreRecordMenuManager.cs +++ b/Assets/Scripts/HighscoreRecordMenuManager.cs @@ -61,7 +61,11 @@ public class HighscoreRecordMenuManager : BaseInputBehavior { if (waitFor) { - if(WaitText!=null) WaitText.text = "En attente du joueur " + (Player2 ? "2" : "1"); + if (WaitText != null) { + WaitText.gameObject.SetActive (true); + WaitText.text = "En attente du joueur " + (Player2 ? "2" : "1"); + + } if (Recorders[OtherPlayerIndex].Finished) GameManager.Instance.DisplayMenu(); } @@ -100,7 +104,7 @@ public class HighscoreRecordMenuManager : BaseInputBehavior private void Finish() { Finished = true; - if (!Recorders[OtherPlayerIndex].Finished) + if (Recorders[OtherPlayerIndex]==null || !Recorders[OtherPlayerIndex].Finished) { waitFor = true; } @@ -111,7 +115,7 @@ public class HighscoreRecordMenuManager : BaseInputBehavior { Finished = false; waitFor = false; - + WaitText.gameObject.SetActive (false); //on récupère le highscore du joueur Entry = Player2 ? GameManager.Instance.EntryP2 : GameManager.Instance.EntryP1; CheckEntry(); diff --git a/Assets/StreamingAssets/highscores.json b/Assets/StreamingAssets/highscores.json index 74b79ba..3793aa4 100644 --- a/Assets/StreamingAssets/highscores.json +++ b/Assets/StreamingAssets/highscores.json @@ -1 +1 @@ -{"Items":[{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Tata","transport":0,"timeStr":"0:30:30"},{"pseudo":"Titi","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"}]} +{"Items":[{"pseudo":"PRENOM","transport":0,"timeStr":"0:28:20"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Tata","transport":0,"timeStr":"0:30:30"},{"pseudo":"Titi","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"},{"pseudo":"Toto","transport":0,"timeStr":"0:30:30"}]}