GetFreeCapacity() public method

public GetFreeCapacity ( ) : float
return float
Esempio n. 1
0
    public static bool TestContainerRules(Container cn, int SlotIndex)
    {
        if (SlotIndex < 11)
        {
            return(true);
        }
        //Test the various rules for this slot
        ObjectInteraction objInt = playerUW.playerInventory.GetGameObjectInHand().GetComponent <ObjectInteraction>();
        //If in a non player container check that the object in hand can be added to it.
        bool TypeTest = false;
        //If in a non player container check that the container has the weight capacity to accept it.
        bool WeightTest = false;

//		Container curContainer = this;
        switch (cn.ObjectsAccepted)
        {        //objects accepted; 0: runes, 1: arrows, 2: scrolls, 3: edibles, 0xFF: any
        case 0:  //runes
            TypeTest = (objInt.ItemType == ObjectInteraction.RUNE); break;

        case 1:        //Arrows
            TypeTest = (objInt.ItemType == ObjectInteraction.AMMO); break;

        case 2:        //Scrolls
            TypeTest = (
                (objInt.ItemType == ObjectInteraction.SCROLL)
                ||
                (objInt.ItemType == ObjectInteraction.MAGICSCROLL)
                ||
                (objInt.ItemType == ObjectInteraction.MAP)
                );
            break;

        case 3:         //Edibles
            TypeTest = (objInt.ItemType == ObjectInteraction.FOOD); break;

        default:
            TypeTest = true; break;
        }



        if (TypeTest == true)
        {
            if (objInt.GetWeight() >= cn.GetFreeCapacity())
            {
                WeightTest = false;
                playerUW.playerHud.MessageScroll.Add("The " + playerUW.StringControl.GetSimpleObjectNameUW(cn.objInt) + " is too full.");
            }
            else
            {
                WeightTest = true;
            }
        }
        else
        {        //000~001~248~That item does not fit.
            playerUW.playerHud.MessageScroll.Add(playerUW.StringControl.GetString(1, 248));
        }
        return(TypeTest && WeightTest);
    }
    public static bool TestContainerRules(Container cn, int SlotIndex, bool Swapping)
    {
        if (SlotIndex < 11)
        {
            return(true);
        }
        if (UWCharacter.Instance.playerInventory.ObjectInHand == "")
        {
            return(true);
        }
        //Test the various rules for this slot
        ObjectInteraction objInt = UWCharacter.Instance.playerInventory.GetGameObjectInHand().GetComponent <ObjectInteraction>();
        //If in a non player container check that the object in hand can be added to it.
        bool TypeTest = false;
        //If in a non player container check that the container has the weight capacity to accept it.
        bool WeightTest = false;
//		Container curContainer = this;
        bool CapacityTest = false;

        if (EditorMode)                        //Anything is allowed in editor mode.
        {
            return(true);
        }
        switch (cn.ObjectsAccepted())
        {        //objects accepted; 0: runes, 1: arrows, 2: scrolls, 3: edibles, 0xFF: any
        case 0:  //runes
            TypeTest = (objInt.GetItemType() == ObjectInteraction.RUNE); break;

        case 1:        //Arrows
            TypeTest = (objInt.GetItemType() == ObjectInteraction.AMMO); break;

        case 2:        //Scrolls
            TypeTest = (
                (objInt.GetItemType() == ObjectInteraction.SCROLL)
                ||
                (objInt.GetItemType() == ObjectInteraction.MAGICSCROLL)
                ||
                (objInt.GetItemType() == ObjectInteraction.MAP)
                ||
                (objInt.GetItemType() == ObjectInteraction.BOOK)
                );
            break;

        case 3:         //Edibles
            TypeTest = ((objInt.GetItemType() == ObjectInteraction.FOOD) || (objInt.GetItemType() == ObjectInteraction.POTIONS)); break;

        default:
            TypeTest = true; break;
        }

        if (TypeTest == true)
        {
            if (objInt.GetWeight() >= cn.GetFreeCapacity())
            {
                WeightTest = false;
                UWHUD.instance.MessageScroll.Add("The " + StringController.instance.GetSimpleObjectNameUW(cn.objInt()) + " is too full.");
            }
            else
            {
                WeightTest = true;
            }
        }
        else
        {        //000~001~248~That item does not fit.
            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_that_item_does_not_fit_));
        }

        if (WeightTest == true)
        {
            if (cn.CountItems() <= cn.MaxCapacity())
            {
                CapacityTest = true;
            }
            else
            {            //000~001~248~That item does not fit.
                UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_that_item_does_not_fit_));
            }
        }
        return(TypeTest && WeightTest && (CapacityTest | Swapping));
    }
Esempio n. 3
0
    public static bool TestContainerRules(Container cn, int SlotIndex)
    {
        if (SlotIndex<11)
        {
            return true;
        }
        if (GameWorldController.instance.playerUW.playerInventory.ObjectInHand=="")
        {
            return true;
        }
        //Test the various rules for this slot
        ObjectInteraction objInt = GameWorldController.instance.playerUW.playerInventory.GetGameObjectInHand().GetComponent<ObjectInteraction>();
        //If in a non player container check that the object in hand can be added to it.
        bool TypeTest=false;
        //If in a non player container check that the container has the weight capacity to accept it.
        bool WeightTest=false;
        //		Container curContainer = this;
        bool CapacityTest=false;

        switch (cn.ObjectsAccepted)
        {//objects accepted; 0: runes, 1: arrows, 2: scrolls, 3: edibles, 0xFF: any
        case 0://runes
            TypeTest=(objInt.GetItemType()==ObjectInteraction.RUNE);break;
        case 1://Arrows
            TypeTest=(objInt.GetItemType()==ObjectInteraction.AMMO);break;
        case 2://Scrolls
            TypeTest=(
                (objInt.GetItemType()==ObjectInteraction.SCROLL)
                ||
                (objInt.GetItemType()==ObjectInteraction.MAGICSCROLL)
                ||
                (objInt.GetItemType()==ObjectInteraction.MAP)
                ||
                (objInt.GetItemType()==ObjectInteraction.BOOK)
                );
            break;
        case 3: //Edibles
            TypeTest=((objInt.GetItemType()==ObjectInteraction.FOOD) || (objInt.GetItemType()==ObjectInteraction.POTIONS));break;
        default:
            TypeTest=true;break;
        }

        if (TypeTest==true)
        {
            if (objInt.GetWeight() >= cn.GetFreeCapacity())
            {
                WeightTest=false;
                UWHUD.instance.MessageScroll.Add ("The " + StringController.instance.GetSimpleObjectNameUW(cn.objInt()) + " is too full.");
            }
            else
            {
                WeightTest=true;
            }
        }
        else
        {//000~001~248~That item does not fit.
            UWHUD.instance.MessageScroll.Add (StringController.instance.GetString(1,248));
        }

        if (WeightTest==true)
        {
            if (cn.CountItems()<=cn.MaxCapacity())
            {
                CapacityTest=true;
            }
            else
            {//000~001~248~That item does not fit.
                UWHUD.instance.MessageScroll.Add (StringController.instance.GetString(1,248));
            }
        }
        return (TypeTest && WeightTest && CapacityTest);
    }