GetWeight() 공개 메소드

public GetWeight ( ) : float
리턴 float
예제 #1
0
    public float getInventoryWeight()
    {
        float answer = 0.0f;

        //Get the weight of all the equipment slots
        for (int i = 0; i <= 10; i++)
        {
            ObjectInteraction objItem = GetObjectIntAtSlot(i);
            if (objItem != null)
            {
                answer += objItem.GetWeight();
            }
        }

        //Get the weight of the gronk container as that is alway the top level of the inventory
        for (short i = 0; i <= playerContainer.MaxCapacity(); i++)
        {
            ObjectInteraction objItem = playerContainer.GetItemAt(i); //GameObject.Find (playerContainer.GetItemAt(i));
            if (objItem != null)
            {
                answer += objItem.GetWeight();
            }
            else
            {
                answer += 0;
            }
        }
        return(answer);
    }
예제 #2
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);
    }
예제 #3
0
    public override float GetWeight()
    {                                    //Get the weight of all items in the container
        float answer = base.GetWeight(); //The container has it's own weight as well.

        for (int i = 0; i < MaxCapacity(); i++)
        {
            if (GetItemAt(i) != "")
            {
                ObjectInteraction objContainerItem = GameObject.Find(GetItemAt(i)).GetComponent <ObjectInteraction>();
                answer += objContainerItem.GetWeight();
            }
        }
        return(answer);
    }
    public float GetWeight(float containerObjWeight)
    {                                      //Get the weight of all items in the container
        float answer = containerObjWeight; //The container has it's own weight as well.

        for (short i = 0; i <= MaxCapacity(); i++)
        {
            ObjectInteraction objContainerItem = GetItemAt(i);
            //if (GetItemAt(i) != "")
            //{
            //GameObject ItemAt = GetGameObjectAt(i); //GameObject.Find (GetItemAt(i));
            if (objContainerItem != null)
            {
                //ObjectInteraction objContainerItem = ItemAt.GetComponent<ObjectInteraction>();
                //if (objContainerItem != null)
                //{
                answer += objContainerItem.GetWeight();
                //}
            }
            // }
        }
        return(answer);
    }
예제 #5
0
    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));
    }