GetGameObjectAt() 공개 메소드

public GetGameObjectAt ( int index ) : GameObject
index int
리턴 GameObject
예제 #1
0
 public static void SetItemsParent(Container cn, Transform Parent)
 {
     for (short i = 0; i <= cn.MaxCapacity(); i++)
     {
         string ItemName = cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = cn.GetGameObjectAt(i);                 //GameObject.Find (cn.GetItemAt(i));
             if (item != null)
             {
                 item.transform.parent = Parent;
                 if (Parent == GameWorldController.instance.LevelMarker())
                 {
                     GameWorldController.MoveToWorld(item);
                 }
                 else
                 {
                     GameWorldController.MoveToInventory(item);
                 }
                 if (item.GetComponent <Container>() != null)
                 {
                     Container.SetItemsParent(item.GetComponent <Container>(), Parent);
                 }
             }
         }
     }
 }
예제 #2
0
    public float getInventoryWeight()
    {
        float answer = 0.0f;

        //Get the weight of all the equipment slots
        for (int i = 0; i <= 10; i++)
        {
            GameObject objItem = GetGameObjectAtSlot(i);
            if (objItem != null)
            {
                answer += objItem.GetComponent <ObjectInteraction>().GetWeight();
            }
        }

        //Get the weight of the gronk container as that is alway the top level of the inventory
        for (short i = 0; i <= playerContainer.MaxCapacity(); i++)
        {
            GameObject objItem = playerContainer.GetGameObjectAt(i);             //GameObject.Find (playerContainer.GetItemAt(i));
            if (objItem != null)
            {
                answer += objItem.GetComponent <ObjectInteraction>().GetWeight();
            }
            else
            {
                answer += 0;
            }
        }
        return(answer);
    }
예제 #3
0
 public static void SetItemsPosition(Container cn, Vector3 Position)
 {
     for (short i = 0; i <= cn.MaxCapacity(); i++)
     {
         string ItemName = cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = cn.GetGameObjectAt(i);                //GameObject.Find (cn.GetItemAt(i));
             if (item != null)
             {
                 item.transform.position = Position;
                 if (item.GetComponent <Container>() != null)
                 {
                     Container.SetItemsPosition(item.GetComponent <Container>(), Position);
                 }
             }
         }
     }
 }
예제 #4
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 (short i = 0; i <= cn.MaxCapacity(); i++)
     {
         GameObject item = cn.GetGameObjectAt(i);            // 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(cn.gameObject);
                     cn.RemoveItemFromContainer(i);
                 }
                 else if (item.GetComponent <Container>() != null)
                 {
                     Container.SetPickedUpFlag(item.GetComponent <Container>(), NewValue);
                 }
             }
         }
     }
 }
예제 #5
0
    /// <summary>
    /// Mixs the rotworm stew.
    /// </summary>
    /// <returns><c>true</c>, if rotworm stew was mixed, <c>false</c> otherwise.</returns>
    bool MixRotwormStew()
    {
        bool hasPort               = false;
        ObjectInteraction port     = null;
        bool hasGreenMushroom      = false;
        ObjectInteraction mushroom = null;
        bool hasCorpse             = false;
        ObjectInteraction corpse   = null;
        bool hasExtraItems         = false;
        //Find a bowl in the players inventory.
        //Check if it only contains port, a rotworm corpse and a greenmushroom.

        //000~001~148~The bowl does not contain the correct ingredients. \n
        //000~001~149~You mix the ingredients into a stew. \n
        //000~001~150~You need a bowl to mix the ingredients. \n
        Container cn = UWCharacter.Instance.playerInventory.playerContainer;

        if (cn != null)
        {
            string BowlName = cn.findItemOfType(142);   //Finds the first bowl in the inventory;
            if (BowlName != "")
            {
                GameObject bowl = GameObject.Find(BowlName);
                if (bowl != null)
                {
                    //Search for
                    Container bowlContainer = bowl.GetComponent <Container>();
                    if (bowlContainer != null)
                    {
                        for (short i = 0; i <= bowlContainer.GetCapacity(); i++)
                        {
                            GameObject foundItem = bowlContainer.GetGameObjectAt(i);
                            if (foundItem != null)
                            {
                                ObjectInteraction foundItemObj = foundItem.GetComponent <ObjectInteraction>();
                                if (foundItemObj != null)
                                {
                                    switch (foundItemObj.item_id)
                                    {
                                    case 184:                                                                                            //Mushroom
                                        mushroom         = foundItemObj;
                                        hasGreenMushroom = true; break;

                                    case 190:                                                                                            //Port
                                        port    = foundItemObj;
                                        hasPort = true; break;

                                    case 217:                                                                                            //Rotworm Corpse
                                        corpse    = foundItemObj;
                                        hasCorpse = true; break;

                                    default:
                                        hasExtraItems = true; break;
                                    }
                                }
                            }
                        }
                        //Has a bowl. Now test contents.
                        if (
                            (hasCorpse) && (hasGreenMushroom) && (hasPort) &&
                            (!hasExtraItems)
                            )
                        {                                                        //Mix port
                            //000~001~149~You mix the ingredients into a stew. \n
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 149));
                            //Consume the items
                            port.consumeObject();
                            corpse.consumeObject();
                            mushroom.consumeObject();

                            ObjectInteraction bowlObjectInt = bowl.GetComponent <ObjectInteraction>();
                            bowlObjectInt.ChangeType(283, 16);
                            Destroy(bowlContainer);
                            bowl.AddComponent <Food>();
                            //bowl.GetComponent<Food>().Nutrition=5;
                            return(true);
                        }
                        else
                        {                                                        //We don't have the items
                            //000~001~148~The bowl does not contain the correct ingredients. \n
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 148));
                            return(true);
                        }
                    }
                }
            }
        }
        //000~001~150~You need a bowl to mix the ingredients. \n
        UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 150));
        return(true);
    }