GetItemType() 공개 메소드

Gets the type of the item from object masters. UWE object type codes.
public GetItemType ( ) : int
리턴 int
예제 #1
0
 public override bool LookAt()
 {
     UWHUD.instance.MessageScroll.Add(StringController.instance.TextureDescription(TextureIndex));
     if ((TextureIndex == 142) && ((_RES == GAME_UW1) || (_RES == GAME_UWDEMO)))
     {        //This is a window into the abyss.
         UWHUD.instance.CutScenesSmall.anim.SetAnimation = "VolcanoWindow_" + GameWorldController.instance.LevelNo;
         UWHUD.instance.CutScenesSmall.anim.looping      = true;
     }
     if (objInt().link != 0)
     {
         GameObject triggerObj = ObjectLoader.getGameObjectAt(objInt().link);
         if (triggerObj != null)
         {
             ObjectInteraction objIntTrigger = triggerObj.GetComponent <ObjectInteraction>();
             if ((objIntTrigger.GetItemType() == ObjectInteraction.A_LOOK_TRIGGER)
                 ||
                 (objIntTrigger.GetItemType() == ObjectInteraction.A_USE_TRIGGER)
                 )
             {
                 objIntTrigger.GetComponent <trigger_base> ().Activate(this.gameObject);
                 return(true);
             }
         }
     }
     return(true);
 }
 /// <summary>
 /// Finds the first item of a particular category in the container.
 /// </summary>
 /// <returns>The name of the object that matches the itemid</returns>
 /// <param name="itemid">Itemid.</param>
 public ObjectInteraction findItemOfCategory(int Category)
 {
     for (short i = 0; i <= MaxCapacity(); i++)
     {
         ObjectInteraction obj = GetItemAt(i);
         if (obj != null)
         {
             if (obj.GetItemType() == Category)
             {
                 return(obj);
             }
             else
             {
                 if (obj.GetItemType() == ObjectInteraction.CONTAINER)
                 {
                     ObjectInteraction ans = obj.GetComponent <Container>().findItemOfCategory(Category);
                     if (ans != null)
                     {
                         return(ans);
                     }
                 }
             }
         }
     }
     return(null);
 }
예제 #3
0
 /// <summary>
 /// Finds the trap of the specified type in chain of execution of linked items
 /// </summary>
 /// <returns><c>true</c>, if trap in chain was found, <c>false</c> otherwise.</returns>
 /// <param name="link">Link.</param>
 /// <param name="TrapType">Trap type.</param>
 public virtual ObjectInteraction FindObjectInChain(int link, int ItemType)
 {
     if (link != 0)
     {
         ObjectInteraction objLink = CurrentObjectList().objInfo[link].instance;
         if (objLink != null)
         {
             if (objLink.GetItemType() == ObjectInteraction.A_DELETE_OBJECT_TRAP)
             {//Stop infinite loops
                 if (ItemType == ObjectInteraction.A_DELETE_OBJECT_TRAP)
                 {
                     return(objLink);
                 }
                 else
                 {
                     return(null);
                 }
             }
             if (objLink.GetItemType() == ItemType)
             {
                 return(objLink);
             }
             else
             {
                 return(FindObjectInChain(objLink.link, ItemType));
             }
         }
     }
     return(null);
 }
예제 #4
0
    //To support potions that are linked to spells/damage traps
    public override void MoveToWorldEvent()
    {
        if ((isquant == 0) && (link < 256) && (link > 0))
        {//Object links to a spell.
            if (linked != null)
            {
                bool match = false;
                //Try and find a spell already in the level that matches the characteristics of this spell
                ObjectLoaderInfo[] objList = CurrentObjectList().objInfo;
                for (int i = 0; i <= objList.GetUpperBound(0); i++)
                {
                    if (objList[i].GetItemType() == linked.GetItemType())//Find a matching item type
                    {
                        if (objList[i].instance != null)
                        {
                            if ((objList[i].link == linked.link) && (objList[i].owner == linked.owner) && (objList[i].quality == linked.quality))
                            {//Point to that instance if found instead.
                                Destroy(linked.gameObject);
                                linked = objList[i].instance;
                                link   = i;
                                match  = true;
                                break;
                            }
                        }
                    }
                }

                if (!match)
                {
                    //linkedspell.gameObject.transform.parent=GameWorldController.instance.DynamicObjectMarker();
                    GameWorldController.MoveToWorld(linked.gameObject);
                }
            }
        }
    }
