findItemOfType() публичный Метод

Finds the first item of a particular type in the container.
public findItemOfType ( int itemid ) : string
itemid int Itemid.
Результат string
Пример #1
0
    public ObjectInteraction findObjInteractionByID(int item_id)
    {    //Returns the first instance of a particular Item id in the players inventory
        for (int i = 0; i <= 10; i++)
        {
            GameObject obj = GetGameObjectAtSlot(i);
            if (obj != null)
            {
                ObjectInteraction objInt = obj.GetComponent <ObjectInteraction>();
                if (objInt != null)
                {
                    if (objInt.item_id == item_id)
                    {
                        return(objInt);
                    }
                }
            }
        }
        //playerUW.GetComponent<Container>();
        string find = playerContainer.findItemOfType(item_id);

        if (find != "")
        {
            GameObject        obj    = GameObject.Find(find);
            ObjectInteraction objInt = obj.GetComponent <ObjectInteraction>();
            if (objInt != null)
            {
                if (objInt.item_id == item_id)
                {
                    return(objInt);
                }
            }
        }
        return(null);
    }
Пример #2
0
    public ObjectInteraction findObjInteractionByID(int item_id)
    {     //Returns the first instance of a particular Item id in the players inventory
        for (int i = 0; i <= 10; i++)
        { //Search the paperdoll slots first.
            GameObject obj = GetGameObjectAtSlot(i);
            if (obj != null)
            {
                ObjectInteraction objInt = obj.GetComponent <ObjectInteraction>();
                if (objInt != null)
                {
                    if (objInt.item_id == item_id)
                    {
                        return(objInt);
                    }
                    else
                    {
                        if (objInt.GetItemType() == ObjectInteraction.CONTAINER)
                        {
                            string find2 = obj.GetComponent <Container>().findItemOfType(item_id);
                            if (find2 != "")
                            {
                                GameObject        obj2    = GameObject.Find(find2);
                                ObjectInteraction objInt2 = obj2.GetComponent <ObjectInteraction>();
                                if (objInt2 != null)
                                {
                                    if (objInt2.item_id == item_id)
                                    {
                                        return(objInt2);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        //playerUW.GetComponent<Container>();
        string find = playerContainer.findItemOfType(item_id);

        if (find != "")
        {
            GameObject        obj    = GameObject.Find(find);
            ObjectInteraction objInt = obj.GetComponent <ObjectInteraction>();
            if (objInt != null)
            {
                if (objInt.item_id == item_id)
                {
                    return(objInt);
                }
            }
        }
        return(null);
    }
Пример #3
0
    /// <summary>
    /// Determines whether this object is a quest object or similar object that should not be destroyed by contact. If it is a container it will search to the container for a quest object.
    /// </summary>
    /// <returns><c>true</c> if this instance is object quest related the specified obj; otherwise, <c>false</c>.</returns>
    /// <param name="obj">Object.</param>
    /// Implemented for UW1 only so far.
    public bool IsObjectDestroyable(ObjectInteraction obj)
    {
        int[] UW1_Protected_items = { 453,  10,  50,  47,  54,  55, 151, 147,
                                      280, 281, 275, 272, 273, 276, 258, 259,
                                      260, 261, 262, 263, 265, 265, 266, 267,
                                      268, 269, 270, 285, 191, 175, 287, 290, 143, 315 };

        if (ObjectLoader.isStatic(obj.BaseObjectData))
        {
            return(false);
        }

        if ((obj.item_id >= 64) && (obj.item_id <= 127))
        {//For the moment don't do anything to Npcs
            return(false);
        }

        if (obj.GetComponent <Rigidbody>() != null)
        {
            if (obj.GetComponent <Rigidbody>().useGravity == false)
            {//Object has probably spawned at this point.
                return(false);
            }
        }

        for (int i = 0; i <= UW1_Protected_items.GetUpperBound(0); i++)
        {
            if (obj.item_id == UW1_Protected_items[i])
            {
                return(false);
            }
        }

        if (obj.GetComponent <Container>() != null)
        {
            Container cn = obj.GetComponent <Container>();
            for (int i = 0; i <= UW1_Protected_items.GetUpperBound(0); i++)
            {
                if (cn.findItemOfType(UW1_Protected_items[i]) != null)
                {
                    return(false);
                }
            }
        }
        return(true);
    }
Пример #4
0
    /// <summary>
    /// Returns the first instance of a particular Item id in the players inventory
    /// </summary>
    /// <param name="item_id">Item ID to find</param>
    /// <returns></returns>
    public ObjectInteraction findObjInteractionByID(int item_id)
    {
        for (int i = 0; i <= 10; i++)
        {//Search the paperdoll slots first.
            ObjectInteraction objInt = GetObjectIntAtSlot(i);
            //ObjectInteraction objInt = obj.GetComponent<ObjectInteraction>();
            if (objInt != null)
            {
                if (objInt.item_id == item_id)
                {
                    return(objInt);
                }
                else
                {
                    if (objInt.GetItemType() == ObjectInteraction.CONTAINER)
                    {
                        ObjectInteraction find2 = objInt.GetComponent <Container>().findItemOfType(item_id);
                        if (find2 != null)
                        {
                            if (find2.item_id == item_id)
                            {
                                return(find2);
                            }
                        }
                    }
                }
            }
        }
        //playerUW.GetComponent<Container>();
        ObjectInteraction find = playerContainer.findItemOfType(item_id);

        if (find != null)
        {
            //GameObject obj = GameObject.Find(find);
            // ObjectInteraction objInt = obj.GetComponent<ObjectInteraction>();
            //if (objInt != null)
            // {
            if (find.item_id == item_id)
            {
                return(find);
            }
            //}
        }
        return(null);
    }
Пример #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)
        {
            ObjectInteraction bowl = 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++)
                    {
                        ObjectInteraction foundItemObj = bowlContainer.GetItemAt(i);
                        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);
                        Destroy(bowlContainer);    //Remove the container from the object.
                        bowl.gameObject.AddComponent <Food>();
                        bowlObjectInt.isquant = 1;
                        bowlObjectInt.link    = 1;
                        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);
    }