예제 #1
0
        //When a client wants to enter the game world, we need to send them a bunch of information to set up their game world before they can enter
        public static void HandleEnterWorldRequest(int ClientID, ref NetworkPacket Packet)
        {
            CommunicationLog.LogIn(ClientID + " enter world request");

            //Read the characters name the player is going to use, use it to fetch the rest of the characters data from the database
            string        CharacterName = Packet.ReadString();
            CharacterData CharacterData = CharactersDatabase.GetCharacterData(CharacterName);

            //Fetch this ClientConnection and make sure they were able to be found
            ClientConnection Client = ConnectionManager.GetClient(ClientID);

            if (Client == null)
            {
                MessageLog.Print("ERROR: Client not found, unable to handle enter world request.");
                return;
            }

            //Store the character data in the client
            Client.Character = CharacterData;

            //Send the clients lists of other players, AI entities, item pickups, inventory contents, equipped items and socketed actionbar abilities
            GameWorldStatePacketSender.SendActivePlayerList(ClientID);
            GameWorldStatePacketSender.SendActiveEntityList(ClientID);
            GameWorldStatePacketSender.SendActiveItemList(ClientID);
            GameWorldStatePacketSender.SendInventoryContents(ClientID, CharacterName);
            GameWorldStatePacketSender.SendEquippedItems(ClientID, CharacterName);
            GameWorldStatePacketSender.SendSocketedAbilities(ClientID, CharacterName);
        }
예제 #2
0
        private void TryRevivePlayer(string[] Input)
        {
            string CharacterName = Input[1];

            if (!CharactersDatabase.DoesCharacterExist(CharacterName))
            {
                MessageLog.Print("That character doesnt exist, cant revive them.");
                return;
            }
            ClientConnection Client = ClientSubsetFinder.GetClientUsingCharacter(CharacterName);

            if (Client == null)
            {
                MessageLog.Print("That character is not ingame right now, cant revive them.");
                return;
            }
            if (Client.Character.IsAlive)
            {
                MessageLog.Print("That character is not dead, cant revive them.");
                return;
            }
            MessageLog.Print("Reviving " + CharacterName + "...");
            Client.Character.IsAlive = true;
            Client.Character.SetDefaultValues();
            CombatPacketSenders.SendLocalPlayerRespawn(Client.ClientID, Client.Character);
            foreach (ClientConnection OtherClient in ClientSubsetFinder.GetInGameClientsExceptFor(Client.ClientID))
            {
                CombatPacketSenders.SendRemotePlayerRespawn(OtherClient.ClientID, Client.Character);
            }
        }
예제 #3
0
        //Tries using the command arguments for killing one of the player characters
        private void TryKillPlayer(string[] Input)
        {
            string CharacterName = Input[1];

            if (!CharactersDatabase.DoesCharacterExist(CharacterName))
            {
                MessageLog.Print("That character doesnt exist, cant kill them.");
                return;
            }
            ClientConnection Client = ClientSubsetFinder.GetClientUsingCharacter(CharacterName);

            if (Client == null)
            {
                MessageLog.Print("That character is not ingame right now, cant kill them.");
                return;
            }
            //Make sure the character is still alive
            if (!Client.Character.IsAlive)
            {
                MessageLog.Print("That character is already dead, cant kill them.");
                return;
            }
            MessageLog.Print("Killing " + CharacterName + "...");
            Client.Character.IsAlive = false;
            Client.Character.RemoveBody(Program.World.World);
            //Client.RemovePhysicsBody(Program.World.WorldSimulation);
            CombatPacketSenders.SendLocalPlayerDead(Client.ClientID);
            foreach (ClientConnection OtherClient in ClientSubsetFinder.GetInGameClientsExceptFor(Client.ClientID))
            {
                CombatPacketSenders.SendRemotePlayerDead(OtherClient.ClientID, Client.Character.Name);
            }
        }
예제 #4
0
        public string ThirdCharacterName  = ""; //Name of the third character

        /// <summary>
        /// Returns a new CharacterData object containing all of that characters data
        /// </summary>
        /// <param name="CharacterNumber">The character slot to get data from (1,2 or 3)</param>
        /// <returns></returns>
        public CharacterData GetCharactersData(int CharacterNumber)
        {
            //Make sure the character who's data is being requested exists
            if (CharacterNumber == 1 && FirstCharacterName == "")
            {
                MessageLog.Print("ERROR: This account doesnt have a 1st character, so its data cannot be provded.");
                return(null);
            }
            if (CharacterNumber == 2 && SecondCharacterName == "")
            {
                MessageLog.Print("ERROR: This account doesnt have a 2nd character, so its data cannot be provided.");
                return(null);
            }
            if (CharacterNumber == 3 && ThirdCharacterName == "")
            {
                MessageLog.Print("ERROR: This account doesnt have a 3rd character, so its data cannot be provided.");
                return(null);
            }

            //Fetch the characters data and return it
            return(CharactersDatabase.GetCharacterData(
                       CharacterNumber == 1 ? FirstCharacterName :
                       CharacterNumber == 2 ? SecondCharacterName :
                       ThirdCharacterName));
        }