예제 #5
0
 public override float GetUseRange()
 {
     if (isTelekinetic == true)
     {
         return(useRange * 8.0f);
     }
     else
     {
         if (playerInventory.GetObjectInHand() == "")
         {
             return(useRange);
         }
         else
         {            //Test if this is a pole. If so extend the use range by a small amount.
             ObjectInteraction objIntInHand = playerInventory.GetGameObjectInHand().GetComponent <ObjectInteraction>();
             if (objIntInHand != null)
             {
                 switch (objIntInHand.GetItemType())
                 {
                 case ObjectInteraction.POLE:
                     return(useRange * 2);
                 }
             }
             return(useRange);
         }
     }
 }
예제 #6
0
    /// <summary>
    /// Activation of this object by another. EG key on door
    /// </summary>
    /// <returns>true</returns>
    /// <c>false</c>
    /// <param name="ObjectUsed">Object used.</param>
    /// Handles anvil usage
    public override bool ActivateByObject(GameObject ObjectUsed)
    {
        ObjectInteraction objIntUsed = ObjectUsed.GetComponent <ObjectInteraction>();

        if (objIntUsed != null)
        {
            switch (objIntUsed.GetItemType())
            {
            case ObjectInteraction.ANVIL:             //ANVIL
            {
                //Do a difficulty check and prompt for approval.
                UWHUD.instance.MessageScroll.Set("[placeholder]You think it will be hard/easy to repair this item. Press Y or N followed by enter to proceed");
                InputField inputctrl = UWHUD.instance.InputControl;
                inputctrl.gameObject.SetActive(true);
                inputctrl.gameObject.GetComponent <InputHandler>().target           = this.gameObject;
                inputctrl.gameObject.GetComponent <InputHandler>().currentInputMode = InputHandler.InputAnvil;
                inputctrl.contentType = InputField.ContentType.Alphanumeric;
                inputctrl.Select();
                WindowDetect.WaitingForInput = true;
                Time.timeScale = 0.0f;
                return(true);
            }
            }
        }
        return(false);
    }
    //public int xpos;

    /*
     * Per uw-formats.txt
     * 018e  a_check variable trap
     * the "value" from the set variable trap (018d) is also used here.
     * the trap checks a range of variables, starting from "zpos" and of
     * length "heading". if "xpos" is not 0, the variable values in range
     * are added; if it is 0, the lower 3 bits of every variable value are
     * shifted into the resulting value. here's some meta-C code to show
     * how the check works:
     *
     * bool check_variable_trap(zpos,heading,value)
     * {
     *  Int16 cmp = 0;
     *  for(Int16 i=zpos; i<zpos+heading; i++)
     *  {
     *     if (xpos != 0)
     *        cmp += game_vars[i];
     *     else
     *     {
     *        cmp <<= 3;
     *        cmp |= game_vars[i] & 7;
     *     }
     *  }
     *
     *  return di != value
     * }
     *
     * The trigger associated with the trap is set off when the resulting
     * value is not equal the "value".
     *
     * Examples of usage
     * the left, right, center button combination on Level3.
     *
     */

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        //Debug.Log (this.name);
        if (check_variable_trap())
        {
            TriggerNext(triggerX, triggerY, State);
            PostActivate(src);
        }
        else
        {
            if (_RES == GAME_UW2)
            {            //If linked to a null trap in UW2 the next of the null trap will act as a "false" action.
                ObjectInteraction nullObj = ObjectLoader.getObjectIntAt(objInt().link);
                //if (triggerObj.tileX==TileMap.ObjectStorageTile)
                if (nullObj.GetItemType() == ObjectInteraction.A_NULL_TRAP)
                {
                    ObjectInteraction triggerObj = ObjectLoader.getObjectIntAt(nullObj.next);
                    if (triggerObj != null)
                    {
                        if (triggerObj.GetComponent <trap_base>() != null)
                        {
                            triggerObj.GetComponent <trap_base>().Activate(this, triggerX, triggerY, State);
                            PostActivate(src);
                        }
                    }
                }
            }
        }
    }
