예제 #1
0
        public EquipmentItem GetItem(EquipmentItem.EquipmentSlot slot)
        {
            switch (slot)
            {
            case EquipmentItem.EquipmentSlot.Head:
                return(_headSlot);

            case EquipmentItem.EquipmentSlot.Torso:
                return(_torsoSlot);

            case EquipmentItem.EquipmentSlot.Legs:
                return(_legsSlot);

            case EquipmentItem.EquipmentSlot.Feet:
                return(_feetSlot);

            case EquipmentItem.EquipmentSlot.Accessory:
                return(_accessorySlot);

            case EquipmentItem.EquipmentSlot.Weapon:
                return(Weapon);

            default:
                return(null);
            }
        }
        public EquipmentItem GetItem(EquipmentItem.EquipmentSlot slot)
        {
            switch (slot)
            {
            case EquipmentItem.EquipmentSlot.Head:
                return(m_HeadSlot);

            case EquipmentItem.EquipmentSlot.Torso:
                return(m_TorsoSlot);

            case EquipmentItem.EquipmentSlot.Legs:
                return(m_LegsSlot);

            case EquipmentItem.EquipmentSlot.Feet:
                return(m_FeetSlot);

            case EquipmentItem.EquipmentSlot.Accessory:
                return(m_AccessorySlot);

            default:
                return(null);
            }
        }
        /// <summary>
        /// Unequip the item in the given slot. isReplacement is used to tell the system if this unequip was called
        /// because we equipped something new in that slot or just unequip to empty slot. This is for the weapon : the
        /// weapon slot can't be empty, so if this is not a replacement, this will auto-requip the base weapon.
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="isReplacement"></param>
        public void Unequip(EquipmentItem.EquipmentSlot slot, bool isReplacement = false)
        {
            switch (slot)
            {
            case EquipmentItem.EquipmentSlot.Head:
                if (m_HeadSlot != null)
                {
                    m_HeadSlot.UnequippedBy(m_Owner);
                    m_Owner.Inventory.AddItem(m_HeadSlot);
                    OnUnequip?.Invoke(m_HeadSlot);
                    m_HeadSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Torso:
                if (m_TorsoSlot != null)
                {
                    m_TorsoSlot.UnequippedBy(m_Owner);
                    m_Owner.Inventory.AddItem(m_TorsoSlot);
                    OnUnequip?.Invoke(m_TorsoSlot);
                    m_TorsoSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Legs:
                if (m_LegsSlot != null)
                {
                    m_LegsSlot.UnequippedBy(m_Owner);
                    m_Owner.Inventory.AddItem(m_LegsSlot);
                    OnUnequip?.Invoke(m_LegsSlot);
                    m_LegsSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Feet:
                if (m_FeetSlot != null)
                {
                    m_FeetSlot.UnequippedBy(m_Owner);
                    m_Owner.Inventory.AddItem(m_FeetSlot);
                    OnUnequip?.Invoke(m_FeetSlot);
                    m_FeetSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Accessory:
                if (m_AccessorySlot != null)
                {
                    m_AccessorySlot.UnequippedBy(m_Owner);
                    m_Owner.Inventory.AddItem(m_AccessorySlot);
                    OnUnequip?.Invoke(m_AccessorySlot);
                    m_AccessorySlot = null;
                }
                break;

            case (EquipmentItem.EquipmentSlot) 666:
                if (Weapon != null &&
                    (Weapon != m_DefaultWeapon || isReplacement))     // the only way to unequip the default weapon is through replacing it
                {
                    Weapon.UnequippedBy(m_Owner);

                    //the default weapon does not go back to the inventory
                    if (Weapon != m_DefaultWeapon)
                    {
                        m_Owner.Inventory.AddItem(Weapon);
                    }

                    OnUnequip?.Invoke(Weapon);
                    Weapon = null;

                    //reequip the default weapon if this is not an unequip to equip a new one
                    if (!isReplacement)
                    {
                        Equip(m_DefaultWeapon);
                    }
                }
                break;

            default:
                break;
            }
        }
예제 #4
0
        /// <summary>
        /// Unequip the item in the given slot.
        /// </summary>
        /// <param name="slot"></param>
        public void Unequip(EquipmentItem.EquipmentSlot slot)
        {
            switch (slot)
            {
            case EquipmentItem.EquipmentSlot.Head:
                if (_headSlot != null)
                {
                    _headSlot.UnequippedBy(_owner);
                    // m_Owner.Inventory.AddItem(m_HeadSlot);
                    OnUnequip?.Invoke(_headSlot);
                    _headSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Torso:
                if (_torsoSlot != null)
                {
                    _torsoSlot.UnequippedBy(_owner);
                    // m_Owner.Inventory.AddItem(m_TorsoSlot);
                    OnUnequip?.Invoke(_torsoSlot);
                    _torsoSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Legs:
                if (_legsSlot != null)
                {
                    _legsSlot.UnequippedBy(_owner);
                    // m_Owner.Inventory.AddItem(m_LegsSlot);
                    OnUnequip?.Invoke(_legsSlot);
                    _legsSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Feet:
                if (_feetSlot != null)
                {
                    _feetSlot.UnequippedBy(_owner);
                    // m_Owner.Inventory.AddItem(m_FeetSlot);
                    OnUnequip?.Invoke(_feetSlot);
                    _feetSlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Accessory:
                if (_accessorySlot != null)
                {
                    _accessorySlot.UnequippedBy(_owner);
                    // m_Owner.Inventory.AddItem(m_AccessorySlot);
                    OnUnequip?.Invoke(_accessorySlot);
                    _accessorySlot = null;
                }
                break;

            case EquipmentItem.EquipmentSlot.Weapon:
                if (Weapon != null)
                {
                    Weapon.UnequippedBy(_owner);

                    OnUnequip?.Invoke(Weapon);
                    Weapon = null;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(slot), slot, null);
            }
        }