예제 #5
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        if (GUILayout.Button("Update Character List"))
        {
            CharactersDatabase characters = (CharactersDatabase)target;
            characters.UpdateDatabase();
        }
    }
예제 #6
0
        //Tries using the command arguments for performing a setallcharactersrotations
        private void TrySetAllCharactersRotations(string[] Input)
        {
            //Seperate the command arguments
            Quaternion Rotation = new Quaternion(float.Parse(Input[1]), float.Parse(Input[2]), float.Parse(Input[3]), float.Parse(Input[4]));

            //Log what is happening here
            MessageLog.Print("Setting the rotation of all characters in the database to " + Rotation.ToString());

            //Apply the new rotation to all characters in the database
            CharactersDatabase.SetAllRotations(Rotation);
        }
예제 #7
0
        //Tries using the command arguments for performing a setallcharacterspositions
        private void TrySetAllCharactersPositions(string[] Input)
        {
            //Seperate the command arguments
            Vector3 Position = new Vector3(float.Parse(Input[1]), float.Parse(Input[2]), float.Parse(Input[3]));

            //Log what is happening here
            MessageLog.Print("Setting the position of all characters in the database to " + Position.ToString());

            //Apply the new position to all characters in the database
            CharactersDatabase.SetAllPositions(Position);
        }
예제 #8
0
        //Tries using the command arguments for performing a database purge
        private void TryPurgeDatabase(string[] Input)
        {
            //Log what is happening here
            MessageLog.Print("Purging all entries from all databases.");

            //Purge all the databases
            AccountsDatabase.PurgeAccounts();
            ActionBarsDatabase.PurgeActionBars();
            CharactersDatabase.PurgeCharacters();
            EquipmentsDatabase.PurgeEquipments();
            InventoriesDatabase.PurgeInventories();
        }
예제 #9
0
        //Tries using the command arguments for performing a setallcharactersintegervalue
        private void TrySetAllCharactersIntegerValue(string[] Input)
        {
            //Seperate the command arguments
            string IntegerName  = Input[1];
            int    IntegerValue = int.Parse(Input[2]);

            //Log what is happening here
            MessageLog.Print("Setting the value of the " + IntegerName + " integer to " + IntegerValue.ToString() + " in all character tables in the characters database.");

            //Use the arguments to apply the new value to the character tables in the database
            CharactersDatabase.SetAllIntegerValue(IntegerName, IntegerValue);
        }
예제 #10
0
        //Tries using the command arguments for performing a setallcharacterscameras
        private void TrySetAllCharactersCameras(string[] Input)
        {
            //Seperate the command arguments
            float Zoom = float.Parse(Input[1]);
            float XRot = float.Parse(Input[2]);
            float YRot = float.Parse(Input[3]);

            //Log what is happening here
            MessageLog.Print("Setting the camera of all characters in the database to Zoom:" + Zoom + ", XRot:" + XRot + ", YRot:" + YRot + ".");

            //Apply the new camera settings to all characters in the database
            CharactersDatabase.SetAllCameras(Zoom, XRot, YRot);
        }
예제 #11
0
 //Cleans up any dead connections, removing their character from the world, and telling other clients to do the same on their end
 public static void CleanDeadClients(Simulation World)
 {
     foreach (ClientConnection DeadClient in ClientSubsetFinder.GetDeadClients())
     {
         //Backup / Remove from World and alert other clients about any ingame dead clients
         if (DeadClient.Character.InGame)
         {
             CharactersDatabase.SaveCharacterData(DeadClient.Character);
             DeadClient.Character.RemoveBody(World);
             foreach (ClientConnection LivingClient in ClientSubsetFinder.GetInGameLivingClientsExceptFor(DeadClient.ClientID))
             {
                 PlayerManagementPacketSender.SendRemoveRemotePlayer(LivingClient.ClientID, DeadClient.Character.Name, DeadClient.Character.IsAlive);
             }
         }
         ActiveConnections.Remove(DeadClient.ClientID);
     }
 }