예제 #8
0
    public override bool ActivateByObject(GameObject ObjectUsed)
    {
        ObjectInteraction objIntUsed = ObjectUsed.GetComponent <ObjectInteraction>();

        if (objIntUsed != null)
        {
            switch (objIntUsed.GetItemType())
            {
            case ObjectInteraction.AN_ORB_ROCK:
            {
                if ((_RES == GAME_UW1) && (GameWorldController.instance.LevelNo == 6))
                {
                    UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault;
                    UWCharacter.Instance.playerInventory.ObjectInHand = "";
                    OrbRock.DestroyOrb(objInt());
                    return(true);
                }
                else
                {
                    return(base.ActivateByObject(ObjectUsed));
                }
            }
            }
        }
        return(base.ActivateByObject(ObjectUsed));
    }
    public override bool ActivateByObject(GameObject ObjectUsed)
    {
        ObjectInteraction objI = ObjectUsed.GetComponent <ObjectInteraction>();

        if (objI != null)
        {
            if (objI.GetItemType() == ObjectInteraction.A_BLACKROCK_GEM)
            {
                if (objI.owner == 1)
                {
                    int thisGemIndex = objI.item_id - 280;
                    int bitField     = (1 << thisGemIndex);
                    Quest.instance.x_clocks[2]++;
                    Quest.instance.QuestVariables[130] |= bitField;
                    UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 338));
                    UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 338 + Quest.instance.x_clocks[2]));
                    objI.consumeObject();
                }
                else
                {
                    UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 347));
                }
                UWCharacter.Instance.playerInventory.ObjectInHand = "";
                return(true);
            }
        }
        return(false);
    }
 public override bool ActivateByObject(ObjectInteraction ObjectUsed)
 {
     //ObjectInteraction objI=ObjectUsed.GetComponent<ObjectInteraction>();
     if (ObjectUsed != null)
     {
         if (ObjectUsed.GetItemType() == ObjectInteraction.A_BLACKROCK_GEM)
         {
             if (ObjectUsed.owner == 1)
             {
                 int thisGemIndex = ObjectUsed.item_id - 280;
                 int bitField     = (1 << thisGemIndex);
                 Quest.instance.x_clocks[2]++;
                 Quest.instance.QuestVariables[130] |= bitField;
                 UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 338));
                 UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 338 + Quest.instance.x_clocks[2]));
                 CameraShake.instance.ShakeEarthQuake(Quest.instance.x_clocks[2] * 0.2f);
                 ObjectUsed.consumeObject();
             }
             else
             {
                 UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 347));
             }
             CurrentObjectInHand = null;
             return(true);
         }
     }
     return(false);
 }
예제 #11
0
 public override bool use()
 {
     if (CurrentObjectInHand == null)
     {
         if (link != 0)
         {
             GameObject triggerObj = ObjectLoader.getGameObjectAt(link);
             if (triggerObj != null)
             {
                 ObjectInteraction objIntTrigger = triggerObj.GetComponent <ObjectInteraction>();
                 if (
                     (objIntTrigger.GetItemType() == ObjectInteraction.A_USE_TRIGGER)
                     )
                 {
                     objIntTrigger.GetComponent <trigger_base>().Activate(this.gameObject);
                     return(true);
                 }
             }
         }
         return(true);
     }
     else
     {
         return(ActivateByObject(CurrentObjectInHand));
     }
 }
예제 #12
0
 public override bool use()
 {
     if (UWCharacter.Instance.playerInventory.ObjectInHand == "")
     {
         if (objInt().link != 0)
         {
             GameObject triggerObj = ObjectLoader.getGameObjectAt(objInt().link);
             if (triggerObj != null)
             {
                 ObjectInteraction objIntTrigger = triggerObj.GetComponent <ObjectInteraction>();
                 if (
                     (objIntTrigger.GetItemType() == ObjectInteraction.A_USE_TRIGGER)
                     )
                 {
                     objIntTrigger.GetComponent <trigger_base> ().Activate(this.gameObject);
                     return(true);
                 }
             }
         }
         return(true);
     }
     else
     {
         return(ActivateByObject(UWCharacter.Instance.playerInventory.GetGameObjectInHand()));
     }
 }
