|
|
@ -6,7 +6,6 @@ using UnityEngine.Networking; |
|
|
|
|
|
|
|
namespace Networking.Server |
|
|
|
{ |
|
|
|
|
|
|
|
[CreateAssetMenu(menuName = "Major Project/Networking/ClientList", order = 150)] |
|
|
|
public class ClientList : ScriptableObject, IEnumerable<ClientData> |
|
|
|
{ |
|
|
@ -69,7 +68,6 @@ namespace Networking.Server |
|
|
|
{ |
|
|
|
this.server = serverObject.server; |
|
|
|
Reset(); |
|
|
|
|
|
|
|
server.RegisterHandler(MsgType.Connect, OnClientConnect); |
|
|
|
server.RegisterHandler(MsgType.Disconnect, OnClientDisconnect); |
|
|
|
server.RegisterHandler(LoginProtocols.SendingLoginDetails, OnClientLogin); |
|
|
@ -93,7 +91,6 @@ namespace Networking.Server |
|
|
|
|
|
|
|
public void OnClientDisconnect(NetworkMessage msg) |
|
|
|
{ |
|
|
|
|
|
|
|
PotentialClients.RemoveAll(p => p == msg.conn); |
|
|
|
|
|
|
|
if (!ConnectedClients.Any(p => p.ID == msg.conn.connectionId)) |
|
|
@ -105,7 +102,6 @@ namespace Networking.Server |
|
|
|
ClientData client = ConnectedClients.FirstOrDefault(p => p.ID == msg.conn.connectionId); |
|
|
|
ConnectedClients.Remove(client); |
|
|
|
DisconnectedClients.Add(client); |
|
|
|
|
|
|
|
|
|
|
|
ConnectedClients.ForEach(p => p.conn.Send(LoginProtocols.OtherClientDisconnected, new LoginProtocols.LoginMsg(client.Name, client.Color, client.characterAnimal))); |
|
|
|
PotentialClients.ForEach(p => p.Send(LoginProtocols.OtherClientDisconnected, new LoginProtocols.LoginMsg(client.Name, client.Color, client.characterAnimal))); |
|
|
@ -140,7 +136,6 @@ namespace Networking.Server |
|
|
|
Debug.Log("new Connection: " + loginMsg.Name); |
|
|
|
newClient = new ClientData(); |
|
|
|
newClient.Inventory = Inventory.Clone(StartInventory); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
newClient.Color = loginMsg.Color; |
|
|
@ -159,14 +154,9 @@ namespace Networking.Server |
|
|
|
newClient.SendInventory(); |
|
|
|
newClient.SendLives(); |
|
|
|
newClient.ChangeScene("WaitScene"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region IEnumerable Implementation
|
|
|
|
public IEnumerator<ClientData> GetEnumerator() |
|
|
|
{ |
|
|
@ -212,7 +202,7 @@ namespace Networking.Server |
|
|
|
/// <summary>
|
|
|
|
/// Clients Current Lives
|
|
|
|
/// </summary>
|
|
|
|
public int Lives; |
|
|
|
public int Lives = 3; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Clients character animal - needed for instantiation
|
|
|
|