Container.SetPickedUpFlag C# (CSharp) Method

SetPickedUpFlag() public static method

public static SetPickedUpFlag ( Container, cn, bool NewValue ) : void
cn Container,
NewValue bool
return void
    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);
                        }
                    }
                }
            }
        }
    }

Usage Example

Exemplo n.º 1
0
 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>().ItemType == 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);
                     }
                 }
             }
         }
     }
 }
All Usage Examples Of Container::SetPickedUpFlag