Browse Source

Started on Lobby

Josh_Dev_branch
Joshua Reason 5 years ago
parent
commit
568f3bdfe2
25 changed files with 4493 additions and 12 deletions
  1. +3
    -0
      Assets/Data/Networking/Server/Realtime/ClientList.asset
  2. +1
    -1
      Assets/Data/Networking/Server/Realtime/ClientList.asset.meta
  3. +0
    -3
      Assets/Data/Networking/Server/Realtime/Clients.asset
  4. +1
    -1
      Assets/Data/Networking/Server/Realtime/Server.asset
  5. +1
    -1
      Assets/Scenes/Client Scenes.meta
  6. +2727
    -0
      Assets/Scenes/Client Scenes/LoginScreen.unity
  7. +7
    -0
      Assets/Scenes/Client Scenes/LoginScreen.unity.meta
  8. +1
    -1
      Assets/Scenes/Server Scenes.meta
  9. +1379
    -0
      Assets/Scenes/Server Scenes/Lobby.unity
  10. +7
    -0
      Assets/Scenes/Server Scenes/Lobby.unity.meta
  11. +8
    -0
      Assets/Scripts/Components.meta
  12. +1
    -5
      Assets/Scripts/Networking/Client/ClientLoginManager.cs
  13. +2
    -0
      Assets/Scripts/Networking/Client/ClientObject.cs
  14. +53
    -0
      Assets/Scripts/Networking/Core/Utility/Utility.cs
  15. +9
    -0
      Assets/Scripts/Networking/Server/ClientData.cs
  16. +8
    -0
      Assets/Scripts/UI/Client.meta
  17. +42
    -0
      Assets/Scripts/UI/Client/LoginUIManager.cs
  18. +11
    -0
      Assets/Scripts/UI/Client/LoginUIManager.cs.meta
  19. +8
    -0
      Assets/Scripts/UI/Lobby.meta
  20. +71
    -0
      Assets/Scripts/UI/Lobby/LobbyUIController.cs
  21. +11
    -0
      Assets/Scripts/UI/Lobby/LobbyUIController.cs.meta
  22. +48
    -0
      Assets/Scripts/UI/PreFilledText.cs
  23. +11
    -0
      Assets/Scripts/UI/PreFilledText.cs.meta
  24. +43
    -0
      Logs/Packages-Update.log
  25. +40
    -0
      Packages/manifest.json

+ 3
- 0
Assets/Data/Networking/Server/Realtime/ClientList.asset View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2f155976e5e630ea823177f26a8061c85933c25ecdbba65eadca7013bf9dda20
size 443

Assets/Data/Networking/Server/Realtime/Clients.asset.meta → Assets/Data/Networking/Server/Realtime/ClientList.asset.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: a994940378bdf5d439f7e86d8fa19d63
guid: ded0b21c3ef1e7049a1128c12e9401fe
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000

+ 0
- 3
Assets/Data/Networking/Server/Realtime/Clients.asset View File

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

+ 1
- 1
Assets/Data/Networking/Server/Realtime/Server.asset View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1d8f9477fd04a5984630bcb6b57ce3b9ecc55b844123eac3ce7ed198b0b3d3a5
oid sha256:b79400c63f907550e1cd21c157f2745ed5a483daf6f454465e332def68b794de
size 489

Assets/Models.meta → Assets/Scenes/Client Scenes.meta View File

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

+ 2727
- 0
Assets/Scenes/Client Scenes/LoginScreen.unity
File diff suppressed because it is too large
View File


+ 7
- 0
Assets/Scenes/Client Scenes/LoginScreen.unity.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c972b9dd7e08c874084a85d4890a369b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Assets/Scripts/LogicBlocks.meta → Assets/Scenes/Server Scenes.meta View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 8936b441d7647f74884c94f97bfb8931
guid: 283cfa68c973f754b91b4ee906802870
folderAsset: yes
DefaultImporter:
externalObjects: {}

+ 1379
- 0
Assets/Scenes/Server Scenes/Lobby.unity
File diff suppressed because it is too large
View File


+ 7
- 0
Assets/Scenes/Server Scenes/Lobby.unity.meta View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 05efb2e3826a5db47ad6a8626df99e0b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

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

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

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

