Esempio n. 1
0
    public void unequip(String slot)
    {
        if (bag.Count == size)
        {
            log.Println("The inventory is full. Cannot unequip.");
            return;
        }

        EquippableItem item = null;

        switch (slot)
        {
        case "boots":
            item       = this.boots;
            this.boots = null;
            break;

        case "legs":
            item      = this.legs;
            this.legs = null;
            break;

        case "gloves":
            item        = this.gloves;
            this.gloves = null;
            break;


        case "chest":
            item       = this.chest;
            this.chest = null;
            break;

        case "cloak":
            item       = this.cloak;
            this.cloak = null;
            break;

        case "helm":
            item        = this.helmet;
            this.helmet = null;
            break;

        case "weapon":
            item        = this.weapon;
            this.weapon = null;
            break;

        default:
            //check if maybe the names match
            if (this.weapon != null && this.weapon.ToString().ToLower().Equals(slot.ToLower()))
            {
                item        = this.weapon;
                this.weapon = null;
            }
            else if (this.helmet != null && this.helmet.ToString().ToLower().Equals(slot.ToLower()))
            {
                item        = this.helmet;
                this.helmet = null;
            }
            else if (this.cloak != null && this.cloak.ToString().ToLower().Equals(slot.ToLower()))
            {
                item       = this.cloak;
                this.cloak = null;
            }
            else if (this.legs != null && this.legs.ToString().ToLower().Equals(slot.ToLower()))
            {
                item      = this.legs;
                this.legs = null;
            }
            else if (this.boots != null && this.boots.ToString().ToLower().Equals(slot.ToLower()))
            {
                item       = this.boots;
                this.boots = null;
            }
            else if (this.gloves != null && this.gloves.ToString().ToLower().Equals(slot.ToLower()))
            {
                item        = this.gloves;
                this.gloves = null;
            }
            else if (this.chest != null && this.chest.ToString().ToLower().Equals(slot.ToLower()))
            {
                item       = this.chest;
                this.chest = null;
            }
            else
            {
                return;
            }
            break;
        }

        Add(item, () => { }, () => { /*bag cannot be full here*/ });
    }
Esempio n. 2
0
    public void equip(EquippableItem item)
    {
        if (!bag.Contains(item))
        {
            return;
        }

        EquippableItem tmp = null;

        if (item is HelmArmor)
        {
            if (helmet != null)
            {
                tmp = helmet;
            }
            helmet = (HelmArmor)item;
        }

        if (item is CloakArmor)
        {
            if (cloak != null)
            {
                tmp = cloak;
            }
            cloak = (CloakArmor)item;
        }

        if (item is ChestArmor)
        {
            if (chest != null)
            {
                tmp = chest;
            }
            chest = (ChestArmor)item;
        }

        if (item is GlovesArmor)
        {
            if (gloves != null)
            {
                tmp = gloves;
            }
            gloves = (GlovesArmor)item;
        }

        if (item is LegArmor)
        {
            if (legs != null)
            {
                tmp = legs;
            }
            legs = (LegArmor)item;
        }

        if (item is BootsArmor)
        {
            if (boots != null)
            {
                tmp = boots;
            }
            boots = (BootsArmor)item;
        }

        if (item is Weapon)
        {
            if (weapon != null)
            {
                tmp = weapon;
            }
            weapon = (Weapon)item;
        }

        bag.Remove(item);
        if (tmp != null)
        {
            bag.Add(tmp);
        }

        log.Print("Equipped ");
        log.ItemPrintln(item);
    }