예제 #12
0
        //Tries using the command arguments for performing a character info search
        private void TryCharacterInfoSearch(string[] Input)
        {
            //Get the characters name
            string CharacterName = Input[1];

            //Make sure the character exists
            if (!CharactersDatabase.DoesCharacterExist(CharacterName))
            {
                //Say the character doesnt exist and exit the function
                MessageLog.Print("No character named " + CharacterName + " exists, couldnt look up their info.");
                return;
            }

            //Characters Data will be stored here once we acquire it
            Server.Data.CharacterData Data;

            //Find the client currently controlling this character
            ClientConnection Client = ClientSubsetFinder.GetClientUsingCharacter(CharacterName);

            //If no client was found then we want to get the characters info from the database
            if (Client == null)
            {
                Data = CharactersDatabase.GetCharacterData(CharacterName);
            }
            //Otherwise we get the currently live data from the client who is currently using the character
            else
            {
                Data = Client.Character;
            }

            //Define some nicely formatted strings containing all the characters data
            string CharacterInfo     = CharacterName + " level " + Data.Level + (Data.IsMale ? " male." : "female.") + " with " + Data.CurrentHealth + "/" + Data.MaxHealth + " HP.";
            string CharacterPosition = "Position: " + "(" + Data.Position.X + "," + Data.Position.Y + "," + Data.Position.Z + ").";
            string CharacterRotation = "Rotation: (" + Data.Rotation.X + "," + Data.Rotation.Y + "," + Data.Rotation.Z + "," + Data.Rotation.W + ").";
            string CharacterCamera   = "Camera: Zoom:" + Data.CameraZoom + " XRot:" + Data.CameraXRotation + " YRot:" + Data.CameraYRotation + ".";

            //Display all the information to the message window
            MessageLog.Print(CharacterInfo);
            MessageLog.Print(CharacterPosition);
            MessageLog.Print(CharacterRotation);
            MessageLog.Print(CharacterCamera);
        }
예제 #13
0
        //Tries using the command arguments for performing a server shutdown
        private void TryServerShutdown(string[] Input)
        {
            //Log what is happening here
            MessageLog.Print("Server shutting down...");

            //Get a list of all ingame clients who are logged in and playing right now
            List <ClientConnection> ActiveClients = ClientSubsetFinder.GetInGameClients();

            //Loop through all the active players and backup their data
            foreach (ClientConnection ActiveClient in ActiveClients)
            {
                CharactersDatabase.SaveCharacterData(ActiveClient.Character);
            }

            //Close and save the current log file
            MessageLog.Close();

            //Close the application
            Program.ApplicationWindow.Close();
        }
예제 #14
0
        //Handles a users character creation request
        public static void HandleCreateCharacterRequest(int ClientID, ref NetworkPacket Packet)
        {
            //Log what we are doing here
            CommunicationLog.LogIn(ClientID + " Character Creation Request.");

            //Fetch the name that has been provided for the new character
            string CharacterName = Packet.ReadString();

            //Make sure we are still connected to this client
            ClientConnection Client = ConnectionManager.GetClient(ClientID);

            if (Client == null)
            {
                //Ignore the request if the connection could not be found
                MessageLog.Print("ERROR: " + ClientID + " network connection could not be found, ignoring their character creation request.");
                return;
            }

            //Make sure they provided a valid character name
            if (!ValidInputCheckers.IsValidCharacterName(CharacterName))
            {
                //Reject the request if the provided character name contained any banned character
                AccountManagementPacketSenders.SendCreateCharacterReply(ClientID, false, "Character name provided contained banned characters.");
                return;
            }

            //Make sure the character name isnt already taken
            if (!CharactersDatabase.IsCharacterNameAvailable(CharacterName))
            {
                //Reject the request if the name is already taken
                AccountManagementPacketSenders.SendCreateCharacterReply(ClientID, false, "That character name is already taken.");
                return;
            }

            //Register the new character into the database and then reload this clients account information from the database
            CharactersDatabase.SaveNewCharacter(Client.Account.Username, CharacterName);
            Client.Account = AccountsDatabase.GetAccountData(Client.Account.Username);

            //Tell the client their character creation request has been a success
            AccountManagementPacketSenders.SendCreateCharacterReply(ClientID, true, "Character Created.");
        }
예제 #15
0
        //Tries using the command arguments for performing a player kick
        private void TryKickPlayer(string[] Input)
        {
            //Get the characters name
            string CharacterName = Input[1];

            //Make sure the character exists
            if (!CharactersDatabase.DoesCharacterExist(CharacterName))
            {
                MessageLog.Print("That character doesnt exist, cant kick them.");
                return;
            }

            //Get the client who this character belongs to
            ClientConnection Client = ClientSubsetFinder.GetClientUsingCharacter(CharacterName);

            //If the client couldnt be found then the character isnt logged in currently
            if (Client == null)
            {
                MessageLog.Print("That character is not in the game right now, cant kick them.");
                return;
            }

            //Show that the player is being kicked
            MessageLog.Print("Kicking " + CharacterName + " from the game...");

            //Tell the client that they have been kicked from the game and mark them to be cleaned up from the game
            SystemPacketSender.SendKickedFromServer(Client.ClientID);
            Client.ConnectionDead = true;

            //Tell everyone else to remove the client from their games
            List <ClientConnection> OtherClients = ClientSubsetFinder.GetInGameClientsExceptFor(Client.ClientID);

            foreach (ClientConnection OtherClient in OtherClients)
            {
                PlayerManagementPacketSender.SendRemoveRemotePlayer(OtherClient.ClientID, Client.Character.Name, Client.Character.IsAlive);
            }
        }
예제 #16
0
 public void OnEnable()
 {
     comp = (CharactersDatabase)target;
 }