예제 #1
0
        private bool CheckIfNeedToUpdate(CharacterPlayer current, CharacterPlayer recieved)
        {
            for (int i = 0; i < current.GetInventory().Length - 1; i++)
            {
                WeaponItem existing = current.GetInventory()[i];
                WeaponItem newItem  = recieved.GetInventory()[i];

                if ((existing != null && newItem == null) || (existing == null && newItem != null))
                {
                    return(true);
                }
                if (existing != null & newItem != null && !existing.Name.Equals(newItem.Name))
                {
                    return(true);
                }
            }
            for (int i = 0; i < current.Equipment.Length - 1; i++)
            {
                EqupmentBase existing = current.GetEquipment()[i];
                EqupmentBase newItem  = recieved.GetEquipment()[i];

                if ((existing != null && newItem == null) || (existing == null && newItem != null))
                {
                    return(true);
                }
                if (existing != null & newItem != null && !existing.Name.Equals(newItem.Name))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
        private void UnEquipItem(CharacterPlayer character, NetIncomingMessage message, MessageTemplate template)
        {
            character = MapContainer.FindCharacterByID(message.SenderConnection.RemoteUniqueIdentifier);
            var inventory = character.GetInventory();
            var equpment  = character.GetEquipment();
            int invIndex  = Array.FindIndex(inventory, i => i == null);
            int index     = -1;

            try
            {
                int.TryParse(template.JsonMessage, out index);
            }
            catch (Exception)
            {
            }
            if (invIndex != -1)
            {
                inventory[invIndex] = equpment[index];
                equpment[index]     = null;
            }
        }