|
|
@ -22,6 +22,8 @@ namespace Multiplayer |
|
|
|
ServerManager.Server.RegisterHandler(PlayerMsgID.Position, RecievePosition); |
|
|
|
ServerManager.Server.RegisterHandler(PlayerMsgID.QueryPosition, QueryPosition); |
|
|
|
ServerManager.Server.RegisterHandler(PlayerMsgID.Vegetable, PickUpVeg); |
|
|
|
ServerManager.Server.RegisterHandler(PlayerMsgID.GameWin, OnGameWin); |
|
|
|
ServerManager.Server.RegisterHandler(PlayerMsgID.GameOver, OnGameOver); |
|
|
|
} |
|
|
|
|
|
|
|
private void RecievePosition(NetworkMessage msg) |
|
|
@ -72,6 +74,26 @@ namespace Multiplayer |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void OnGameWin(NetworkMessage msg) |
|
|
|
{ |
|
|
|
foreach (Player player in ServerManager.AllPlayers.Values) |
|
|
|
{ |
|
|
|
|
|
|
|
PlayerMsg winMsg = new PlayerMsg(player.ID); |
|
|
|
player.Connection.Send(PlayerMsgID.GameWin, winMsg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void OnGameOver(NetworkMessage msg) |
|
|
|
{ |
|
|
|
foreach (Player player in ServerManager.AllPlayers.Values) |
|
|
|
{ |
|
|
|
|
|
|
|
PlayerMsg winMsg = new PlayerMsg(player.ID); |
|
|
|
player.Connection.Send(PlayerMsgID.GameOver, winMsg); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void PickUpVeg(NetworkMessage msg) |
|
|
|
{ |
|
|
|
VegMsg vegMsg; |
|
|
|