MB 5 years ago
parent
commit
a53e571bd3
1 changed files with 22 additions and 0 deletions
  1. +22
    -0
      Assets/Scipts/Multiplayer/Server/PlayerServerManager.cs

+ 22
- 0
Assets/Scipts/Multiplayer/Server/PlayerServerManager.cs View File

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

Loading…
Cancel
Save