public static RemoveItemFromSubContainers ( Container, cn, string objectName ) : bool | ||
cn | Container, | |
objectName | string | |
Résultat | bool |
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 bool RemoveItem(string ObjectName) { //Removes the item from the paperdoll and/or the player inventory. if (sHelm == ObjectName) { UnEquipItemEvent(0); sHelm = ""; bHelm = true; return(true); } if (sChest == ObjectName) { UnEquipItemEvent(1); sChest = ""; bChest = true; return(true); } if (sLegs == ObjectName) { UnEquipItemEvent(2); sLegs = ""; bLegs = true; return(true); } if (sBoots == ObjectName) { UnEquipItemEvent(3); sBoots = ""; bBoots = true; return(true); } if (sGloves == ObjectName) { UnEquipItemEvent(4); sGloves = ""; bGloves = true; return(true); } if (sRightShoulder == ObjectName) { //UnEquipItemEvent(5); sRightShoulder = ""; bRightShoulder = true; return(true); } if (sLeftShoulder == ObjectName) { //UnEquipItemEvent(6); sLeftShoulder = ""; bLeftShoulder = true; return(true); } if (sRightHand == ObjectName) { UnEquipItemEvent(7); sRightHand = ""; bRightHand = true; return(true); } if (sLeftHand == ObjectName) { UnEquipItemEvent(8); sLeftHand = ""; bLeftHand = true; return(true); } if (sRightRing == ObjectName) { UnEquipItemEvent(9); sRightRing = ""; bRightRing = true; return(true); } if (sLeftRing == ObjectName) { UnEquipItemEvent(10); sLeftRing = ""; bLeftRing = true; return(true); } Container backpack = GameObject.Find(this.currentContainer).GetComponent <Container>(); for (int i = 0; i < 8; i++) { if (ObjectName == backpack.items[i]) { backpack.items[i] = ""; sBackPack[i] = ""; bBackPack[i] = true; return(true); } } //Try and find it in the entire inventory if (Container.RemoveItemFromSubContainers(playerContainer, ObjectName)) { return(true); } //Try and find it as a container subitem on the paperdoll slots. for (int i = 0; i <= 10; i++) { GameObject obj = GetGameObjectAtSlot(i); if (obj != null) { if (obj.GetComponent <Container>() != null) { if (Container.RemoveItemFromSubContainers(obj.GetComponent <Container>(), ObjectName)) { return(true); } } } } return(false); }