Ejemplo n.º 1
0
        /// <summary>
        /// //Tells a client all the items currently equipped on their chosen character to be loaded in before they enter into the game world
        /// </summary>
        /// <param name="ClientID">NetworkID of target client</param>
        /// <param name="CharacterName">Name of character who's equipped items are being sent</param>
        public static void SendEquippedItems(int ClientID, string CharacterName)
        {
            CommunicationLog.LogOut(ClientID + " equipped items");

            //Create a new NetworkPacket object to store the data for this equipped items request
            NetworkPacket Packet = new NetworkPacket();

            //Grab the list of all the items currently equipped on the character
            List <ItemData> EquippedItems = EquipmentsDatabase.GetAllEquipmentSlots(CharacterName);

            //Write the relevant data values into the packet data
            Packet.WriteType(ServerPacketType.EquippedItems);

            Packet.WriteInt(0);
            PacketQueue.QueuePacket(ClientID, Packet);

            //Packet.WriteInt(EquippedItems.Count);

            ////Loop through the list and write in each items information into the packet data
            //foreach(ItemData Item in EquippedItems)
            //{
            //    Packet.WriteInt((int)Item.ItemEquipmentSlot);
            //    Packet.WriteInt(Item.ItemNumber);
            //    Packet.WriteInt(Item.ItemID);
            //}

            ////Add this packet to the target clients outgoing packet queue
            //PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// //Tells a clients all the contents of their chosen characters inventory to be loaded in before they enter into the game world
        /// </summary>
        /// <param name="ClientID">NetworkID of target client</param>
        /// <param name="CharacterName">Name of character who's inventory contents are being sent</param>
        public static void SendInventoryContents(int ClientID, string CharacterName)
        {
            CommunicationLog.LogOut(ClientID + " inventory contents");

            //Create a new NetworkPacket object to store the data for this inventory contents request
            NetworkPacket Packet = new NetworkPacket();

            //Grab the list of all the items currently in the characters inventory
            List <ItemData> InventoryContents = InventoriesDatabase.GetAllInventorySlots(CharacterName);

            //Write the relevant data values into the packet data
            Packet.WriteType(ServerPacketType.InventoryContents);

            Packet.WriteInt(0);
            PacketQueue.QueuePacket(ClientID, Packet);

            //Packet.WriteInt(InventoryContents.Count);

            ////Loop through the list of items in the players inventory and write all of their information into the packet data
            //foreach(ItemData Item in InventoryContents)
            //{
            //    Packet.WriteInt(Item.ItemNumber);
            //    Packet.WriteInt(Item.ItemID);
            //}

            ////Add this packet to the target clients outgoing packet queue
            //PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// //Tells a client all the items currently socketed into their ability bar to be loaded in before they can enter into the game world
        /// </summary>
        /// <param name="ClientID">NetworkID of target client</param>
        /// <param name="CharacterName">Name of character who's socketed abilities are being sent</param>
        public static void SendSocketedAbilities(int ClientID, string CharacterName)
        {
            CommunicationLog.LogOut(ClientID + " socketed abilities");

            //Create a new NetworkPacket object to store the data for this socketed abilities request
            NetworkPacket Packet = new NetworkPacket();

            //Grab the list of all the items currently socketed into the characters action bar
            List <ItemData> SocketedAbilities = ActionBarsDatabase.GetEveryActionBarItem(CharacterName);

            //Write the relevant data values into the packet data
            Packet.WriteType(ServerPacketType.SocketedAbilities);

            Packet.WriteInt(0);
            PacketQueue.QueuePacket(ClientID, Packet);

            //Packet.WriteInt(SocketedAbilities.Count);

            ////Loop through the list and write in each items information into the packet data
            //foreach(ItemData Ability in SocketedAbilities)
            //{
            //    Packet.WriteInt(Ability.ItemNumber);
            //    Packet.WriteInt(Ability.ItemID);
            //}

            ////Add this packet to the target clients outgoing packet queue
            //PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// //Tells a client where all the other players are in the world so they can be spawned in before they can enter the world
        /// </summary>
        /// <param name="ClientID">NetworkID for target client</param>
        public static void SendActivePlayerList(int ClientID)
        {
            CommunicationLog.LogOut(ClientID + " active player list");

            //Create a new NetworkPacket object to store the data for this active player list
            NetworkPacket Packet = new NetworkPacket();

            //Grab the list of all the other active game clients
            List <ClientConnection> OtherClients = ClientSubsetFinder.GetInGameClientsExceptFor(ClientID);

            //Write the relevant data values into the packet data
            Packet.WriteType(ServerPacketType.ActivePlayerList);
            Packet.WriteInt(OtherClients.Count);

            //Loop through the list of other clients and write each of their information into the packet data
            foreach (ClientConnection OtherClient in OtherClients)
            {
                //Write each characters name, and current location and rotation values
                Packet.WriteString(OtherClient.Character.Name);
                Packet.WriteBool(OtherClient.Character.IsAlive);
                Packet.WriteVector3(OtherClient.Character.Position);
                Packet.WriteQuaternion(OtherClient.Character.Rotation);
                Packet.WriteInt(OtherClient.Character.CurrentHealth);
                Packet.WriteInt(OtherClient.Character.MaxHealth);
            }

            //Add this packet to the target clients outgoing packet queue
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// //Tells a client where all the active entities are in the world to have them spawned in before they can enter the game world
        /// </summary>
        /// <param name="ClientID">NetworkID for target client</param>
        public static void SendActiveEntityList(int ClientID)
        {
            CommunicationLog.LogOut(ClientID + " active entity list");

            //Create a new NetworkPacket object to store the data for this active entity list
            NetworkPacket Packet = new NetworkPacket();

            //Grab the list of all the entities currently active in the game world
            List <BaseEntity> ActiveEntities = EntityManager.ActiveEntities;

            //Write the relevant data values into the packet data
            Packet.WriteType(ServerPacketType.ActiveEntityList);
            Packet.WriteInt(ActiveEntities.Count);

            //Loop through the list of active entities and write each of their information into the packet data
            foreach (BaseEntity ActiveEntity in ActiveEntities)
            {
                Packet.WriteString(ActiveEntity.Type);
                Packet.WriteString(ActiveEntity.ID);
                Packet.WriteVector3(VectorTranslate.ConvertVector(ActiveEntity.Location));
                Packet.WriteInt(ActiveEntity.HealthPoints);
            }

            //Add this packet to the target clients outgoing packet queue
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// //Tells a client where all the active items are in the world to have them spawned in before they can start playing
        /// </summary>
        /// <param name="ClientID">NetworkID for target client</param>
        public static void SendActiveItemList(int ClientID)
        {
            CommunicationLog.LogOut(ClientID + " active item list");

            //Create a new NetworkPacket object to store the data for this active item list
            NetworkPacket Packet = new NetworkPacket();

            //Grab the list of all the active item pickups currently in the game world
            List <GameItem> ItemPickups = ItemManager.GetActiveItemList();

            //Write the relevant data values into the packet data
            Packet.WriteType(ServerPacketType.ActiveItemList);
            Packet.WriteInt(ItemPickups.Count);

            //Loop through the list of item pickups and write each of their information into the packet data
            foreach (GameItem ItemPickup in ItemPickups)
            {
                Packet.WriteInt(ItemPickup.ItemNumber);
                Packet.WriteInt(ItemPickup.ItemID);
                Packet.WriteVector3(VectorTranslate.ConvertVector(ItemPickup.ItemPosition));
            }

            //Add this packet to the target clients outgoing packet queue
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 7
0
        //Tells a client their character is now dead so it turns into a ragdoll and they lose control
        public static void SendLocalPlayerDead(int ClientID)
        {
            CommunicationLog.LogOut(ClientID + " Local Player Dead");
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.LocalPlayerDead);
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// //Asks a client if they are still connected, requesting for them to immediately reply to us letting us know
        /// </summary>
        /// <param name="ClientID">NetworkID of the target client</param>
        public static void SendStillConnectedCheck(int ClientID)
        {
            CommunicationLog.LogOut(ClientID + " still alive request");
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.StillConnectedCheck);
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// //Tells a client they have been added into the game world physics simulation and they may now start playing
        /// </summary>
        /// <param name="ClientID">NetworkID of the target client</param>
        public static void SendPlayerBegin(int ClientID)
        {
            CommunicationLog.LogOut(ClientID + " player begin");

            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.AllowPlayerBegin);
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 10
0
        //Tells a client to update their players character with a new HP value
        public static void SendLocalPlayerTakeHit(int ClientID, int NewHPValue)
        {
            CommunicationLog.LogOut(ClientID + " local player take hit alert");
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.LocalPlayerTakeHit);
            Packet.WriteInt(NewHPValue);
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// //Sends a message to a client letting them know we have missed some packets and need them to be resent to us again
        /// </summary>
        /// <param name="ClientID">NetworkID of the target client</param>
        /// <param name="FirstMissedPacket">Number of the first packet you need resent, all the way to the last</param>
        public static void SendMissingPacketsRequest(int ClientID, int FirstMissedPacket)
        {
            CommunicationLog.LogOut(ClientID + " Missing Packets Request.");
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.MissingPacketsRequest);
            Packet.WriteInt(FirstMissedPacket);
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 12
0
        //Tells a client to update some remote players character as being dead, so it turn into a ragdoll
        public static void SendRemotePlayerDead(int ClientID, string CharacterName)
        {
            CommunicationLog.LogOut(ClientID + " Remote Player Dead");
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.RemotePlayerDead);
            Packet.WriteString(CharacterName);
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 13
0
        public static void SendPlayAnimationAlert(int ClientID, string CharacterName, string AnimationName)
        {
            CommunicationLog.LogOut(ClientID + " play animation alert");
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.PlayAnimationAlert);
            Packet.WriteString(CharacterName);
            Packet.WriteString(AnimationName);
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 14
0
        //Tells a client to update some remote players character with a new HP value
        public static void SendRemotePlayerTakeHit(int ClientID, string CharacterName, int NewHPValue)
        {
            CommunicationLog.LogOut(ClientID + " remote player take hit alert");
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.RemotePlayerTakeHit);
            Packet.WriteString(CharacterName);
            Packet.WriteInt(NewHPValue);
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 15
0
        //Tells a client to respawn some other remote players character into the game world with all these values
        public static void SendRemotePlayerRespawn(int ClientID, CharacterData Data)
        {
            CommunicationLog.LogOut(ClientID + " Remote Player Respawn");
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.RemotePlayerRespawn);
            Packet.WriteString(Data.Name);
            Packet.WriteVector3(Data.Position);
            Packet.WriteQuaternion(Data.Rotation);
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 16
0
        //Tells a client to respawn their character back into the game world with all these values
        public static void SendLocalPlayerRespawn(int ClientID, CharacterData Data)
        {
            CommunicationLog.LogOut(ClientID + " Local Player Respawn");
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.LocalPlayerRespawn);
            Packet.WriteVector3(Data.Position);
            Packet.WriteQuaternion(Data.Rotation);
            Packet.WriteFloat(Data.CameraZoom);
            Packet.WriteFloat(Data.CameraXRotation);
            Packet.WriteFloat(Data.CameraYRotation);
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// //Sends a chat message out to be displayed in a client chat window
        /// </summary>
        /// <param name="ClientID">NetworkID of target client</param>
        /// <param name="Sender">Name of character who sent the message</param>
        /// <param name="Message">Contents of the message that was sent</param>
        public static void SendChatMessage(int ClientID, string Sender, string Message)
        {
            CommunicationLog.LogOut(ClientID + " player chat message");

            //Create a new NetworkPacket to store the data for this chat message
            NetworkPacket Packet = new NetworkPacket();

            //Write the relevant data values into the packet data
            Packet.WriteType(ServerPacketType.PlayerChatMessage);
            Packet.WriteString(Sender);
            Packet.WriteString(Message);

            //Add this packet to the target clients outgoing packet queue
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// //Tells a client to remove a remote player character from their game world
        /// </summary>
        /// <param name="ClientID">NetworkID of the target client</param>
        /// <param name="CharacterName">Name of the character to be removed</param>
        public static void SendRemoveRemotePlayer(int ClientID, string CharacterName, bool IsAlive)
        {
            CommunicationLog.LogOut(ClientID + " remove other player");

            //Create a new NetworkPacket object to store all the data inside
            NetworkPacket Packet = new NetworkPacket();

            //Write all the relevant data into the network packet
            Packet.WriteType(ServerPacketType.RemovePlayer);
            Packet.WriteString(CharacterName);
            Packet.WriteBool(IsAlive);

            //Add this packet to the target clients outgoing packet queue
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Replies to a clients request to register a brand new user account
        /// </summary>
        /// <param name="ClientID">The clients network ID</param>
        /// <param name="RegistrationSuccess">If the account registration request was a success</param>
        /// <param name="ReplyMessage">What went wrong if the request was denied</param>
        public static void SendAccountRegistrationReply(int ClientID, bool RegistrationSuccess, string ReplyMessage)
        {
            CommunicationLog.LogOut(ClientID + " account registration reply");

            //Create a new NetworkPacket object to store the data for this account login reply
            NetworkPacket Packet = new NetworkPacket();

            //Write the relevant data values into the network packet
            Packet.WriteType(ServerPacketType.AccountRegistrationReply);
            Packet.WriteBool(RegistrationSuccess);
            Packet.WriteString(ReplyMessage);

            //Add this packet to the target clients outgoign packet queue
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Replies to a clients new character creation request
        /// </summary>
        /// <param name="ClientID">The clients network ID</param>
        /// <param name="CreationSuccess">If the new character creation request was granted</param>
        /// <param name="ReplyMessage">What went wrong if the request was denied</param>
        public static void SendCreateCharacterReply(int ClientID, bool CreationSuccess, string ReplyMessage)
        {
            CommunicationLog.LogOut(ClientID + " character creation reply");

            //Create a new NetworkPacket object to store the data for this account login reply
            NetworkPacket Packet = new NetworkPacket();

            //Write the relevant data values into the packet data
            Packet.WriteType(ServerPacketType.CreateCharacterReply);
            Packet.WriteBool(CreationSuccess);
            Packet.WriteString(ReplyMessage);

            //Add this packet to the target clients outgoing packets queue
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 21
0
        //Tells a client to spawn a remote player character into their game world
        public static void SendAddRemotePlayer(int ClientID, CharacterData Character)
        {
            //Log what we are doing here
            CommunicationLog.LogOut(ClientID + " Add Remote Player.");
            //Create a new NetworkPacket filled with all the nessacery character data values
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.AddPlayer);
            Packet.WriteString(Character.Name);
            Packet.WriteBool(Character.IsAlive);
            Packet.WriteVector3(Character.Position);
            Packet.WriteQuaternion(Character.Rotation);
            Packet.WriteInt(Character.CurrentHealth);
            Packet.WriteInt(Character.MaxHealth);
            //Queue the packet for network transmission
            PacketQueue.QueuePacket(ClientID, Packet);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Sends a client a list of characters that they have created under their account
        /// </summary>
        /// <param name="ClientID">The clients network ID</param>
        /// <param name="AccountName">The account the client is logged into</param>
        public static void SendCharacterDataReply(int ClientID, string AccountName)
        {
            //Log what is happening here
            CommunicationLog.LogOut(ClientID + " Character Data Reply.");

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

            if (Client == null)
            {
                //Cancel the reply if the clients connection couldnt be found
                MessageLog.Print("ERROR: Clients network connection couldnt not be found, Character Data Reply cancelled.");
                return;
            }

            //Create a new NetworkPacket object to store all the character data we are going to send to the client
            NetworkPacket Packet = new NetworkPacket();

            Packet.WriteType(ServerPacketType.CharacterDataReply);

            //Write the number of characters existing in the users account
            Packet.WriteInt(Client.Account.CharacterCount);

            //Loop through and fetch the data for each of the users characters
            for (int i = 0; i < Client.Account.CharacterCount; i++)
            {
                //Fetch the data of each character in their account
                CharacterData CharacterData = Client.Account.GetCharactersData(i + 1);

                //Write all of the characters information into the packet
                Packet.WriteString(CharacterData.Name);
                Packet.WriteVector3(CharacterData.Position);
                Packet.WriteQuaternion(CharacterData.Rotation);
                Packet.WriteFloat(CharacterData.CameraZoom);
                Packet.WriteFloat(CharacterData.CameraXRotation);
                Packet.WriteFloat(CharacterData.CameraYRotation);
                Packet.WriteInt(CharacterData.CurrentHealth);
                Packet.WriteInt(CharacterData.MaxHealth);
                Packet.WriteBool(CharacterData.IsAlive);
            }

            //Add this packet to the transmission queue
            PacketQueue.QueuePacket(ClientID, Packet);
        }