当前位置: 首页>>代码示例>>C#>>正文


C# Container.MaxCapacity方法代码示例

本文整理汇总了C#中Container.MaxCapacity方法的典型用法代码示例。如果您正苦于以下问题:C# Container.MaxCapacity方法的具体用法?C# Container.MaxCapacity怎么用?C# Container.MaxCapacity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Container的用法示例。


在下文中一共展示了Container.MaxCapacity方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveItemFromSubContainers

 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;
 }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:26,代码来源:Container.cs

示例2: GetFreeSlot

 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;
 }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:12,代码来源:Container.cs

示例3: SetItemsPosition

 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);
                 }
             }
         }
     }
 }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:19,代码来源:Container.cs

示例4: SetItemsParent

 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);
                 }
             }
         }
     }
 }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:19,代码来源:Container.cs

示例5: CloseChildContainer

 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);
                     }
                 }
             }
         }
     }
 }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:22,代码来源:ContainerOpened.cs

示例6: TestContainerRules

    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);
    }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:72,代码来源:Container.cs

示例7: SortContainer

 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;
             }
         }
     }
 }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:36,代码来源:Container.cs

示例8: SetPickedUpFlag

 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);
                     }
                 }
             }
         }
     }
 }
开发者ID:hankmorgan,项目名称:UnderworldExporter,代码行数:31,代码来源:Container.cs


注:本文中的Container.MaxCapacity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。