|
|
@ -49,19 +49,21 @@ namespace Networking.Client |
|
|
|
[Tooltip("Current Score in Round")] |
|
|
|
public float RoundScore; |
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
[Tooltip("Remaining Lives")] |
|
|
|
public float RemainingLives; |
|
|
|
|
|
|
|
[SerializeField] |
|
|
|
[Tooltip("A list of all connected clients")] |
|
|
|
public ConnectedClients ConnectedClients; |
|
|
|
|
|
|
|
#endregion Inspector Fields
|
|
|
|
|
|
|
|
|
|
|
|
#region ReadOnly Variables
|
|
|
|
public NetworkClient client { get; private set; } |
|
|
|
public bool isConnected { get { return client != null && client.isConnected; } } |
|
|
|
#endregion ReadOnly Variables
|
|
|
|
|
|
|
|
|
|
|
|
public void Connect(string serverAddress,int port) |
|
|
|
{ |
|
|
|
Debug.Log("Connecting to server: " + serverAddress + ", " + port); |
|
|
@ -81,6 +83,7 @@ namespace Networking.Client |
|
|
|
client.RegisterHandler(MsgType.Disconnect, OnDisconnect); |
|
|
|
client.RegisterHandler(LogicProtocols.SendRoundTime, UpdateTime); |
|
|
|
client.RegisterHandler(LogicProtocols.SendScore, UpdateScore); |
|
|
|
client.RegisterHandler(LogicProtocols.SendLives, UpdateLives); |
|
|
|
} |
|
|
|
|
|
|
|
public void Stop() |
|
|
@ -97,7 +100,6 @@ namespace Networking.Client |
|
|
|
this.PlayerColor = PlayerColor; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void RecieveInventory(NetworkMessage msg) |
|
|
|
{ |
|
|
|
Debug.Log("Recieving Inventory"); |
|
|
@ -132,8 +134,7 @@ namespace Networking.Client |
|
|
|
if (!msg.TryRead(out floatMsg)) |
|
|
|
return; |
|
|
|
|
|
|
|
RoundTime = floatMsg.Float; |
|
|
|
|
|
|
|
RoundTime = floatMsg.Float; |
|
|
|
} |
|
|
|
|
|
|
|
public void UpdateScore(NetworkMessage msg) |
|
|
@ -144,6 +145,14 @@ namespace Networking.Client |
|
|
|
|
|
|
|
RoundScore = floatMsg.Float; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void UpdateLives(NetworkMessage msg) |
|
|
|
{ |
|
|
|
LogicProtocols.FloatMsg floatMsg; |
|
|
|
if (!msg.TryRead(out floatMsg)) |
|
|
|
return; |
|
|
|
|
|
|
|
RemainingLives = floatMsg.Float; |
|
|
|
} |
|
|
|
} |
|
|
|
} |