MaxCapacity() public method

public MaxCapacity ( ) : int
return int
 public static bool RemoveItemFromSubContainers(Container cn, string objectName)
 {
     for (int i =0; i<=cn.MaxCapacity ();i++)
     {
         if (cn.items[i] == objectName)
         {
             cn.RemoveItemFromContainer(i);
             return true;
         }
         else
         {
             if (cn.items[i] !="")
             {
                 GameObject obj = GameObject.Find (cn.items[i]);
                 if (obj!=null)
                 {
                     if (obj.GetComponent<Container>()!=null)
                     {
                         return RemoveItemFromSubContainers(obj.GetComponent<Container>(),objectName);
                     }
                 }
             }
         }
     }
     return false;
 }
 public static int GetFreeSlot(Container cn)
 {
     //Returns an available slot on the current container.
     for (int i=0;i<=cn.MaxCapacity();i++)
     {
         if (cn.GetItemAt (i)=="")
         {
             return i;
         }
     }
     return -1;
 }
 public static void SetItemsPosition(Container cn, Vector3 Position)
 {
     for (int i =0; i<=cn.MaxCapacity();i++)
     {
         string ItemName=cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = GameObject.Find (cn.GetItemAt(i));
             if (item!=null)
             {
                 item.transform.position=Position;
                 if (item.GetComponent<Container>()!=null)
                 {
                     Container.SetItemsPosition(item.GetComponent<Container>(),Position);
                 }
             }
         }
     }
 }
 public static void SetItemsParent(Container cn, Transform Parent)
 {
     for (int i =0; i<=cn.MaxCapacity ();i++)
     {
         string ItemName=cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = GameObject.Find (cn.GetItemAt(i));
             if (item != null)
             {
                 item.transform.parent=Parent;
                 if (item.GetComponent<Container>()!=null)
                 {
                     Container.SetItemsParent(item.GetComponent<Container>(),Parent);
                 }
             }
         }
     }
 }
 void CloseChildContainer(Container ClosingParent)
 {
     //Recursively closes open child containers
     ClosingParent.isOpenOnPanel=false;
     for (int i = 0;i<=ClosingParent.MaxCapacity();i++)
     {
         if (ClosingParent.items[i] !="")
         {
             GameObject currObj = GameObject.Find (ClosingParent.items[i]);
             {
                 if (currObj!=null)
                 {
                     Container currObjContainer = currObj.GetComponent<Container>();
                     if (currObjContainer !=null)
                     {
                         CloseChildContainer (currObjContainer);
                     }
                 }
             }
         }
     }
 }
    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);
    }
 public static void SortContainer(Container cn)
 {
     //Debug.Log ("Sorting container");
     //Flattens the contents of a container so that they occupy the first slots
     int currFreeSlot=-1;
     string ItemName;
     bool GetNextSlot=true;
     for (int i=0;i<=cn.MaxCapacity();i++)
     {
         //Find the first free slot
         if (GetNextSlot==true)
         {
             for (int j=0;j<=cn.MaxCapacity();j++)
             {
                 ItemName=cn.GetItemAt(j);
                 if (ItemName=="")
                 {
                     currFreeSlot=j;
                     GetNextSlot=false;
                     break;
                 }
             }
         }
         if ((i>currFreeSlot) &&(currFreeSlot!=-1))
         {
             ItemName=cn.GetItemAt(i);
             if (ItemName!="")
             {//Move this item to the free slot
                 cn.RemoveItemFromContainer(i);
                 cn.AddItemToContainer(ItemName,currFreeSlot);
                 GetNextSlot=true;
                 currFreeSlot=-1;
             }
         }
     }
 }
 public static void SetPickedUpFlag(Container cn, bool NewValue)
 {
     //Recursivly sets the picked up flag on all items in the container and all sub-container contents.
     for (int i =0; i<=cn.MaxCapacity();i++)
     {
         string ItemName=cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = GameObject.Find (cn.GetItemAt(i));
             if (item !=null)
             {
                 if (item.GetComponent<ObjectInteraction>()!=null)
                 {
                     item.GetComponent<ObjectInteraction>().PickedUp=NewValue;
                     if (item.GetComponent<ObjectInteraction>().GetItemType()==ObjectInteraction.A_PICK_UP_TRIGGER)
                     {//Special case
                         item.GetComponent<a_pick_up_trigger>().Activate();
                         //if (item==null)
                         //{//Use trigger is no more.
                         cn.RemoveItemFromContainer(i);
                         //}
                     }
                     else if (item.GetComponent<Container>()!=null)
                     {
                         Container.SetPickedUpFlag(item.GetComponent<Container>(),NewValue);
                     }
                 }
             }
         }
     }
 }