本文整理汇总了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;
}
示例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;
}
示例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);
}
}
}
}
}
示例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);
}
}
}
}
}
示例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);
}
}
}
}
}
}
示例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);
}
示例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;
}
}
}
}
示例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);
}
}
}
}
}
}