@ -24,10 +24,6 @@ namespace Networking.Client
[Tooltip("Try and connect on Play")]
private bool StartClientOnAwake;
[SerializeField]
[Tooltip("Scene to load on connection")]
private string LevelToLoad;
[Header("Player Settings")]
[SerializeField]
[Tooltip("Player Name")]
@ -91,7 +87,7 @@ namespace Networking.Client
{
Debug.Log("Log in successful");
Client.UpdatePlayerDetails(DisplayName, PlayerColor);
UnityEngine.SceneManagement.SceneManager.LoadScene(LevelToLoad);
//UnityEngine.SceneManagement.SceneManager.LoadScene(LevelToLoad);
}
public void LoginFail(NetworkMessage msg)

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

@ -58,6 +58,8 @@ namespace Networking.Client
this.PlayerColor = PlayerColor;
}
}
}

+ 53
- 0
Assets/Scripts/Networking/Core/Utility/Utility.cs View File

@ -3,6 +3,9 @@ using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using UnityEngine;
namespace Networking
@ -48,5 +51,55 @@ namespace Networking
return obj;
}
public enum ADDRESSFAM
{
IPv4, IPv6
}
//https://stackoverflow.com/questions/51975799/how-to-get-ip-address-of-device-in-unity-2018
public static string GetIP(ADDRESSFAM Addfam)
{
//Return null if ADDRESSFAM is Ipv6 but Os does not support it
if (Addfam == ADDRESSFAM.IPv6 && !Socket.OSSupportsIPv6)
{
return null;
}
string output = "";
foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces())
{
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN
NetworkInterfaceType _type1 = NetworkInterfaceType.Wireless80211;
NetworkInterfaceType _type2 = NetworkInterfaceType.Ethernet;
if ((item.NetworkInterfaceType == _type1 || item.NetworkInterfaceType == _type2) && item.OperationalStatus == OperationalStatus.Up)
#endif
{
foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses)
{
//IPv4
if (Addfam == ADDRESSFAM.IPv4)
{
if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
{
output = ip.Address.ToString();
}
}
//IPv6
else if (Addfam == ADDRESSFAM.IPv6)
{
if (ip.Address.AddressFamily == AddressFamily.InterNetworkV6)
{
output = ip.Address.ToString();
}
}
}
}
}
return output;
}
}
}

+ 9
- 0
Assets/Scripts/Networking/Server/ClientData.cs View File

@ -24,6 +24,13 @@ namespace Networking.Server
/// Usefull if a client needs to reconnect
/// </summary>
public List<ClientData> DisconnectedClients;
/// <summary>
/// Called when a client connects or disconnet
/// </summary>
public System.Action<List<ClientData>> OnClientsChange;
#endregion Public Variables
#region Private Variables
@ -81,6 +88,7 @@ namespace Networking.Server
DisconnectedClients.Add(client);
Debug.Log("Disconnected: " + client.Name);
OnClientsChange.Invoke(ConnectedClients);
}
public void OnClientLogin(NetworkMessage msg)
@ -120,6 +128,7 @@ namespace Networking.Server
ConnectedClients.Add(newClient);
newClient.conn.Send(LoginProtocols.LoginSuccess, new LoginProtocols.LoginMsg(newClient.Name, newClient.Color));
OnClientsChange.Invoke(ConnectedClients);
}

+ 8
- 0
Assets/Scripts/UI/Client.meta View File

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

+ 42
- 0
Assets/Scripts/UI/Client/LoginUIManager.cs View File

@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Networking.Client;
using TMPro;
public class LoginUIManager : MonoBehaviour
{
[SerializeField]
private ClientLoginManager clientManager;
private string serverAddress;
private int serverPort;
private void Start()
{
serverAddress = PlayerPrefs.GetString("LastUsedAddress", "");
serverPort = PlayerPrefs.GetInt("LastUsedPort", 2222);
}
public void OnChange_ServerAddress(string serverAddress)
{
this.serverAddress = serverAddress;
}
public void OnChange_ServerPort(string serverPort)
{
this.serverPort = int.Parse(serverPort);
}
public void OnClickConnect()
{
clientManager.StartClient(serverAddress, serverPort);
PlayerPrefs.SetString("LastUsedAddress", serverAddress);
PlayerPrefs.SetInt("LastUsedPort", serverPort);
PlayerPrefs.Save();
}
}

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

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

+ 8
- 0
Assets/Scripts/UI/Lobby.meta View File

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

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

