Ejemplo n.º 1
0
        /// <summary>
        /// Снять вещь
        /// </summary>
        /// <param name="type">Тип предмета</param>
        public void UnEquip(Type type)
        {
            if (type == typeof(Helmet))
            {
                if (helmet != null)
                {
                    this.Inventory.Add(helmet);
                }
                helmet = null;
            }

            if (type == typeof(Chest))
            {
                if (chest != null)
                {
                    this.Inventory.Add(chest);
                }
                chest = null;
            }

            if (type == typeof(Pants))
            {
                if (pants != null)
                {
                    this.Inventory.Add(pants);
                }
                pants = null;
            }

            if (type == typeof(Boots))
            {
                if (boots != null)
                {
                    this.Inventory.Add(boots);
                }
                boots = null;
            }

            if (type == typeof(Wrist))
            {
                if (wrist != null)
                {
                    this.Inventory.Add(wrist);
                }

                wrist = null;
            }

            if (type == typeof(Weapon))
            {
                if (weapon != null)
                {
                    this.Inventory.Add(weapon);
                }
                weapon = null;
            }
            StatsUpdate();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Надеть предмет
        /// </summary>
        /// <param name="item">Предмет</param>
        public void Equip(Item item)
        {
            if (Class.EquipForClass(this, item))
            {
                if (item is Weapon)
                {
                    if (weapon != null)
                    {
                        UnEquip(typeof(Weapon));
                    }
                    weapon = (Weapon)item;
                }
                if (item is Armor)
                {
                    if (item is Helmet)
                    {
                        if (helmet != null)
                        {
                            UnEquip(typeof(Helmet));
                        }
                        helmet = item as Helmet;
                    }

                    if (item is Chest)
                    {
                        if (chest != null)
                        {
                            UnEquip(typeof(Chest));
                        }
                        chest = item as Chest;
                    }

                    if (item is Pants)
                    {
                        if (pants != null)
                        {
                            UnEquip(typeof(Pants));
                        }
                        pants = item as Pants;
                    }

                    if (item is Boots)
                    {
                        if (boots != null)
                        {
                            UnEquip(typeof(Boots));
                        }
                        boots = item as Boots;
                    }

                    if (item is Wrist)
                    {
                        if (wrist != null)
                        {
                            UnEquip(typeof(Wrist));
                        }
                        wrist = item as Wrist;
                    }
                }
                this.Inventory.Remove(item);
                StatsUpdate();
            }
            else
            {
                return;
            }
        }