예제 #13
0
 public override bool ActivateByObject(GameObject ObjectUsed)
 {
     if ((UWEBase._RES == UWEBase.GAME_UW1) && (TextureIndex == 47))       //The door to the base of the abyss.
     {
         if (ObjectUsed.GetComponent <ObjectInteraction>().item_id == 231) //The key of infinity.
         {
             if (objInt().link != 0)
             {
                 GameObject triggerObj = ObjectLoader.getGameObjectAt(objInt().link);
                 if (triggerObj != null)
                 {
                     ObjectInteraction objIntTrigger = triggerObj.GetComponent <ObjectInteraction>();
                     if (
                         (objIntTrigger.GetItemType() == ObjectInteraction.AN_OPEN_TRIGGER)
                         )
                     {
                         objIntTrigger.GetComponent <trigger_base> ().Activate(this.gameObject);
                         UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault;
                         UWCharacter.Instance.playerInventory.ObjectInHand = "";
                         return(true);
                     }
                 }
             }
         }
     }
     return(base.ActivateByObject(ObjectUsed));
 }
    public override bool LookAt()
    {
        //public void LookAt()
        //Generally gives the object description but depending on the trigger target type it may activate (lookat trigger)
        //GameObject triggerObj= ObjectLoader.getObjectIntAt(link).gameObject;
        GameObject triggerObj = ObjectLoader.getGameObjectAt(link);

        if (triggerObj != null)
        {
            ObjectInteraction TargetObjInt = triggerObj.GetComponent <ObjectInteraction>();
            UWHUD.instance.MessageScroll.Add(StringController.instance.GetFormattedObjectNameUW(objInt()));
            if (TargetObjInt.GetItemType() == ObjectInteraction.A_LOOK_TRIGGER)//A look trigger.
            {
                base.LookAt();
                this.Activate(this.gameObject);
            }
            else
            {
                base.LookAt();
            }
        }
        else
        {
            base.LookAt();
        }
        return(true);
    }
예제 #15
0
    /// <summary>
    /// Activation of this object by another. EG key on door
    /// </summary>
    /// <returns>true</returns>
    /// <c>false</c>
    /// <param name="ObjectUsed">Object used.</param>
    /// Handles anvil usage
    public override bool ActivateByObject(ObjectInteraction ObjectUsed)
    {
        //ObjectInteraction objIntUsed = ObjectUsed.GetComponent<ObjectInteraction>();
        if (ObjectUsed != null)
        {
            switch (ObjectUsed.GetItemType())
            {
            case ObjectInteraction.ANVIL:     //ANVIL
            {
                //Do a difficulty check and prompt for approval.
                int RepairDifficulty   = repairEstimate();
                int estimateStringNo   = 0;
                int repairStringOffset = StringController.str_you_think_it_will_be_;
                if (_RES == GAME_UW2)
                {
                    repairStringOffset = 231;
                }
                if (RepairDifficulty == -1)
                {
                    UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_cannot_repair_that_));
                    return(true);
                }
                else
                {
                    int estimate = RepairDifficulty - UWCharacter.Instance.PlayerSkills.Repair + 0xF;
                    if (estimate >= 0x1E)
                    {
                        estimate = 4;
                    }
                    else
                    {
                        estimate = (estimate / 0xA) + 1;
                    }
                    estimateStringNo += repairStringOffset + estimate + 3;
                }


                string question = StringController.instance.GetString(1, repairStringOffset)
                                  + StringController.instance.GetString(1, estimateStringNo)
                                  + StringController.instance.GetString(1, repairStringOffset + 1)
                                  + StringController.instance.GetObjectNounUW(item_id)
                                  + StringController.instance.GetString(1, StringController.str__make_an_attempt_);

                UWHUD.instance.MessageScroll.Set(question);
                InputField inputctrl = UWHUD.instance.InputControl;
                inputctrl.gameObject.SetActive(true);
                inputctrl.gameObject.GetComponent <InputHandler>().target           = this.gameObject;
                inputctrl.gameObject.GetComponent <InputHandler>().currentInputMode = InputHandler.InputAnvil;
                inputctrl.contentType = InputField.ContentType.Alphanumeric;
                inputctrl.text        = "No";
                inputctrl.Select();
                WindowDetect.WaitingForInput = true;
                Time.timeScale = 0.0f;
                return(true);
            }
            }
        }
        return(false);
    }
