/// <summary> /// Send the current players to the backend /// </summary> /// <remarks> /// Gameplay method : You shouldn't call it manually. /// </remarks> public void SendPlayers() { SimpleObjectFormater objectToSend = new SimpleObjectFormater(); SimpleArray playersArray = new SimpleArray(); foreach (Player player in players) { if (player.IsDefined()) { SimpleObjectFormater playerObjectToSend = new SimpleObjectFormater(); playerObjectToSend.AddInt("id", player.PlayerId); playerObjectToSend.AddInt("state", (int)player.State); playersArray.AddMember(playerObjectToSend); } } objectToSend.AddArray("players", playersArray); if (logMode) { log.Info(Step.ToString() + " : Send available players = " + objectToSend.JSONFormat()); } socketIO.Emit("players", objectToSend.JSONFormat()); }
/// <summary> /// Send all players speed to the backend /// </summary> /// <remarks> /// Gameplay method : You shouldn't call it manually. /// </remarks> public void SendSpeed() { SimpleObjectFormater objectToSend = new SimpleObjectFormater(); SimpleArray playersArray = new SimpleArray(); foreach (Player player in players) { if (player.IsDefined()) { SimpleObjectFormater playerObjectToSend = new SimpleObjectFormater(); playerObjectToSend.AddInt("id", player.PlayerId); playerObjectToSend.AddFloat("speed", player.Speed.value); playersArray.AddMember(playerObjectToSend); } } objectToSend.AddArray("players", playersArray); if (logMode) { log.Info(Step.ToString() + " : Send players speed = " + objectToSend.JSONFormat()); } socketIO.Emit("kinectPlayerSpeed", objectToSend.JSONFormat()); }