@ -0,0 +1,71 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using Networking;
using Networking.Server;
public class LobbyUIController : MonoBehaviour
{
[SerializeField]
private ConnectionHandler Clients;
[SerializeField]
private string SceneToStart;
[Header("UI Elements")]
[SerializeField]
private TextMeshProUGUI IPText;
[SerializeField]
private Transform Content;
[SerializeField]
private GameObject ClientTag;
// Start is called before the first frame update
void Start()
{
IPText.text = "Lobby - " + Networking.Utility.GetIP(Networking.Utility.ADDRESSFAM.IPv4);
}
private void OnEnable()
{
Clients.OnClientsChange += DisplayClients;
DisplayClients(Clients.ConnectedClients);
}
private void OnDisable()
{
Clients.OnClientsChange -= DisplayClients;
}
private void DisplayClients(List<ClientData> data)
{
Debug.Log("Updating Connected Clients");
foreach (Transform child in Content)
if (child.gameObject != ClientTag)
Destroy(child.gameObject);
foreach (ClientData client in Clients.ConnectedClients)
{
GameObject clientObject = Instantiate(ClientTag, Content);
TextMeshProUGUI clientText = clientObject.GetComponent<TextMeshProUGUI>();
clientText.text = client.Name;
clientText.color = client.Color;
clientObject.SetActive(true);
}
}
public void OnClick_StartGame()
{
UnityEngine.SceneManagement.SceneManager.LoadScene(SceneToStart);
}
}

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

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

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

@ -0,0 +1,48 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class PreFilledText : MonoBehaviour
{
[System.Serializable]
private enum Action {String, Int, Float};
[SerializeField]
private TMP_InputField text;
[Header("Player Prefs")]
[SerializeField]
private Action Type;
[SerializeField]
private string Key;
[SerializeField]
private string DefaultValue;
private void Awake()
{
SetText();
}
private void SetText()
{
switch (Type)
{
case Action.String:
text.text = PlayerPrefs.GetString(Key, DefaultValue);
break;
case Action.Int:
text.text = PlayerPrefs.GetFloat(Key, int.Parse(DefaultValue)).ToString();
break;
case Action.Float:
text.text = PlayerPrefs.GetFloat(Key, float.Parse(DefaultValue)).ToString();
break;
}
}
}

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

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

+ 43
- 0
Logs/Packages-Update.log View File

@ -41,3 +41,46 @@ The following packages were added:
com.unity.modules.vr@1.0.0
com.unity.modules.wind@1.0.0
com.unity.modules.xr@1.0.0
=== Fri Apr 19 10:40:17 2019
Packages were changed.
Update Mode: resetToDefaultDependencies
The following packages were added:
com.unity.analytics@3.2.2
com.unity.purchasing@2.0.3
com.unity.ads@2.0.8
com.unity.textmeshpro@1.3.0
com.unity.package-manager-ui@2.0.3
com.unity.collab-proxy@1.2.15
com.unity.modules.ai@1.0.0
com.unity.modules.animation@1.0.0
com.unity.modules.assetbundle@1.0.0
com.unity.modules.audio@1.0.0
com.unity.modules.cloth@1.0.0
com.unity.modules.director@1.0.0
com.unity.modules.imageconversion@1.0.0
com.unity.modules.imgui@1.0.0
com.unity.modules.jsonserialize@1.0.0
com.unity.modules.particlesystem@1.0.0
com.unity.modules.physics@1.0.0
com.unity.modules.physics2d@1.0.0
com.unity.modules.screencapture@1.0.0
com.unity.modules.terrain@1.0.0
com.unity.modules.terrainphysics@1.0.0
com.unity.modules.tilemap@1.0.0
com.unity.modules.ui@1.0.0
com.unity.modules.uielements@1.0.0
com.unity.modules.umbra@1.0.0
com.unity.modules.unityanalytics@1.0.0
com.unity.modules.unitywebrequest@1.0.0
com.unity.modules.unitywebrequestassetbundle@1.0.0
com.unity.modules.unitywebrequestaudio@1.0.0
com.unity.modules.unitywebrequesttexture@1.0.0
com.unity.modules.unitywebrequestwww@1.0.0
com.unity.modules.vehicles@1.0.0
com.unity.modules.video@1.0.0
com.unity.modules.vr@1.0.0
com.unity.modules.wind@1.0.0
com.unity.modules.xr@1.0.0

+ 40
- 0
Packages/manifest.json View File

@ -0,0 +1,40 @@
{
"dependencies": {
"com.unity.ads": "2.0.8",
"com.unity.analytics": "3.2.2",
"com.unity.collab-proxy": "1.2.15",
"com.unity.package-manager-ui": "2.0.3",
"com.unity.purchasing": "2.0.3",
"com.unity.textmeshpro": "1.3.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.cloth": "1.0.0",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.screencapture": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vehicles": "1.0.0",
"com.unity.modules.video": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
}
}

Loading…
Cancel
Save