Browse Source

Added ability for player one to start game

master
Joshua Reason 4 years ago
parent
commit
47b91aac84
17 changed files with 99 additions and 43 deletions
  1. +0
    -8
      Assets/Plugins/IngameDebugConsole/Prefabs.meta
  2. +0
    -8
      Assets/Plugins/IngameDebugConsole/Scripts.meta
  3. +0
    -8
      Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta
  4. +3
    -0
      Assets/Scenes/Client Scenes/LobbyWait.unity
  5. +1
    -2
      Assets/Scenes/Client Scenes/LobbyWait.unity.meta
  6. +2
    -2
      Assets/Scenes/Menus/Lobby.unity
  7. +1
    -1
      Assets/Scripts/Components.meta
  8. +0
    -8
      Assets/Scripts/LogicBlocks.meta
  9. +1
    -1
      Assets/Scripts/Networking/Client/ClientObject.cs
  10. +5
    -0
      Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs
  11. +1
    -0
      Assets/Scripts/Networking/Core/Protocols/LoginProtocols.cs
  12. +3
    -2
      Assets/Scripts/Networking/Server/ClientList.cs
  13. +5
    -1
      Assets/Scripts/Networking/Server/ServerManager.cs
  14. +48
    -0
      Assets/Scripts/UI/Client/LobbyWaitManager.cs
  15. +11
    -0
      Assets/Scripts/UI/Client/LobbyWaitManager.cs.meta
  16. +16
    -0
      Assets/Scripts/UI/Lobby/LobbyUIController.cs
  17. +2
    -2
      ProjectSettings/EditorBuildSettings.asset

+ 0
- 8
Assets/Plugins/IngameDebugConsole/Prefabs.meta View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 7dbc36665bc0d684db9a4447e27a7a4b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 0
- 8
Assets/Plugins/IngameDebugConsole/Scripts.meta View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 860c08388401a6d4e858fe4910ea9337
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 0
- 8
Assets/Plugins/IngameDebugConsole/Sprites/Unused.meta View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f6caae32d463529478f2186f47c2e3fe
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 3
- 0
Assets/Scenes/Client Scenes/LobbyWait.unity View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:75d1d366515f1ee9c5accad4e0c3de25a3d68b0391bc31921d7a89d58c8029c7
size 45836

Assets/Plugins/IngameDebugConsole/Android.meta → Assets/Scenes/Client Scenes/LobbyWait.unity.meta View File

@ -1,6 +1,5 @@
fileFormatVersion: 2
guid: 3d7d7a61a5341904eb3c65af025b1d86
folderAsset: yes
guid: bd7b77db655c8c44b85cdd06e9ce9bae
DefaultImporter:
externalObjects: {}
userData:

+ 2
- 2
Assets/Scenes/Menus/Lobby.unity View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6f20ea3050a82f28cd55b2c1ff133057d302ec2ecec14f3f0b59477598461b08
size 45816
oid sha256:2884d7c10378352a9a3863aa21382541b6fb45a0d4b69c9c59ca99352d6555f8
size 45893

Assets/Models.meta → Assets/Scripts/Components.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 296bd90e667df1f4697823a0aa45acf0
guid: 8d7394d70ec233849a60a26da5f23b75
folderAsset: yes
DefaultImporter:
externalObjects: {}

+ 0
- 8
Assets/Scripts/LogicBlocks.meta View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 8936b441d7647f74884c94f97bfb8931
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

+ 1
- 1
Assets/Scripts/Networking/Client/ClientObject.cs View File

@ -30,7 +30,7 @@ namespace Networking.Client
[SerializeField]
[Tooltip("Player Animal")]
private string PlayerAnimal;
public string PlayerAnimal;
[SerializeField]
[Tooltip("Player Color")]

+ 5
- 0
Assets/Scripts/Networking/Core/Protocols/LogicProtocols.cs View File

@ -152,5 +152,10 @@ namespace Networking
String = reader.ReadSingle();
}
}
public class EmptyMsg : MessageBase
{
}
}
}

+ 1
- 0
Assets/Scripts/Networking/Core/Protocols/LoginProtocols.cs View File

@ -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 { }

+ 3
- 2
Assets/Scripts/Networking/Server/ClientList.cs View File

@ -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");
}

+ 5
- 1
Assets/Scripts/Networking/Server/ServerManager.cs View File

@ -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
}
}

+ 48
- 0
Assets/Scripts/UI/Client/LobbyWaitManager.cs View File

@ -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<ClientData> AllClients)
{
if (AllClients.Count > 0 && AllClients[0].characterAnimal == localClient.PlayerAnimal)
{
StartButton.gameObject.SetActive(true);
}
else
{
StartButton.gameObject.SetActive(false);
}
}
}

+ 11
- 0
Assets/Scripts/UI/Client/LobbyWaitManager.cs.meta View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 80436e4e0645dd64fbeb765b080e04ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

+ 16
- 0
Assets/Scripts/UI/Lobby/LobbyUIController.cs View File

@ -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<ClientData> data)
@ -75,4 +86,9 @@ public class LobbyUIController : MonoBehaviour
}
#endif
}
public void RecieveStartMsg(UnityEngine.Networking.NetworkMessage msg)
{
OnClick_StartGame();
}
}

+ 2
- 2
ProjectSettings/EditorBuildSettings.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e48732e471c7fbb8ad8d49bbcc12af26273e0caa803f73b6610358d1793ca05f
size 2120
oid sha256:1890d8b9d4cb6c52f70ca8e818b21a7f57189e3c35841758de9fc21b4fd1bbe0
size 2232

Loading…
Cancel
Save