Exemple #1
0
    /// <summary>
    /// tries to remove one unit from the external
    /// clip item type and returns result
    /// </summary>
    protected virtual bool OnAttempt_RemoveClip()
    {
        // fail if we don't have the weapon or it is unknown
        if (m_CurrentWeaponStatus == null)
        {
            return(false);
        }


        // fail if ammo type is unknown
        InventoryItemStatus ammo = GetItemStatus(m_CurrentWeaponStatus.ClipType);

        if (ammo == null)
        {
            return(false);
        }

        // can't reload if ammo is full
        if (m_CurrentWeaponStatus.LoadedAmmo >= m_CurrentWeaponStatus.MaxAmmo)
        {
            return(false);
        }

        // try to remove an ammo clip
        if (!m_Player.RemoveItem.Try(new object[] { m_CurrentWeaponStatus.ClipType }))
        {
            return(false);
        }

        return(true);
    }
Exemple #2
0
    /// <summary>
    /// tries to add an amount of units to the item count. fails
    /// if item count is maxed out
    /// </summary>
    protected virtual bool OnAttempt_AddItem(object args)
    {
        object[] arr    = (object[])args;
        string   name   = (string)arr[0];
        int      amount = (arr.Length == 2) ? (int)arr[1] : 1;

        // fail if item type is unknown
        InventoryItemStatus type = GetItemStatus(name);

        if (type == null)
        {
            return(false);
        }

        // enforce ability to have atleast 1 item of each type
        type.CanHave = Mathf.Max(1, type.CanHave);

        // fail if we already have max units of this item
        if (type.Have >= type.CanHave)
        {
            return(false);
        }

        // add amount (cap at max)
        type.Have = Mathf.Min(type.Have + amount, type.CanHave);

        return(true);
    }
Exemple #3
0
    /// <summary>
    /// tries to remove one unit from the item count.
    /// fails if item count is zero
    /// </summary>
    protected virtual bool OnAttempt_RemoveItem(object args)
    {
        object [] arr    = (object[])args;
        string    name   = (string)arr[0];
        int       amount = (arr.Length == 2) ? (int)arr[1] : 1;

        // fail if item type is unknown
        InventoryItemStatus type = GetItemStatus(name);

        if (type == null)
        {
            return(false);
        }

        // fail if we have zero units of this item
        if (type.Have <= 0)
        {
            return(false);
        }

        // reduce amount (cap at zero)
        type.Have = Mathf.Max(type.Have - amount, 0);

        return(true);
    }
 // constructor for loading an EXISTING Inventory Item - This constructor DOES NOT create a new GUID
 public InventoryItem(Guid inventoryItemId, InventoryItemStatus inventoryItemStatus, string inventoryItemName, int numberInStock,
                      Guid catalogItemId, string itemManufacturer, int numberInscriptionLines,
                      int numberLineCharacters, decimal itemCost, decimal itemRetailPrice, InscriptionType inscriptionType)
     : base(catalogItemId)
 {
     _inventoryItemId = inventoryItemId;
     InventoryItemStatus _inventoryItemStatus = inventoryItemStatus;
     base.ItemName = inventoryItemName;
     base.CatalogItemId = catalogItemId;
     base.Manufacturer = itemManufacturer;
     base.NumberInscriptionLines = numberInscriptionLines;
     base.NumberLineCharacters = numberLineCharacters;
     base.ItemCost = itemCost;
     base.ItemRetailPrice = itemRetailPrice;
     base.InscriptionType = inscriptionType;
 }
Exemple #5
0
        // constructor for loading an EXISTING Inventory Item - This constructor DOES NOT create a new GUID
        public InventoryItem(Guid inventoryItemId, InventoryItemStatus inventoryItemStatus, string inventoryItemName, int numberInStock,
                             Guid catalogItemId, string itemManufacturer, int numberInscriptionLines,
                             int numberLineCharacters, decimal itemCost, decimal itemRetailPrice, InscriptionType inscriptionType)
            : base(catalogItemId)
        {
            _inventoryItemId = inventoryItemId;
            InventoryItemStatus _inventoryItemStatus = inventoryItemStatus;

            base.ItemName               = inventoryItemName;
            base.CatalogItemId          = catalogItemId;
            base.Manufacturer           = itemManufacturer;
            base.NumberInscriptionLines = numberInscriptionLines;
            base.NumberLineCharacters   = numberLineCharacters;
            base.ItemCost               = itemCost;
            base.ItemRetailPrice        = itemRetailPrice;
            base.InscriptionType        = inscriptionType;
        }