예제 #16
0
    public override bool use()
    {
        trigger_base trigger = null;

        //If a door has a link and the link is to something that is not a lock then it is a trigger that I need to activae
        if (link != 0)
        {
            ObjectInteraction linkedObject = ObjectLoader.getObjectIntAt(link);
            if (linkedObject != null)
            {
                if (linkedObject.GetItemType() != ObjectInteraction.LOCK)
                {
                    trigger = linkedObject.GetComponent <trigger_base>();
                }
            }
        }

        if (CurrentObjectInHand != null)
        {
            ActivateByObject(CurrentObjectInHand);
            //Clear the object in hand
            //UWHUD.instance.CursorIcon= UWHUD.instance.CursorIconDefault;
            CurrentObjectInHand = null;
            if (trigger != null)
            {
                trigger.Activate(this.gameObject);
            }
            return(true);
        }
        else
        {        //Normal Usage
            PlayerUse = true;
            if ((UWCharacter.AutoKeyUse) && (locked()))
            {//Try each key in the players inventory to see if it can open the door
                foreach (Transform t in GameWorldController.instance.InventoryMarker.transform)
                {
                    if (t.gameObject.GetComponent <DoorKey>() != null)
                    {
                        DoorKey key = t.gameObject.GetComponent <DoorKey>();
                        if (key.KeyId == KeyIndex)
                        {
                            ActivateByObject(key.objInt());
                            if (trigger != null)
                            {
                                trigger.Activate(this.gameObject);
                            }
                            PlayerUse = false;
                            return(true);
                        }
                    }
                }
            }

            Activate(this.gameObject);
            PlayerUse = false;
            return(true);
        }
    }
예제 #17
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);
    }
예제 #18
0
 /// <summary>
 /// Finds the trap of the specified type in chain of execution
 /// </summary>
 /// <returns><c>true</c>, if trap in chain was found, <c>false</c> otherwise.</returns>
 /// <param name="link">Link.</param>
 /// <param name="TrapType">Trap type.</param>
 public virtual bool FindTrapInChain(int link, int TrapType)
 {
     if (link != 0)
     {
         ObjectInteraction objLink = CurrentObjectList().objInfo[link].instance;
         if (objLink != null)
         {
             if (objLink.GetItemType() == ObjectInteraction.A_DELETE_OBJECT_TRAP)
             {
                 return(TrapType == ObjectInteraction.A_DELETE_OBJECT_TRAP);
             }
             if (objLink.GetItemType() == TrapType)
             {
                 return(true);
             }
             else
             {
                 return(FindTrapInChain(objLink.link, TrapType));
             }
         }
     }
     return(false);
 }
예제 #19
0
    public override string UseObjectOnVerb_Inv()
    {
        ObjectInteraction ObjIntInHand = UWCharacter.Instance.playerInventory.GetObjIntInHand();

        if (ObjIntInHand != null)
        {
            switch (ObjIntInHand.GetItemType())
            {
            case ObjectInteraction.RUNE:
                return("place rune in bag");
            }
        }
        return(base.UseObjectOnVerb_Inv());
    }
    public override string UseObjectOnVerb_World()
    {
        ObjectInteraction ObjIntInHand = UWCharacter.Instance.playerInventory.GetObjIntInHand();

        if (ObjIntInHand != null)
        {
            switch (ObjIntInHand.GetItemType())
            {
            case ObjectInteraction.POLE:
                return("trigger with pole");
            }
        }

        return(base.UseObjectOnVerb_Inv());
    }
    public override string UseObjectOnVerb_Inv()
    {
        ObjectInteraction ObjIntInHand = CurrentObjectInHand;

        if (ObjIntInHand != null)
        {
            switch (ObjIntInHand.GetItemType())
            {
            case ObjectInteraction.OIL:
                return("refill lantern");
            }
        }

        return(base.UseObjectOnVerb_Inv());
    }
예제 #22
0
 public override bool LookAt()
 {
     if (link != 0)
     {
         ObjectInteraction objIntLink = ObjectLoader.getObjectIntAt(link);
         if (objIntLink != null)
         {
             switch (objIntLink.GetItemType())
             {
             case ObjectInteraction.A_LOOK_TRIGGER:
                 return(objIntLink.GetComponent <trigger_base>().Activate(this.gameObject));
             }
         }
     }
     return(base.LookAt());
 }
예제 #23
0
    //Change bottle type of the potion and link it to a damage trap.

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        foreach (Transform child in GameWorldController.instance.InventoryMarker.transform)
        {
            if (child.gameObject.GetComponent <ObjectInteraction>() != null)
            {
                ObjectInteraction obj = child.gameObject.GetComponent <ObjectInteraction>();
                if (obj.GetItemType() == ObjectInteraction.POTIONS)
                {
                    if ((obj.link == 529) && (obj.enchantment == 1) && (obj.GetComponent <Potion>().linked == null))
                    {
                        SpoilPotion(obj);
                    }
                }
            }
        }
    }
