diff --git a/Assets/Plugins/IngameDebugConsole/Prefabs.meta b/Assets/Plugins/IngameDebugConsole/Prefabs.meta deleted file mode 100644 index 6aa8bf2..0000000 --- a/Assets/Plugins/IngameDebugConsole/Prefabs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7dbc36665bc0d684db9a4447e27a7a4b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Scripts.meta b/Assets/Plugins/IngameDebugConsole/Scripts.meta deleted file mode 100644 index 72dcaac..0000000 --- a/Assets/Plugins/IngameDebugConsole/Scripts.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 860c08388401a6d4e858fe4910ea9337 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta b/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta deleted file mode 100644 index f3769b1..0000000 --- a/Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f6caae32d463529478f2186f47c2e3fe -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scenes/Client Scenes/LobbyWait.unity b/Assets/Scenes/Client Scenes/LobbyWait.unity new file mode 100644 index 0000000..68f4458 --- /dev/null +++ b/Assets/Scenes/Client Scenes/LobbyWait.unity @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75d1d366515f1ee9c5accad4e0c3de25a3d68b0391bc31921d7a89d58c8029c7 +size 45836 diff --git a/Assets/Plugins/IngameDebugConsole/Android.meta b/Assets/Scenes/Client Scenes/LobbyWait.unity.meta similarity index 67% rename from Assets/Plugins/IngameDebugConsole/Android.meta rename to Assets/Scenes/Client Scenes/LobbyWait.unity.meta index 12049b6..f04631d 100644 --- a/Assets/Plugins/IngameDebugConsole/Android.meta +++ b/Assets/Scenes/Client Scenes/LobbyWait.unity.meta @@ -1,6 +1,5 @@ fileFormatVersion: 2 -guid: 3d7d7a61a5341904eb3c65af025b1d86 -folderAsset: yes +guid: bd7b77db655c8c44b85cdd06e9ce9bae DefaultImporter: externalObjects: {} userData: diff --git a/Assets/Scenes/Menus/Lobby.unity b/Assets/Scenes/Menus/Lobby.unity index 6b28543..69c8415 100644 --- a/Assets/Scenes/Menus/Lobby.unity +++ b/Assets/Scenes/Menus/Lobby.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6f20ea3050a82f28cd55b2c1ff133057d302ec2ecec14f3f0b59477598461b08 -size 45816 +oid sha256:2884d7c10378352a9a3863aa21382541b6fb45a0d4b69c9c59ca99352d6555f8 +size 45893 diff --git a/Assets/Models.meta b/Assets/Scripts/Components.meta similarity index 77% rename from Assets/Models.meta rename to Assets/Scripts/Components.meta index 5346456..5a95b09 100644 --- a/Assets/Models.meta +++ b/Assets/Scripts/Components.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 296bd90e667df1f4697823a0aa45acf0 +guid: 8d7394d70ec233849a60a26da5f23b75 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Scripts/LogicBlocks.meta b/Assets/Scripts/LogicBlocks.meta deleted file mode 100644 index 98af9d1..0000000 --- a/Assets/Scripts/LogicBlocks.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8936b441d7647f74884c94f97bfb8931 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/Networking/Client/ClientObject.cs b/Assets/Scripts/Networking/Client/ClientObject.cs index 950d4ec..f50fd68 100644 --- a/Assets/Scripts/Networking/Client/ClientObject.cs +++ b/Assets/Scripts/Networking/Client/ClientObject.cs @@ -30,7 +30,7 @@ namespace Networking.Client [SerializeField] [Tooltip("Player Animal")] - private string PlayerAnimal; + public string PlayerAnimal; [SerializeField] [Tooltip("Player Color")] diff --git a/Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs b/Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs index b7227ec..eb1a220 100644 --- a/Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs +++ b/Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs @@ -152,5 +152,10 @@ namespace Networking String = reader.ReadSingle(); } } + + public class EmptyMsg : MessageBase + { + + } } } \ No newline at end of file diff --git a/Assets/Scripts/Networking/Core/Protocols/LoginProtocols.cs b/Assets/Scripts/Networking/Core/Protocols/LoginProtocols.cs index 9c13e8f..1b72b92 100644 --- a/Assets/Scripts/Networking/Core/Protocols/LoginProtocols.cs +++ b/Assets/Scripts/Networking/Core/Protocols/LoginProtocols.cs @@ -13,6 +13,7 @@ public class LoginProtocols public const short SceneChange = 104; public const short OtherClientConnected = 105; public const short OtherClientDisconnected = 106; + public const short StartGame = 107; public class EmptyMsg : MessageBase { } diff --git a/Assets/Scripts/Networking/Server/ClientList.cs b/Assets/Scripts/Networking/Server/ClientList.cs index 5c3d90b..fe1ed1a 100644 --- a/Assets/Scripts/Networking/Server/ClientList.cs +++ b/Assets/Scripts/Networking/Server/ClientList.cs @@ -143,9 +143,10 @@ namespace Networking.Server newClient.Name = loginMsg.Name; newClient.conn = msg.conn; - ConnectedClients.ForEach(p => p.conn.Send(LoginProtocols.OtherClientConnected, new LoginProtocols.LoginMsg(newClient.Name, newClient.Color, newClient.characterAnimal))); + ConnectedClients.Add(newClient); + ConnectedClients.ForEach(p => p.conn.Send(LoginProtocols.OtherClientConnected, new LoginProtocols.LoginMsg(newClient.Name, newClient.Color, newClient.characterAnimal))); PotentialClients.RemoveAll(p => p == newClient.conn); PotentialClients.ForEach(p => p.Send(LoginProtocols.OtherClientConnected, new LoginProtocols.LoginMsg(newClient.Name, newClient.Color, newClient.characterAnimal))); @@ -153,7 +154,7 @@ namespace Networking.Server OnClientsChange.Invoke(ConnectedClients); newClient.SendInventory(); newClient.SendLives(); - newClient.ChangeScene("WaitScene"); + newClient.ChangeScene("LobbyWait"); } diff --git a/Assets/Scripts/Networking/Server/ServerManager.cs b/Assets/Scripts/Networking/Server/ServerManager.cs index c04fdd2..a5f781f 100644 --- a/Assets/Scripts/Networking/Server/ServerManager.cs +++ b/Assets/Scripts/Networking/Server/ServerManager.cs @@ -27,7 +27,9 @@ namespace Networking.Server private void Awake() { if (StartServerOnAwake) - Server.StartServer(Port); + { + Server.StartServer(Port); + } } private void Update() @@ -36,6 +38,8 @@ namespace Networking.Server } + + } diff --git a/Assets/Scripts/UI/Client/LobbyWaitManager.cs b/Assets/Scripts/UI/Client/LobbyWaitManager.cs new file mode 100644 index 0000000..393f5fe --- /dev/null +++ b/Assets/Scripts/UI/Client/LobbyWaitManager.cs @@ -0,0 +1,48 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Networking.Client; + +public class LobbyWaitManager : MonoBehaviour +{ + [SerializeField] + private ConnectedClients AllClients; + [SerializeField] + private ClientObject localClient; + + [SerializeField] + private UnityEngine.UI.Button StartButton; + + private void OnEnable() + { + AllClients.OnClientsChange += UpdateButton; + } + + private void OnDisable() + { + AllClients.OnClientsChange -= UpdateButton; + } + + private void Start() + { + UpdateButton(AllClients.AllClients); + } + + public void OnClick_Start() + { + localClient.client.Send(LoginProtocols.StartGame, new Networking.LogicProtocols.EmptyMsg()); + } + + private void UpdateButton(List AllClients) + { + if (AllClients.Count > 0 && AllClients[0].characterAnimal == localClient.PlayerAnimal) + { + StartButton.gameObject.SetActive(true); + } + else + { + StartButton.gameObject.SetActive(false); + } + } + +} diff --git a/Assets/Scripts/UI/Client/LobbyWaitManager.cs.meta b/Assets/Scripts/UI/Client/LobbyWaitManager.cs.meta new file mode 100644 index 0000000..856c751 --- /dev/null +++ b/Assets/Scripts/UI/Client/LobbyWaitManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 80436e4e0645dd64fbeb765b080e04ce +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/Lobby/LobbyUIController.cs b/Assets/Scripts/UI/Lobby/LobbyUIController.cs index 2a5415d..423de6c 100644 --- a/Assets/Scripts/UI/Lobby/LobbyUIController.cs +++ b/Assets/Scripts/UI/Lobby/LobbyUIController.cs @@ -23,6 +23,9 @@ public class LobbyUIController : MonoBehaviour [SerializeField] private GameObject ClientTag; + [SerializeField] + private ServerObject Server; + // Start is called before the first frame update void Start() { @@ -33,11 +36,19 @@ public class LobbyUIController : MonoBehaviour { Clients.OnClientsChange += DisplayClients; DisplayClients(Clients.ConnectedClients); + + if (Server.server != null) + Server.server.RegisterHandler(LoginProtocols.StartGame, RecieveStartMsg); + else + Debug.LogWarning("Server not started yet"); } private void OnDisable() { Clients.OnClientsChange -= DisplayClients; + + if (Server.server != null) + Server.server.UnregisterHandler(LoginProtocols.StartGame); } private void DisplayClients(List data) @@ -75,4 +86,9 @@ public class LobbyUIController : MonoBehaviour } #endif } + + public void RecieveStartMsg(UnityEngine.Networking.NetworkMessage msg) + { + OnClick_StartGame(); + } } diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 1c0a9f3..20d763c 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e48732e471c7fbb8ad8d49bbcc12af26273e0caa803f73b6610358d1793ca05f -size 2120 +oid sha256:1890d8b9d4cb6c52f70ca8e818b21a7f57189e3c35841758de9fc21b4fd1bbe0 +size 2232