Пример #1
0
 public void Handle(EquipmentSelectedMessage message)
 {
     if (Model.SYNC_ID == message.Equipment.InvFacilityId)
     {
         SelectedEquipment = Equipments.FirstOrDefault(x => x.Model.SYNC_ID == message.Equipment.SYNC_ID);
         SelectedTabIndex  = 1;
     }
 }
Пример #2
0
        /// <summary>
        /// Map item string coming from demos events with equipment.
        /// Used for specials equipments such as kevlar and weapons that have special name such as molotov.
        /// Others weapons detection is based on their item index definition.
        /// </summary>
        /// <param name="originalString"></param>
        /// <returns></returns>
        public static EquipmentElement MapEquipment(string originalString)
        {
            EquipmentElement weapon = EquipmentElement.Unknown;

            if (!originalString.StartsWith(ITEM_PREFIX) && !originalString.StartsWith(WEAPON_PREFIX))
            {
                originalString = WEAPON_PREFIX + originalString;
            }

            EquipmentMapping equipment = Equipments.FirstOrDefault(e => e.OriginalName == originalString);

            if (equipment.ItemIndex == 0)
            {
                switch (originalString)
                {
                case "item_kevlar":
                case "item_vest":
                    weapon = EquipmentElement.Kevlar;
                    break;

                case "item_assaultsuit":
                case "item_vesthelm":
                    weapon = EquipmentElement.Helmet;
                    break;

                case "item_defuser":
                    weapon = EquipmentElement.DefuseKit;
                    break;

                case "weapon_world":
                case "weapon_worldspawn":
                    weapon = EquipmentElement.World;
                    break;

                case "weapon_inferno":
                    weapon = EquipmentElement.Incendiary;
                    break;

                case "weapon_molotov_projectile":
                case "weapon_molotovgrenade":
                    weapon = EquipmentElement.Molotov;
                    break;

                default:
                    Trace.WriteLine("Unknown weapon. " + originalString, "Equipment.MapEquipment()");
                    break;
                }
            }
            else
            {
                weapon = equipment.Element;
            }

            return(weapon);
        }
Пример #3
0
        public void Remove(int id)
        {
            var item      = Items.FirstOrDefault(i => i.Id == id);
            var equipment = Equipments.FirstOrDefault(e => e.Id == id);

            if (item == null && equipment == null)
            {
                return;
            }

            if (item != null)
            {
                Items.Remove(item);
            }
            else if (equipment != null)
            {
                Equipments.Remove(equipment);
            }
        }
Пример #4
0
        public void UnequipCostume(Costume costume, bool ignoreEquipmentsAndCustomize = false)
        {
            if (costume is null)
            {
                return;
            }

            switch (costume.ItemSubType)
            {
            case ItemSubType.EarCostume:
                UpdateEar();
                break;

            case ItemSubType.EyeCostume:
                UpdateEye();
                break;

            case ItemSubType.FullCostume:
                if (!ignoreEquipmentsAndCustomize)
                {
                    var armor = (Armor)Equipments.FirstOrDefault(equipment =>
                                                                 equipment.ItemSubType == ItemSubType.Armor);
                    var weapon = (Weapon)Equipments.FirstOrDefault(equipment =>
                                                                   equipment.ItemSubType == ItemSubType.Weapon);
                    EquipEquipmentsAndUpdateCustomize(armor, weapon);
                }

                break;

            case ItemSubType.HairCostume:
                UpdateHair();
                break;

            case ItemSubType.TailCostume:
                UpdateTail();
                break;

            case ItemSubType.Title:
                // TODO: 구현!
                break;
            }
        }
Пример #5
0
        public int GetAmorId()
        {
            var armor = (Armor)Equipments.FirstOrDefault(x => x.ItemSubType == ItemSubType.Armor);

            return(armor?.Id ?? GameConfig.DefaultAvatarArmorId);
        }
Пример #6
0
        //********************************************************************
        // Helpers
        //********************************************************************
        private EquipedItem SearchEquipmentSlot(IEquipable item, bool replace)
        {
            // TODO: if wield, can be equiped as wield2 if dual wield
            // TODO: if wield2H, can be equiped as wield+hold or wield+shield
            // TODO: if hold (or shield), can be equiped as hold (or shield) and no wield2H on wield+hold (or +shield)
            switch (item.WearLocation)
            {
            case WearLocations.None:
                return(null);

            case WearLocations.Light:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Light && (replace || x.Item == null)));

            case WearLocations.Head:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Head && (replace || x.Item == null)));

            case WearLocations.Amulet:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Amulet && (replace || x.Item == null)));

            case WearLocations.Shoulders:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Shoulders && (replace || x.Item == null)));

            case WearLocations.Chest:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Chest && (replace || x.Item == null)));

            case WearLocations.Cloak:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Cloak && (replace || x.Item == null)));

            case WearLocations.Waist:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Waist && (replace || x.Item == null)));

            case WearLocations.Wrists:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Wrists && (replace || x.Item == null)));

            case WearLocations.Arms:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Arms && (replace || x.Item == null)));

            case WearLocations.Hands:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Hands && (replace || x.Item == null)));

            case WearLocations.Ring:
                // Search an empty slot, if no empty slot take first non-empty if replace is true
                return(Equipments.FirstOrDefault(x => (x.Slot == EquipmentSlots.RingLeft || x.Slot == EquipmentSlots.RingRight) && x.Item == null)
                       ?? (replace ?
                           Equipments.FirstOrDefault(x => (x.Slot == EquipmentSlots.RingLeft || x.Slot == EquipmentSlots.RingRight))
                               : null));

            case WearLocations.Legs:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Legs && (replace || x.Item == null)));

            case WearLocations.Feet:
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Feet && (replace || x.Item == null)));

            case WearLocations.Trinket:
                // Search an empty slot, if no empty slot take first non-empty if replace is true
                return(Equipments.FirstOrDefault(x => (x.Slot == EquipmentSlots.Trinket1 || x.Slot == EquipmentSlots.Trinket2) && x.Item == null)
                       ?? (replace ?
                           Equipments.FirstOrDefault(x => (x.Slot == EquipmentSlots.Trinket1 || x.Slot == EquipmentSlots.Trinket2))
                               : null));

            case WearLocations.Wield:
                if (replace)
                {
                    return(Equipments.FirstOrDefault(x => (x.Slot == EquipmentSlots.Wield ||
                                                           x.Slot == EquipmentSlots.Wield2 ||
                                                           x.Slot == EquipmentSlots.Wield3 ||
                                                           x.Slot == EquipmentSlots.Wield4) && x.Item == null)
                           ?? Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Wield)
                           ?? Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Wield2)
                           ?? Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Wield3)
                           ?? Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Wield4));
                }
                else
                {
                    return(Equipments.FirstOrDefault(x => (x.Slot == EquipmentSlots.Wield ||
                                                           x.Slot == EquipmentSlots.Wield2 ||
                                                           x.Slot == EquipmentSlots.Wield3 ||
                                                           x.Slot == EquipmentSlots.Wield4) && x.Item == null));
                }

            case WearLocations.Hold:
                // TODO
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Hold && (replace || x.Item == null)));

            case WearLocations.Shield:
                // TODO
                return(Equipments.FirstOrDefault(x => x.Slot == EquipmentSlots.Shield && (replace || x.Item == null)));

            case WearLocations.Wield2H:
                // TODO
                return(Equipments.FirstOrDefault(x => (x.Slot == EquipmentSlots.Wield2H || x.Slot == EquipmentSlots.Wield2H2) && (replace || x.Item == null)));
            }
            return(null);
        }