From 728191c657bc23fa62e8d403425e2d028c96ab23 Mon Sep 17 00:00:00 2001 From: JoshuaReason Date: Sun, 27 Jan 2019 13:36:41 +1100 Subject: [PATCH] Added win and lose to server side --- .../Multiplayer/Server/PlayerServerManager.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Assets/Scipts/Multiplayer/Server/PlayerServerManager.cs b/Assets/Scipts/Multiplayer/Server/PlayerServerManager.cs index af8591e..70a367b 100644 --- a/Assets/Scipts/Multiplayer/Server/PlayerServerManager.cs +++ b/Assets/Scipts/Multiplayer/Server/PlayerServerManager.cs @@ -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;