public ClientConnectionResponse AcceptClient(LiNGS.Server.GameClient client, LiNGS.Common.Network.NetworkMessage message, bool savedState) { if (currentState is PlayGameState && !savedState) { return(new ClientConnectionResponse(false, false, "Game in progress")); } else if (savedState) { CPlayer cPlayer = clientPlayers.FirstOrDefault(cp => cp.networkGameClient.SessionUserId == client.SessionUserId); if (cPlayer != null) { PlayerController controller = controllers.FirstOrDefault(c => c.client.SessionUserId == client.SessionUserId); if (controller != null) { controller.client = client; } cPlayer.networkGameClient = client; cPlayer.player.networkGameClient = client; cPlayer.disconnected = false; cPlayer.player.disconnected = false; return(new ClientConnectionResponse(true, true)); } return(new ClientConnectionResponse(false, false, "Invalid game state.")); } else { Player p = new Player(client); newPlayers.Add(p); clientPlayers.Add(new CPlayer(client, p)); return(new ClientConnectionResponse(true, false)); } }
public bool ClientDisconnected(LiNGS.Server.GameClient client) { CPlayer cPlayer = clientPlayers.FirstOrDefault(cp => cp.networkGameClient == client); if (cPlayer != null) { cPlayer.disconnected = true; cPlayer.player.disconnected = true; } return(true); }
public LiNGS.Common.GameLogic.INetworkedObject CreateClientObject(LiNGS.Server.GameClient client, string typeName, string name) { PlayerController pController = controllers.FirstOrDefault(pc => pc.client == client); if (pController != null) { return(pController); } PlayerController c = new PlayerController(client, clientPlayers.FirstOrDefault(cp => cp.networkGameClient == client)); controllers.Add(c); return(c); }
public void DestroyClientObject(LiNGS.Server.GameClient client, LiNGS.Common.GameLogic.INetworkedObject networkedObject, string name) { //Keep client objects return; }
public void ReceiveGameMessage(LiNGS.Server.GameClient client, LiNGS.Common.Network.NetworkMessage message) { }
public bool DoesClientNeedToKnowAboutObject(LiNGS.Server.GameClient client, LiNGS.Common.GameLogic.INetworkedObject networkedObject) { if (networkedObject is CPlayer) { return((networkedObject as CPlayer).networkGameClient == client); } else { if (networkedObject is Player) { if ((networkedObject as Player).networkGameClient != client) { return(true); } return(false); } return(true); } if (networkedObject is Character && characters.Contains((Character)networkedObject)) { if (networkedObject is Player) { if ((networkedObject as Player).networkGameClient != client) { Character c = clientPlayers.FirstOrDefault(cp => cp.networkGameClient == client); if (c != null) { if (c.DistanceFromOther(networkedObject as Player) < 15) { return(true); } } } return(false); } else { Character c = clientPlayers.FirstOrDefault(cp => cp.networkGameClient == client); if (c != null) { if (c.DistanceFromOther(networkedObject as Character) < 15) { return(true); } } return(false); } } else { if (networkedObject is CPlayer) { return((networkedObject as CPlayer).networkGameClient == client); } else if (networkedObject is Character) { Character c = clientPlayers.FirstOrDefault(cp => cp.networkGameClient == client); if (c != null) { if (c.DistanceFromOther(networkedObject as Character) < 15) { return(true); } } return(false); } } return(true); }