예제 #24
0
 void OnCollisionEnter(Collision collision)
 {    //
     if (objInt().PickedUp == false)
     {
         if ((GameWorldController.instance.LevelNo == 6) && (_RES == GAME_UW1))
         {
             if (collision.gameObject.name.Contains("orb"))
             {
                 ObjectInteraction HitobjInt = collision.gameObject.GetComponent <ObjectInteraction>();
                 if (HitobjInt.GetItemType() == ObjectInteraction.ORB)
                 {
                     DestroyOrb(HitobjInt);
                 }
             }
         }
     }
 }
예제 #25
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);
    }
예제 #26
0
 public override bool ActivateByObject(ObjectInteraction ObjectUsed)
 {
     //000~001~182~You think it is a bad idea to add oil to the lit torch. \n
     //ObjectInteraction objIntUsed = ObjectUsed.GetComponent<ObjectInteraction>();
     if (ObjectUsed != null)
     {
         switch (ObjectUsed.GetItemType())
         {
         case ObjectInteraction.OIL:
             if (item_id == 149)              //Lit torch
             {
                 UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_think_it_is_a_bad_idea_to_add_oil_to_the_lit_torch_));
                 return(true);
             }
             break;
         }
     }
     return(base.ActivateByObject(ObjectUsed));
 }
예제 #27
0
    public override bool use()
    {
        trigger_base trigger = null;

        //If a door has a link and the link is to something that is not a lock then it is a trigger that I need to activae
        if (objInt().link != 0)
        {
            ObjectInteraction linkedObject = ObjectLoader.getObjectIntAt(objInt().link);
            if (linkedObject != null)
            {
                if (linkedObject.GetItemType() != ObjectInteraction.LOCK)
                {
                    trigger = linkedObject.GetComponent <trigger_base>();
                }
            }
        }


        if (UWCharacter.Instance.playerInventory.ObjectInHand != "")
        {
            ActivateByObject(UWCharacter.Instance.playerInventory.GetGameObjectInHand());
            //Clear the object in hand
            UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault;
            UWCharacter.Instance.playerInventory.ObjectInHand = "";
            if (trigger != null)
            {
                trigger.Activate(this.gameObject);
            }
            return(true);
        }
        else
        {        //Normal Usage
            PlayerUse = true;
            Activate(this.gameObject);
            PlayerUse = false;
            //if (trigger!=null)
            //{
            //	trigger.Activate();
            //}
            return(true);
        }
    }
 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++)
     {
         ObjectInteraction item = cn.GetItemAt(i);
         if (item != null)
         {
             //FIELD PICKUP item.GetComponent<ObjectInteraction>().PickedUp=NewValue;
             if (item.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);
             }
         }
     }
 }
예제 #29
0
    public virtual bool Read()
    {
        switch (_RES)
        {
        case GAME_UW2:
        {
            //TODO: Need to figure out how the "sign/writing/plaque" etc prefix works
            if (objInt().isquant == 1)
            {                    //This is a normal sign
                UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(8, objInt().link - 0x200));
                return(true);
            }
            else
            {                    //This is linked to a trigger that spouts some nonsense.
                ObjectInteraction linkObj = ObjectLoader.getObjectIntAt(objInt().link);
                if (linkObj != null)
                {
                    switch (linkObj.GetItemType())
                    {
                    case ObjectInteraction.A_USE_TRIGGER:
                        return(linkObj.GetComponent <trigger_base>().Activate(this.gameObject));

                    case ObjectInteraction.A_LOOK_TRIGGER:
                        return(linkObj.GetComponent <trigger_base>().Activate(this.gameObject));

                    default:
                        UWHUD.instance.MessageScroll.Add("You need to investigate me " + this.name);
                        return(true);
                    }
                }
            }
            return(false);
        }

        default:
        {
            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(8, objInt().link - 0x200));
            return(true);
        }
        }
    }
예제 #30
0
    public override string UseObjectOnVerb_World()
    {
        ObjectInteraction ObjIntInHand = UWCharacter.Instance.playerInventory.GetObjIntInHand();

        if (ObjIntInHand != null)
        {
            switch (ObjIntInHand.GetItemType())
            {
            case ObjectInteraction.KEY:
                return("turn key in lock");

            case ObjectInteraction.SPIKE:
                return("spike door");

            case ObjectInteraction.LOCKPICK:
                return("attempt lockpicking");
            }
        }

        return(base.UseObjectOnVerb_Inv());
    }