diff --git a/Assets/Mirror/Core/NetworkManager.cs b/Assets/Mirror/Core/NetworkManager.cs index 98f2977..c7ec813 100644 --- a/Assets/Mirror/Core/NetworkManager.cs +++ b/Assets/Mirror/Core/NetworkManager.cs @@ -379,6 +379,35 @@ public void StartClient() OnStartClient(); } + public void StartClient(string serverAddress) + { + if (NetworkClient.active) + { + Debug.LogWarning("Client already started."); + return; + } + + mode = NetworkManagerMode.ClientOnly; + + SetupClient(); + + // In case this is a headless client... + ConfigureHeadlessFrameRate(); + + RegisterClientMessages(); + + if (string.IsNullOrWhiteSpace(serverAddress)) + { + Debug.LogError("Must set the serverAddress field in the manager"); + return; + } + // Debug.Log($"NetworkManager StartClient address:{networkAddress}"); + + NetworkClient.Connect(serverAddress); + + OnStartClient(); + } + /// Starts the client, connects it to the server via Uri public void StartClient(Uri uri) { diff --git a/Assets/Prefabs/Prometheus.prefab b/Assets/Prefabs/Prometheus.prefab index d6d317d..55346e8 100644 --- a/Assets/Prefabs/Prometheus.prefab +++ b/Assets/Prefabs/Prometheus.prefab @@ -283,7 +283,7 @@ MonoBehaviour: syncInterval: 0.1 Speed: 0 CheckpointsReached: 0 - TotalCheckpoints: 0 + TotalCheckpoints: 5 --- !u!114 &2803430939122561944 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 3a3c8be..22dacd9 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -6633,7 +6633,7 @@ MonoBehaviour: syncDirection: 0 syncMode: 0 syncInterval: 0.1 - NumberOfPlayers: 1 + NumberOfPlayers: 2 GameStarted: 0 --- !u!4 &442470983 Transform: @@ -8403,7 +8403,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: Press any key to continue...... + m_text: Press RETURN to continue...... m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} diff --git a/Assets/Scripts/BGMController.cs b/Assets/Scripts/BGMController.cs index 0f34693..3016e7b 100644 --- a/Assets/Scripts/BGMController.cs +++ b/Assets/Scripts/BGMController.cs @@ -7,7 +7,6 @@ public class BGMController : MonoBehaviour AudioSource Prep = null; AudioSource Game = null; - bool GameHasStarted = false; // Start is called before the first frame update void Start() diff --git a/Assets/Scripts/GameStarter.cs b/Assets/Scripts/GameStarter.cs index 75b96a5..7687c11 100644 --- a/Assets/Scripts/GameStarter.cs +++ b/Assets/Scripts/GameStarter.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using UnityEngine; using Mirror; +using System; public class GameStarter : MonoBehaviour { @@ -12,9 +13,9 @@ public class GameStarter : MonoBehaviour public enum Connection // your custom enumeration { - Host, + Client, Server, - Client + Host }; public Connection ConnectionType; @@ -30,7 +31,7 @@ void Start() // Update is called once per frame void Update() { - if (!Started && Input.GetKeyDown(KeyCode.Space)) + if (!Started && Input.GetKeyDown(KeyCode.Return)) { // UISystem.SetActive(true); @@ -40,7 +41,7 @@ void Update() Manager.StartHost(); } else if (ConnectionType == Connection.Client) { - Manager.StartClient(); + Manager.StartClient("34.94.115.129"); } else { Manager.StartServer(); diff --git a/Assets/Scripts/UpdateStats.cs b/Assets/Scripts/UpdateStats.cs index 24a3d45..cd68708 100644 --- a/Assets/Scripts/UpdateStats.cs +++ b/Assets/Scripts/UpdateStats.cs @@ -9,7 +9,7 @@ public class UpdateStats : NetworkBehaviour public int Speed = 0; public int CheckpointsReached = 0; - public int TotalCheckpoints = 0; + public int TotalCheckpoints = 5; private bool IsWinner = false; private bool UIDestroyed = false; private float LapTime = 0.0f; @@ -133,7 +133,11 @@ void FixedUpdate() { Destroy(transform.Find("UI").Find("Speedometer").gameObject); Destroy(transform.Find("UI").Find("ModeIndicator").gameObject); - Destroy(transform.Find("UI")); + Destroy(transform.Find("UI").Find("Timer").gameObject); + Destroy(transform.Find("UI").Find("DefenseModeTimeLeft").Find("TimeLeftBackground").gameObject); + Destroy(transform.Find("UI").Find("DefenseModeTimeLeft").Find("TimeLeft").gameObject); + Destroy(transform.Find("UI").Find("DefenseModeTimeLeft").gameObject); + Destroy(transform.Find("UI").gameObject); UIDestroyed = true; } }