Example #1
0
        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));
            }
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
 public void DestroyClientObject(LiNGS.Server.GameClient client, LiNGS.Common.GameLogic.INetworkedObject networkedObject, string name)
 {
     //Keep client objects
     return;
 }
Example #5
0
 public void ReceiveGameMessage(LiNGS.Server.GameClient client, LiNGS.Common.Network.NetworkMessage message)
 {
 }
Example #6
0
        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);
        }