From 69c51ec879f116ecd5bb71ff3f228f7c348b4bdc Mon Sep 17 00:00:00 2001 From: magn9775 Date: Fri, 26 Apr 2024 15:58:44 +0200 Subject: [PATCH] done? --- .../Timers/Car Customization_timers.json | 2 +- .../Timers/ForestRacetrack_timers.json | 2 +- Assets/ML-Agents/Timers/WinScreen_timers.json | 6 +- Assets/Scenes/ForestRacetrack.unity | 148 +++++++++++++++++- Assets/Scripts/GameManager.cs | 56 ++++++- Assets/Scripts/PlayerController.cs | 2 +- Assets/Scripts/WinScript.cs | 5 +- 7 files changed, 205 insertions(+), 16 deletions(-) diff --git a/Assets/ML-Agents/Timers/Car Customization_timers.json b/Assets/ML-Agents/Timers/Car Customization_timers.json index 96c3c36..0565b70 100644 --- a/Assets/ML-Agents/Timers/Car Customization_timers.json +++ b/Assets/ML-Agents/Timers/Car Customization_timers.json @@ -1 +1 @@ -{"count":1,"self":10.6869432,"total":10.777194099999999,"children":{"InitializeActuators":{"count":8,"self":0.0035095,"total":0.0035095,"children":null},"InitializeSensors":{"count":8,"self":0.0035093999999999998,"total":0.0035093999999999998,"children":null},"AgentSendState":{"count":1,"self":0.0090396,"total":0.0199904,"children":{"CollectObservations":{"count":8,"self":0,"total":0,"children":null},"WriteActionMask":{"count":8,"self":0,"total":0,"children":null},"RequestDecision":{"count":8,"self":0.0109508,"total":0.0109508,"children":null}}},"DecideAction":{"count":1,"self":0.0632417,"total":0.0632417,"children":{"RayPerceptionSensor.Perceive":{"count":16,"self":0,"total":0,"children":null}}},"AgentAct":{"count":1,"self":0,"total":0,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714132819","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\noahk\\Documents\\Unity projects\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-noahk -hubSessionId a6f45e0e-41b6-4c96-a70e-ec8e10ca5aa9 -accessToken LhF-MiZYoHmiI2p1_6JvQZvJ6QUPd4VyLbrTbhNHTT8005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Car Customization","end_time_seconds":"1714132830"}} \ No newline at end of file +{"count":1,"self":196.72761599999998,"total":218.7672601,"children":{"InitializeActuators":{"count":16,"self":0.0039921,"total":0.0039921,"children":null},"InitializeSensors":{"count":16,"self":0.001982,"total":0.001982,"children":null},"AgentSendState":{"count":10302,"self":1.67696,"total":2.0846375999999998,"children":{"CollectObservations":{"count":13904,"self":0.2781029,"total":0.2781029,"children":null},"WriteActionMask":{"count":13904,"self":0.0349994,"total":0.0349994,"children":null},"RequestDecision":{"count":13904,"self":0.0945753,"total":0.0945753,"children":null}}},"DecideAction":{"count":10302,"self":18.1721072,"total":18.4863648,"children":{"RayPerceptionSensor.Perceive":{"count":27808,"self":0.3142569,"total":0.3142569,"children":null}}},"AgentAct":{"count":10302,"self":1.4606668,"total":1.4606668,"children":null}},"gauges":{"Benson Track2.CumulativeReward":{"count":21,"max":25.5401878,"min":21.13704,"runningAverage":24.4067917,"value":25.3901539,"weightedAverage":24.80418}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714138791","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\Magnus\\Desktop\\Ny unityting\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-Magnus -hubSessionId 8c17471b-7795-4082-905c-75744d6a077b -accessToken hv3zp4IA8nxcowfZc35r5tDHrlmzUZoExTBgESksngo005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"Car Customization","end_time_seconds":"1714139010"}} \ No newline at end of file diff --git a/Assets/ML-Agents/Timers/ForestRacetrack_timers.json b/Assets/ML-Agents/Timers/ForestRacetrack_timers.json index 44a20c1..dd19ace 100644 --- a/Assets/ML-Agents/Timers/ForestRacetrack_timers.json +++ b/Assets/ML-Agents/Timers/ForestRacetrack_timers.json @@ -1 +1 @@ -{"count":1,"self":111.73324799999999,"total":115.3655125,"children":{"InitializeActuators":{"count":8,"self":0.0010012999999999999,"total":0.0010012999999999999,"children":null},"InitializeSensors":{"count":8,"self":0.0015026,"total":0.0015026,"children":null},"AgentSendState":{"count":5535,"self":0.3819255,"total":0.4813301,"children":{"CollectObservations":{"count":8856,"self":0.055236799999999996,"total":0.055236799999999996,"children":null},"WriteActionMask":{"count":8856,"self":0.0010157999999999999,"total":0.0010157999999999999,"children":null},"RequestDecision":{"count":8856,"self":0.043151999999999996,"total":0.043151999999999996,"children":null}}},"DecideAction":{"count":5535,"self":2.6350796,"total":2.6868285,"children":{"RayPerceptionSensor.Perceive":{"count":17712,"self":0.0517488,"total":0.0517488,"children":null}}},"AgentAct":{"count":5535,"self":0.4606065,"total":0.4606065,"children":null}},"gauges":{"Benson Track2.CumulativeReward":{"count":13,"max":25.5656662,"min":21.4600677,"runningAverage":23.7516136,"value":25.0143127,"weightedAverage":23.9939575}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714134391","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\noahk\\Documents\\Unity projects\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-noahk -hubSessionId a6f45e0e-41b6-4c96-a70e-ec8e10ca5aa9 -accessToken LhF-MiZYoHmiI2p1_6JvQZvJ6QUPd4VyLbrTbhNHTT8005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"ForestRacetrack","end_time_seconds":"1714134506"}} \ No newline at end of file +{"count":1,"self":12.399459199999999,"total":13.293839499999999,"children":{"InitializeActuators":{"count":8,"self":0.0019879999999999997,"total":0.0019879999999999997,"children":null},"InitializeSensors":{"count":8,"self":0.0019944999999999997,"total":0.0019944999999999997,"children":null},"AgentSendState":{"count":416,"self":0.0657717,"total":0.092637299999999992,"children":{"CollectObservations":{"count":672,"self":0.011900299999999999,"total":0.011900299999999999,"children":null},"WriteActionMask":{"count":672,"self":0.00098559999999999989,"total":0.00098559999999999989,"children":null},"RequestDecision":{"count":672,"self":0.0139797,"total":0.0139797,"children":null}}},"DecideAction":{"count":416,"self":0.73920659999999994,"total":0.74924059999999992,"children":{"RayPerceptionSensor.Perceive":{"count":1344,"self":0.010034,"total":0.010034,"children":null}}},"AgentAct":{"count":416,"self":0.046527399999999997,"total":0.046527399999999997,"children":null}},"gauges":{},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714136963","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\Magnus\\Desktop\\Ny unityting\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-Magnus -hubSessionId 8c17471b-7795-4082-905c-75744d6a077b -accessToken hv3zp4IA8nxcowfZc35r5tDHrlmzUZoExTBgESksngo005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"ForestRacetrack","end_time_seconds":"1714136976"}} \ No newline at end of file diff --git a/Assets/ML-Agents/Timers/WinScreen_timers.json b/Assets/ML-Agents/Timers/WinScreen_timers.json index de10a2c..9f44567 100644 --- a/Assets/ML-Agents/Timers/WinScreen_timers.json +++ b/Assets/ML-Agents/Timers/WinScreen_timers.json @@ -1,5 +1 @@ -<<<<<<< HEAD -{"count":1,"self":143.99398399999998,"total":158.9544038,"children":{"InitializeActuators":{"count":8,"self":0.0019890999999999997,"total":0.0019890999999999997,"children":null},"InitializeSensors":{"count":8,"self":0.0019927,"total":0.0019927,"children":null},"AgentSendState":{"count":7618,"self":1.1591486,"total":1.4356867,"children":{"CollectObservations":{"count":9544,"self":0.1744258,"total":0.1744258,"children":null},"WriteActionMask":{"count":9544,"self":0.0269984,"total":0.0269984,"children":null},"RequestDecision":{"count":9544,"self":0.0751139,"total":0.0751139,"children":null}}},"DecideAction":{"count":7618,"self":12.356396799999999,"total":12.5554197,"children":{"RayPerceptionSensor.Perceive":{"count":19088,"self":0.19902319999999998,"total":0.19902319999999998,"children":null}}},"AgentAct":{"count":7618,"self":0.96334409999999993,"total":0.96334409999999993,"children":null}},"gauges":{"Benson Track2.CumulativeReward":{"count":17,"max":25.4505177,"min":22.522934,"runningAverage":24.4887524,"value":25.4505177,"weightedAverage":25.1389389}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714134194","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\Magnus\\Desktop\\Ny unityting\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-Magnus -hubSessionId 8c17471b-7795-4082-905c-75744d6a077b -accessToken hv3zp4IA8nxcowfZc35r5tDHrlmzUZoExTBgESksngo005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"WinScreen","end_time_seconds":"1714134353"}} -======= -{"count":1,"self":92.310976,"total":94.7386543,"children":{"InitializeActuators":{"count":8,"self":0.0010216,"total":0.0010216,"children":null},"InitializeSensors":{"count":8,"self":0.0020005,"total":0.0020005,"children":null},"AgentSendState":{"count":3706,"self":0.2585523,"total":0.33199409999999996,"children":{"CollectObservations":{"count":5928,"self":0.0394114,"total":0.0394114,"children":null},"WriteActionMask":{"count":5928,"self":0.0065324,"total":0.0065324,"children":null},"RequestDecision":{"count":5928,"self":0.027497999999999998,"total":0.027497999999999998,"children":null}}},"DecideAction":{"count":3706,"self":1.7604408,"total":1.7950252999999998,"children":{"RayPerceptionSensor.Perceive":{"count":11856,"self":0.0345845,"total":0.0345845,"children":null}}},"AgentAct":{"count":3706,"self":0.2966395,"total":0.2966395,"children":null}},"gauges":{"Benson Track2.CumulativeReward":{"count":6,"max":25.4789715,"min":19.6162643,"runningAverage":22.84457,"value":23.53373,"weightedAverage":22.6495037}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714133850","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\noahk\\Documents\\Unity projects\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-noahk -hubSessionId a6f45e0e-41b6-4c96-a70e-ec8e10ca5aa9 -accessToken LhF-MiZYoHmiI2p1_6JvQZvJ6QUPd4VyLbrTbhNHTT8005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"WinScreen","end_time_seconds":"1714133945"}} ->>>>>>> eff1287fab0ecb324ff936e15a760c9019747146 +{"count":1,"self":586.1533184,"total":643.4153359,"children":{"InitializeActuators":{"count":24,"self":0.0030404,"total":0.0030404,"children":null},"InitializeSensors":{"count":24,"self":0.0029801,"total":0.0029801,"children":null},"AgentSendState":{"count":31266,"self":4.3217256,"total":5.4124117,"children":{"CollectObservations":{"count":35184,"self":0.70932549999999994,"total":0.70932549999999994,"children":null},"WriteActionMask":{"count":35184,"self":0.10799389999999999,"total":0.10799389999999999,"children":null},"RequestDecision":{"count":35184,"self":0.2733665,"total":0.2733665,"children":null}}},"DecideAction":{"count":31266,"self":47.4672,"total":48.2260843,"children":{"RayPerceptionSensor.Perceive":{"count":70368,"self":0.75888329999999993,"total":0.75888329999999993,"children":null}}},"AgentAct":{"count":31266,"self":3.6145072,"total":3.6145072999999996,"children":null}},"gauges":{"Benson Track2.CumulativeReward":{"count":49,"max":25.5646172,"min":7.690056,"runningAverage":23.0404053,"value":24.91241,"weightedAverage":24.5779648}},"metadata":{"timer_format_version":"0.1.0","start_time_seconds":"1714139265","unity_version":"2022.3.11f1","command_line_arguments":"C:\\Program Files\\Unity\\Hub\\Editor\\2022.3.11f1\\Editor\\Unity.exe -projectpath C:\\Users\\Magnus\\Desktop\\Ny unityting\\Racesm -useHub -hubIPC -cloudEnvironment production -licensingIpc LicenseClient-Magnus -hubSessionId 8c17471b-7795-4082-905c-75744d6a077b -accessToken hv3zp4IA8nxcowfZc35r5tDHrlmzUZoExTBgESksngo005f","communication_protocol_version":"1.5.0","com.unity.ml-agents_version":"2.0.1","scene_name":"WinScreen","end_time_seconds":"1714139908"}} \ No newline at end of file diff --git a/Assets/Scenes/ForestRacetrack.unity b/Assets/Scenes/ForestRacetrack.unity index b7f3083..3b36245 100644 --- a/Assets/Scenes/ForestRacetrack.unity +++ b/Assets/Scenes/ForestRacetrack.unity @@ -621,6 +621,140 @@ Transform: - {fileID: 1577072443} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &341842529 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 341842530} + - component: {fileID: 341842532} + - component: {fileID: 341842531} + m_Layer: 5 + m_Name: startTimer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &341842530 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 341842529} + 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_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 4459975215774235059} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 1000, y: 500} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &341842531 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 341842529} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: 3 + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 100 + m_fontSizeBase: 100 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 1 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: -143.84424} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &341842532 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 341842529} + m_CullTransparentMesh: 1 --- !u!1001 &352239913 PrefabInstance: m_ObjectHideFlags: 0 @@ -5822,9 +5956,17 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] - m_AddedGameObjects: [] + m_AddedGameObjects: + - targetCorrespondingSourceObject: {fileID: 6591880210688179092, guid: ad34455a014250446a5073260803b0a0, type: 3} + insertIndex: -1 + addedObject: {fileID: 341842530} m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: ad34455a014250446a5073260803b0a0, type: 3} +--- !u!224 &4459975215774235059 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 6591880210688179092, guid: ad34455a014250446a5073260803b0a0, type: 3} + m_PrefabInstance: {fileID: 4459975215774235058} + m_PrefabAsset: {fileID: 0} --- !u!1001 &8684226825208193988 PrefabInstance: m_ObjectHideFlags: 0 @@ -5925,6 +6067,10 @@ PrefabInstance: propertyPath: lapAmount value: 3 objectReference: {fileID: 0} + - target: {fileID: 5365138393421743302, guid: dc3e6243ce610df4c845a9fa5df754a7, type: 3} + propertyPath: startTime + value: + objectReference: {fileID: 341842531} - target: {fileID: 5365138393421743302, guid: dc3e6243ce610df4c845a9fa5df754a7, type: 3} propertyPath: lapCounter value: diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 56e02ef..2966d11 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -3,6 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Linq; using TMPro; +using Unity.VisualScripting; using UnityEditor.SearchService; using UnityEngine; using UnityEngine.SceneManagement; @@ -18,7 +19,9 @@ public class GameManager : MonoBehaviour int[] playerLaps; public TextMeshProUGUI lapCounter; public TextMeshProUGUI timeCounter; + public TextMeshProUGUI startTime; float DNFTimer = 0; + private bool hasCountedDown = false; void Start() { // reset laps @@ -33,8 +36,8 @@ public class GameManager : MonoBehaviour for (int i = 0; i < players.Count(); i++) { - playerTimes[i] = 0.00000001f; - playerTimesStr[i] = "0"; + playerTimes[i] = 0.00000000000f; + playerTimesStr[i] = "1000000"; } DontDestroyOnLoad(gameObject); @@ -43,6 +46,11 @@ public class GameManager : MonoBehaviour // Update is called once per frame void Update() { + if (!hasCountedDown) + { + StartGame(); + + } for (int i = 0; i < players.Count(); i++) { GameObject player = players[i]; @@ -56,9 +64,10 @@ public class GameManager : MonoBehaviour { return; } - + if (hasCountedDown) + { playerTimes[i] += Time.deltaTime; - + } bool isAI = true; if (player.GetComponent().enabled) isAI = false; @@ -116,6 +125,8 @@ public class GameManager : MonoBehaviour } } + + //DNF if (playersFinished.Count() > 0) { @@ -123,7 +134,7 @@ public class GameManager : MonoBehaviour } // race finished - if (playersFinished.Count() == players.Count() || DNFTimer > 10) + if (playersFinished.Count() == players.Count() || DNFTimer > 60) { // sort array float[] fTimes = new float[players.Count()]; @@ -148,10 +159,45 @@ public class GameManager : MonoBehaviour } } + for (var i = 0; i < players.Count();i++) + { + + if (!playersFinished.Contains(players[i].name) && !playersFinished.Contains(players[i].name + " (player)")){ + + playersFinished.Add(players[i].name); + } + } + SceneManager.LoadScene("WinScreen"); } + } + + + + private float sTime = 5; + private void StartGame(){ + sTime -= Time.deltaTime; + startTime.text = (Mathf.Round(sTime*10)/10).ToString(); + if (sTime/60 <= 5 && sTime/60 >= 0) + { + + for (var i = 0; i < players.Count(); i++) + { + players[i].GetComponent().isKinematic = true; + } + } else if (sTime/60 < 0) { + + for (var i = 0; i < players.Count(); i++) + { + players[i].GetComponent().isKinematic = false; + } + startTime.text = ""; + hasCountedDown=true; + } + + } } diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 0412468..5b0b9f1 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -163,7 +163,7 @@ public class PlayerController : MonoBehaviour - if (checkpintDistance < 0.2f) + if (checkpintDistance < 0.5f) { checkpointsCollected += 1; currentCheckpoint.GetComponent().isVisible = false; diff --git a/Assets/Scripts/WinScript.cs b/Assets/Scripts/WinScript.cs index 9c43ef3..ac67c6b 100644 --- a/Assets/Scripts/WinScript.cs +++ b/Assets/Scripts/WinScript.cs @@ -76,8 +76,9 @@ public class WinScript : MonoBehaviour MainText2.text = "Time: "; for (var i = 0; i < leaderboard.Count; i++){ MainText.text += "\n" + (i+1) + "." + leaderboard[i]; - if (time[i] == "0"){ - MainText2.text += "\n(DNF)"; + if (time[i] == "1000000"){ + MainText2.text += "\n(DNF)"; + continue; } MainText2.text += "\n(" + time[i] + ")"; }