コード例 #1
0
ファイル: Inventory.cs プロジェクト: Cdrix/SM
    /// <summary>
    /// The int returned is the amount was removed from the inventory.
    /// If wht was asked in 'amt' was not fully returned means the inventory hadnt enough to coverred it
    ///
    /// Then item will be removed from inventory
    /// </summary>
    /// <param name="key"></param>
    /// <param name="kg"></param>
    /// <returns></returns>
    public float RemoveByWeight(P key, float kg)
    {
        InvItem curr = null;

        if (IsItemOnInv(key))
        {
            //it means it can cover the amount asked to be removed
            if (ReturnAmtOfItemOnInv(key) - kg > 0)
            {
                float intT = ReturnAmtOfItemOnInv(key) - kg;
                curr = SetAmtWithKey(key, intT);
                CheckIfAnAmtHasExpired(curr);

                AddressGameInventory(key, kg, false);
                return(kg);
            }
            //other wise will depleted
            float t = ReturnAmtOfItemOnInv(key);
            curr = SetAmtWithKey(key, 0);
            CheckIfAnAmtHasExpired(curr);

            RemoveWithKey(key);
            AddressGameInventory(key, kg, false);
            return(t);
        }
        //storages has a well attached
        if (key == P.Water && LocMyId.Contains("Storage"))
        {
            return(kg);
        }

        //docker having negative amount of item on inventory
        RemoveWithKey(key);
        return(0);
    }
コード例 #2
0
ファイル: Inventory.cs プロジェクト: Cdrix/SM
 /// <summary>
 /// Created so 'Storages' appear to have water
 /// </summary>
 /// <returns></returns>
 internal bool DoWeHaveWater()
 {
     return(LocMyId.Contains("Storage") || Contains(P.Water));
 }