示例#1
0
    private void InsertWeaponItemIntoInv(int itemID)
    {
        if (!ItemManager.IsWeaponItem(itemID))
        {
            throw new System.ArgumentException($"This function only inserts " +
                                               $"weapon items into the inventory but was given {itemID} " +
                                               $"which is NOT a weapon item.");
        }
        if (HasTwoWeapons())
        {
            throw new System.AccessViolationException("Trying to insert " +
                                                      "a weapon item into the inventory but player already " +
                                                      "has two weapons in inventory.");
        }

        // Inserting into first weapon slot
        if (m_Inventory[m_WeaponStartingIndex] == Consts.NULL_ITEM_ID)
        {
            m_Inventory[m_WeaponStartingIndex] = itemID;
            m_UI.SetWeaponOneImage(itemID);
        }

        // Inserting into second weapon slot
        //else {
        //    m_Inventory[m_WeaponStartingIndex + 1] = itemID;
        //    m_UI.SetWeaponTwoImage(itemID);
        //}
    }