public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        string created = "";
        //if (objInt().quality <= Random.Range(1,41)) //100% chance when quality is zero.
        //{
        ObjectInteraction objToClone = ObjectLoader.getObjectIntAt(objInt().link);

        if (objToClone != null)
        {
            GameObject NewObject = CloneObject(objToClone, triggerX, triggerY, true);
            LastObjectCreated = NewObject.name;
            created           = NewObject.name;
            if (objToClone.GetComponent <Container>() != null)
            {                    //Clone the items on this object
                for (short i = 0; i <= objToClone.GetComponent <Container>().MaxCapacity(); i++)
                {
                    if (objToClone.GetComponent <Container>().GetItemAt(i) != "")
                    {
                        GameObject obj = objToClone.GetComponent <Container>().GetGameObjectAt(i);
                        GameObject CloneContainerItem = CloneObject(obj.GetComponent <ObjectInteraction>(), triggerX, triggerY, false);
                        NewObject.GetComponent <Container>().items[i] = CloneContainerItem.name;
                    }
                }
            }
        }
        //}
        Debug.Log(this.name + " " + created);
    }
Esempio n. 2
0
    void ConversationClick(bool isLeftClick)
    {
        if (isLeftClick == false)
        {//Looking at object
            ObjectInteraction currObj = UWCharacter.Instance.playerInventory.GetObjectIntAtSlot(slotIndex);

            if (currObj != null)
            {
                if (currObj.GetComponent <Container>() != null)
                {
                    currObj.GetComponent <Container>().OpenContainer();
                    return;
                }
            }

            //TemporaryLookAt();
            return;
        }
        else
        {
            RightClickPickup();
        }

        return;
    }
Esempio n. 3
0
 public static GameObject SpawnHitImpact(int Item_ID, Vector3 ImpactPosition, int StartFrame, int EndFrame)
 {
     try
     {
         ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(Item_ID, 40, StartFrame, 1, 256);
         if (newobjt != null)
         {
             ObjectInteraction objInt = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, ImpactPosition);
             //objInt.GetComponent<AnimationOverlay>().Looping = false;
             objInt.GetComponent <AnimationOverlay>().StartFrame       = StartFrame;
             objInt.GetComponent <AnimationOverlay>().NoOfFrames       = EndFrame - StartFrame;
             objInt.GetComponent <AnimationOverlay>().StartingDuration = objInt.GetComponent <AnimationOverlay>().NoOfFrames;
             objInt.gameObject.layer = LayerMask.NameToLayer("Animation");
             return(objInt.gameObject);
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         return(null);
     }
 }
    //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);
                        }
                    }
                }
            }
        }
    }
Esempio n. 5
0
    public virtual ObjectInteraction Pickup(ObjectInteraction objPicked, PlayerInventory pInv)
    {    //completes the pickup.
        //FIELD PICKUP objPicked.PickedUp=true;
        if (objPicked.GetComponent <Container>() != null)
        {
            Container.SetPickedUpFlag(objPicked.GetComponent <Container>(), true);
            Container.SetItemsParent(objPicked.GetComponent <Container>(), GameWorldController.instance.InventoryMarker.transform);
            Container.SetItemsPosition(objPicked.GetComponent <Container>(), GameWorldController.instance.InventoryMarker.transform.position);
        }
        //UWHUD.instance.CursorIcon=objPicked.GetInventoryDisplay().texture;
        pInv.ObjectInHand = objPicked;
        if (objPicked.GetComponent <Rigidbody>() != null)
        {
            FreezeMovement(objPicked.gameObject);
        }

        objPicked.transform.position = GameWorldController.instance.InventoryMarker.transform.position;
        objPicked.transform.parent   = GameWorldController.instance.InventoryMarker.transform;
        GameWorldController.MoveToInventory(objPicked);
        pInv.ObjectInHand = objPicked;
        objPicked.Pickup();
        if (WindowDetectUW.ContextUIEnabled)
        {
            if (MouseLookEnabled)
            {
                WindowDetectUW.SwitchFromMouseLook();
            }
        }
        return(objPicked);
    }
 public static void SetItemsParent(Container cn, Transform Parent)
 {
     for (short i = 0; i <= cn.MaxCapacity(); i++)
     {
         ObjectInteraction item = 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.DynamicObjectMarker())
             {
                 GameWorldController.MoveToWorld(item);
             }
             else
             {
                 GameWorldController.MoveToInventory(item);
             }
             if (item.GetComponent <Container>() != null)
             {
                 Container.SetItemsParent(item.GetComponent <Container>(), Parent);
             }
         }
         // }
     }
 }
Esempio n. 7
0
    public static GameObject SpawnHitImpact(int Item_ID, Vector3 ImpactPosition, int StartFrame, int EndFrame)
    {
        ObjectLoaderInfo  newobjt = ObjectLoader.newObject(Item_ID, 40, StartFrame, 1, 256);
        ObjectInteraction objInt  = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, ImpactPosition);

        objInt.GetComponent <AnimationOverlay>().Looping    = false;
        objInt.GetComponent <AnimationOverlay>().StartFrame = StartFrame;
        objInt.GetComponent <AnimationOverlay>().NoOfFrames = EndFrame - StartFrame;
        return(objInt.gameObject);
    }
    /// <summary>
    /// Handle player choosing how many items to pick up in a stack
    /// </summary>
    /// <param name="quant"></param>
    public void OnSubmitPickup(int quant)
    {
        InputField inputctrl = UWHUD.instance.InputControl;

        inputctrl.text = "";
        inputctrl.gameObject.SetActive(false);
        WindowDetect.WaitingForInput = false;
        ConversationVM.EnteringQty   = false;
        if (ConversationVM.InConversation == false)
        {
            UWHUD.instance.MessageScroll.Clear();
            Time.timeScale = 1.0f;
        }
        else
        {
            UWHUD.instance.ConversationButtonParent.SetActive(true);
            UWHUD.instance.MessageScroll.Set("");
            // UWHUD.instance.MessageScroll.NewUIOUt.text = InventorySlot.TempLookAt;//Restore original text
        }

        if (quant == 0)
        {//cancel
            QuantityObj = null;
        }
        if (QuantityObj != null)
        {//Just do a normal pickup.
            if (quant >= QuantityObj.GetComponent <ObjectInteraction>().link)
            {
                CurrentObjectInHand = QuantityObj;
                if (this.slotIndex >= 11)
                {
                    UWCharacter.Instance.playerInventory.currentContainer.RemoveItemFromContainer(UWCharacter.Instance.playerInventory.ContainerOffset + this.slotIndex - 11);
                }
                UWCharacter.Instance.playerInventory.ClearSlot(this.slotIndex);
            }
            else
            {
                //split the obj.
                ObjectInteraction objI = QuantityObj.GetComponent <ObjectInteraction>();
                objI.link = objI.link - quant;
                ObjectLoaderInfo newObj = ObjectLoader.newWorldObject(objI.item_id, objI.quality, objI.owner, quant, -1);
                newObj.is_quant = 1;
                ObjectInteraction NewObjI = ObjectInteraction.CreateNewObject(CurrentTileMap(), newObj, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker, GameWorldController.instance.InventoryMarker.transform.position);
                GameWorldController.MoveToInventory(NewObjI);
                CurrentObjectInHand = NewObjI;
                ObjectInteraction.Split(objI, NewObjI);
                UWCharacter.Instance.playerInventory.Refresh();
                QuantityObj = null;
            }
        }
    }
Esempio n. 9
0
    short getDefenceAtSlot(int slot)
    {
        ObjectInteraction obj = GetObjectIntAtSlot(slot);

        if (obj != null)
        {
            switch (slot)
            {
            case 0:    //Helm
            case 1:    //Chest
            case 2:    //Leggings
            case 3:    //Boots
            case 4:    //Gloves
                if (obj.GetComponent <Armour>() != null)
                {
                    return(obj.GetComponent <Armour>().Protection());
                }
                break;

            case 5:    //rings
            {
                if (obj.GetComponent <Ring>() != null)
                {
                    return(obj.GetComponent <Ring>().Protection());
                }
                break;
            }

            case 7:    //HandRight
                if (UWCharacter.Instance.isLefty)
                {
                    return(0);
                }
                else
                {
                    if (obj.GetComponent <Shield>() != null)
                    {
                        return(obj.GetComponent <Shield>().Protection());
                    }
                }
                break;

            case 8:    //HandLeft
                if (!UWCharacter.Instance.isLefty)
                {
                    return(0);
                }
                else
                {
                    if (obj.GetComponent <Shield>() != null)
                    {
                        return(obj.GetComponent <Shield>().Protection());
                    }
                }
                break;
            }
        }

        return(0);
    }
    public void SpillContentsX()
    {                                  //Removes the contents of a container out in the real world.
        int     counter;
        TileMap tm = CurrentTileMap(); //GameObject.Find("Tilemap").GetComponent<TileMap>();

        FreezeMovement(this.gameObject);
        ObjectInteraction objInt = this.gameObject.GetComponent <ObjectInteraction>();

        objInt.SetWorldDisplay(objInt.GetEquipDisplay());
        for (short i = 0; i <= MaxCapacity(); i++)
        {
            ObjectInteraction Spilled = GetItemAt(i);//GameObject.Find (GetItemAt (i));
            if (Spilled != null)
            {
                if (Spilled.GetComponent <trigger_base>() != null)
                {
                    Spilled.GetComponent <trigger_base>().Activate(this.gameObject);
                }
                bool    flag        = false;
                Vector3 randomPoint = this.transform.position;
                counter = 0;
                while ((flag == false) && (counter < 25))
                {
                    randomPoint = this.transform.position + Random.insideUnitSphere;
                    if (randomPoint.y < this.transform.position.y)
                    {
                        randomPoint.y = this.transform.position.y + 0.1f;
                    }
                    flag = ((!Physics.CheckSphere(randomPoint, 0.5f)) && (tm.ValidTile(randomPoint)));
                    counter++;
                }
                if (flag == true)
                {//No object interferes with the spill
                    RemoveItemFromContainer(i);
                    Spilled.transform.position = randomPoint;
                    //FIELD PICKUP Spilled.GetComponent<ObjectInteraction>().PickedUp=false;
                    UnFreezeMovement(Spilled);
                }
                else
                {//No where to put the item. Put it at the containers position.
                    RemoveItemFromContainer(i);
                    Spilled.transform.position = this.transform.position;
                    //FIELD PICKUP Spilled.GetComponent<ObjectInteraction>().PickedUp=false;
                    UnFreezeMovement(Spilled);
                }
            }
        }
        UnFreezeMovement(this.gameObject);
    }
Esempio n. 11
0
    void SpoilPotion(ObjectInteraction obj)
    {
        obj.ChangeType(228);
        obj.isquant = 0;

        ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(384, 40, 1, 0, 256);

        newobjt.InUseFlag = 1;
        ObjectInteraction created = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.DynamicObjectMarker().gameObject, GameWorldController.instance.InventoryMarker.transform.position);

        GameWorldController.MoveToInventory(created);
        created.transform.parent           = GameWorldController.instance.InventoryMarker.transform;
        obj.GetComponent <Potion>().linked = created;
        obj.GetComponent <Potion>().SetDisplayEnchantment();
    }
    //Triggers conversation with feral troll jail in tybals lair (if they are alive)


    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        ObjectInteraction npc = ObjectLoader.getObjectIntAt(251);

        if (npc != null)
        {
            if (npc.GetComponent <NPC>() != null)
            {
                if (npc.GetComponent <NPC>().npc_whoami == 216)
                {
                    npc.TalkTo();
                }
            }
        }
    }
 /// <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);
 }
Esempio n. 14
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()));
     }
 }
Esempio n. 15
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));
     }
 }
Esempio n. 16
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>
    /// Handle looking at objects in inventory
    /// </summary>
    void LookFromSlot()
    {
        ObjectInteraction objLookedAt = UWCharacter.Instance.playerInventory.GetObjectIntAtSlot(slotIndex);

        if (objLookedAt != null)
        {
            if (objLookedAt.GetComponent <Readable>() != null)
            {
                objLookedAt.GetComponent <Readable>().Read();
            }
            else
            {
                objLookedAt.LookDescription();
            }
        }
    }
    /// <summary>
    /// Handles hovering over the slot
    /// </summary>
    public void OnHoverEnter()
    {
        Hovering = true;
        UWHUD.instance.ContextMenu.text = "";
        ObjectInteraction objInt = UWCharacter.Instance.playerInventory.GetObjectIntAtSlot(slotIndex);

        if (objInt != null)
        {
            string ObjectName = "";
            string UseString  = "";
            ObjectName = objInt.GetComponent <object_base>().ContextMenuDesc(objInt.item_id);
            if (CurrentObjectInHand == null)
            {
                switch (UWCharacter.InteractionMode)
                {
                case UWCharacter.InteractionModeUse:
                    UseString = "L-Click to " + objInt.UseVerb() + " R-Click to " + objInt.PickupVerb();
                    break;

                case UWCharacter.InteractionModeLook:
                    UseString = "L-Click to " + objInt.UseVerb() + " R-Click to " + objInt.ExamineVerb();
                    break;

                case UWCharacter.InteractionModePickup:
                    UseString = "L-Click to " + objInt.UseVerb() + " R-Click to " + objInt.PickupVerb();
                    break;
                }
            }
            else
            {
                UseString = "L-Click to " + objInt.UseObjectOnVerb_Inv();
            }
            UWHUD.instance.ContextMenu.text = ObjectName + "\n" + UseString;
        }
    }
Esempio n. 19
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));
 }
Esempio n. 20
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);
    }
Esempio n. 21
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);
        }
    }
 public static void SetItemsPosition(Container cn, Vector3 Position)
 {
     for (short i = 0; i <= cn.MaxCapacity(); i++)
     {
         ObjectInteraction item = 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);
             }
         }
         //}
     }
 }
 public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
 {
     //Test the crystals and delganiser
     if (
         (TestObjectAtTile(59, 4, 161, 2) != -1)
         &&
         (TestObjectAtTile(57, 4, 161, 6) != -1)
         &&
         (TestObjectAtTile(58, 4, 174, -1) != -1)
         )
     {
         //Once all conditions are met execute the following trap to spawn the  bliy
         ObjectInteraction obj = ObjectLoader.getObjectIntAt(642);
         if (obj != null)
         {
             if (obj.GetComponent <trigger_base>() != null)
             {
                 skupSpawned = true;
                 Quest.instance.QuestVariables[38]  = 1;
                 Quest.instance.QuestVariables[122] = 0;
                 obj.GetComponent <trigger_base>().Activate(this.gameObject);
                 int ObjToDestroy = TestObjectAtTile(59, 4, 161, 2);
                 if (ObjToDestroy != -1)
                 {
                     ObjectInteraction objToDestroy = ObjectLoader.getObjectIntAt(ObjToDestroy);
                     if (objToDestroy != null)
                     {
                         objToDestroy.consumeObject();
                     }
                 }
                 ObjToDestroy = TestObjectAtTile(57, 4, 161, 6);
                 if (ObjToDestroy != -1)
                 {
                     ObjectInteraction objToDestroy = ObjectLoader.getObjectIntAt(ObjToDestroy);
                     if (objToDestroy != null)
                     {
                         objToDestroy.consumeObject();
                     }
                 }
             }
         }
     }
 }
Esempio n. 24
0
    //Used when the avatar flees the arena

    public override void ExecuteTrap(object_base src, int triggerX, int triggerY, int State)
    {
        int OpponentsFound = 0;
        int OpponentIndex  = 0;

        for (int i = 0; i <= Quest.instance.ArenaOpponents.GetUpperBound(0); i++)
        {
            if (Quest.instance.ArenaOpponents[i] != 0)
            {
                OpponentsFound++;
                OpponentIndex = Quest.instance.ArenaOpponents[i];
                ObjectInteraction objI = ObjectLoader.getObjectIntAt(OpponentIndex);
                if (objI != null)
                {
                    if (objI.GetComponent <NPC>() != null)
                    {                    //Make NPC calmer.
                        objI.GetComponent <NPC>().npc_attitude = 1;
                        objI.GetComponent <NPC>().npc_goal     = (short)NPC.npc_goals.npc_goal_wander_1;
                    }
                }
            }
            Quest.instance.ArenaOpponents[i] = 0;
        }
        //Reduce player reputation.
        if (OpponentsFound > 0)
        {
            //Update win loss record to record a loss
            Quest.instance.QuestVariables[129] = Mathf.Max(Quest.instance.QuestVariables[129] - OpponentsFound, 0);
            Quest.instance.QuestVariables[133] = 0;
            if (OpponentIndex > 0)
            {            //Begin taunting conversation.
                ObjectInteraction objI = ObjectLoader.getObjectIntAt(OpponentIndex);
                if (objI != null)
                {
                    objI.TalkTo();
                }
            }
            else
            {
                Quest.instance.FightingInArena = 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++)
     {
         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);
             }
         }
     }
 }
Esempio n. 26
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);
        }
        }
    }
Esempio n. 27
0
    public virtual void Pickup(ObjectInteraction objPicked, PlayerInventory pInv)
    {    //completes the pickup.
        objPicked.PickedUp = true;
        if (objPicked.GetComponent <Container>() != null)
        {
            Container.SetPickedUpFlag(objPicked.GetComponent <Container>(), true);
            Container.SetItemsParent(objPicked.GetComponent <Container>(), InvMarker.transform);
            Container.SetItemsPosition(objPicked.GetComponent <Container>(), InvMarker.transform.position);
        }
        CursorIcon        = objPicked.GetInventoryDisplay().texture;
        pInv.ObjectInHand = objPicked.transform.name;
        //////pInv.JustPickedup=true;//To stop me throwing it away immediately.
        if (objPicked.GetComponent <Rigidbody>() != null)
        {
            WindowDetect.FreezeMovement(objPicked.gameObject);
        }
        objPicked.transform.position = InvMarker.transform.position;
        objPicked.transform.parent   = InvMarker.transform;

        objPicked.Pickup();        //Call pickup event for this object.
    }
Esempio n. 28
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.
            ObjectInteraction objInt = GetObjectIntAtSlot(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)
                    {
                        ObjectInteraction find2 = objInt.GetComponent <Container>().findItemOfType(item_id);
                        if (find2 != null)
                        {
                            //GameObject obj2 = GameObject.Find(find2);
                            //ObjectInteraction objInt2 = obj2.GetComponent<ObjectInteraction>();
                            //if (objInt2 != 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);
    }
    void SetNPCLocation(int index, int xhome, int yhome)
    {
        ObjectInteraction obj = ObjectLoader.getObjectIntAt(index);

        if (obj != null)
        {
            NPC npc = obj.GetComponent <NPC>();
            if (npc != null)
            {
                npc.npc_xhome = (short)xhome;
                npc.npc_yhome = (short)yhome;
            }
        }
    }
Esempio n. 30
0
    public virtual ObjectInteraction Pickup(ObjectInteraction objPicked, PlayerInventory pInv)
    {    //completes the pickup.
        objPicked.PickedUp = true;
        if (objPicked.GetComponent <Container>() != null)
        {
            Container.SetPickedUpFlag(objPicked.GetComponent <Container>(), true);
            Container.SetItemsParent(objPicked.GetComponent <Container>(), GameWorldController.instance.InventoryMarker.transform);
            Container.SetItemsPosition(objPicked.GetComponent <Container>(), GameWorldController.instance.InventoryMarker.transform.position);
        }
        UWHUD.instance.CursorIcon = objPicked.GetInventoryDisplay().texture;
        pInv.ObjectInHand         = objPicked.transform.name;
        if (objPicked.GetComponent <Rigidbody>() != null)
        {
            GameWorldController.FreezeMovement(objPicked.gameObject);
        }

        objPicked.transform.position = GameWorldController.instance.InventoryMarker.transform.position;
        objPicked.transform.parent   = GameWorldController.instance.InventoryMarker.transform;
        GameWorldController.MoveToInventory(objPicked);
        pInv.ObjectInHand = objPicked.transform.name;
        objPicked.Pickup();
        return(objPicked);
    }
Esempio n. 31
0
    static int RollForAHitMelee(UWCharacter Origin, ObjectInteraction Target, WeaponMelee weap)
    {
        //0 =Miss
                //1 = hit
                //2 = Crit eventually.
                int HitScore;
                int DefenseScore;
                int WeaponSkill;

                if (weap!=null)
                {
                        WeaponSkill= Origin.PlayerSkills.GetSkill(weap.GetSkill());
                }
                else
                {
                        WeaponSkill= Origin.PlayerSkills.GetSkill(Skills.SkillUnarmed);
                }
                HitScore=Origin.PlayerSkills.Attack/2+WeaponSkill+ Random.Range(1,5);
                if (Target.GetComponent<NPC>()!=null)
                {//Target is an NPC
                        //Need to calculate this based on npc level

                        DefenseScore=-1;	//Until I figure out what values drive this, always hit.
                }
                else
                {
                        DefenseScore=-1;//Will always hit an non-npc;
                }

                if (DefenseScore<=HitScore)
                {
                        return 1;
                }
                else
                {
                        return 0;//A Miss
                }
    }
Esempio n. 32
0
	// Add a new instance of a script to an actor if the primary role is supported.
	public bool AssignScript(InteractionScript script, ObjectInteraction oi){
		bool assigned = false;

		if (oi.Roles.Contains(script.roles[0])){ //assigned by primary role
			// be sure we have a scriptedObject
			ScriptedObject so = oi.GetComponent<ScriptedObject>();
			if (so == null){
				so = oi.gameObject.AddComponent<ScriptedObject>();
				so.scripts = new InteractionScript[0];
				// prettyname!
			}
			// perform replacement if a script with the same name already exists.
			// this supports overriding base scripts with later loads
			foreach (InteractionScript scr in so.scripts){
				if (scr.name == script.name){
					so.RemoveScript(scr);
					DestroyImmediate (scr.gameObject);
					break;	
				}
			}
			
			so.InsertScriptSorted(script); // this sets the parent, we need to duplicate the script at this point.
			assigned = true;
		}
		return assigned;		
	}
 public static void Merge(ObjectInteraction mergingInto, ObjectInteraction mergingFrom)
 {
     //ObjectUsedOn.GetComponent<ObjectInteraction>().Link=ObjectUsedOn.GetComponent<ObjectInteraction>().Link+objInt().Link;
             mergingInto.Link += mergingFrom.Link;
             mergingInto.GetComponent<object_base>().MergeEvent();
             Destroy(mergingFrom.gameObject);
 }
 public static void Split(ObjectInteraction splitFrom)
 {
     splitFrom.GetComponent<object_base>().Split ();
 }
Esempio n. 35
0
    public override void Execute()
    {
        if (!Visible)
            return;

		base.Execute();

        int i;
        List<GUIMenu.MenuButton> buttons = lmenu.GetButtons();
		GUIMenu.MenuButton mbutton = lmenu.GetOnButton();
		
		if ( mbutton != null )
		{
	        // Check Target button, if active
            if ( mbutton.button.text == sHome ) // Patient button
	        {
                interactObject = target;
	
				// change title
				if ( title != null )
					title.text = interactObject.prettyname;
	
                InteractDialogMsg idmsg = new InteractDialogMsg();
                xmlData = interactObject.originXML;
                ScriptedObject so = interactObject.GetComponent<ScriptedObject>();
                if (so != null)
                    idmsg.items = so.QualifiedInteractions();
                else
                    idmsg.items = interactObject.ItemResponse;
                //idmsg.LoadXML(xmlData);
                idmsg.baseXML = xmlData;
                idmsg.baseobj = interactObject;
	
                Setup(idmsg);
	
                pastXMLs.Clear();
                rooming = false;
            }
            if ( mbutton.button.text == sPatient ) // Patient button
	        {
	            interactObject = patient;
				
				// change title
				if ( title != null )
					title.text = interactObject.prettyname;
	
	            InteractDialogMsg idmsg = new InteractDialogMsg();
	            xmlData = interactObject.originXML;
	            ScriptedObject so = interactObject.GetComponent<ScriptedObject>();
	            if (so != null)
	                idmsg.items = so.QualifiedInteractions();
	            else
	                idmsg.items = interactObject.ItemResponse;
	            //idmsg.LoadXML(xmlData);
	            idmsg.baseXML = xmlData;
	            idmsg.baseobj = interactObject;
	
	            Setup(idmsg);
	
	            pastXMLs.Clear();
	            rooming = false;
	        }
	        else if ( mbutton.button.text == sTeam ) // Team button
	        {
				// change button[0] name to this object
				
	            // Setup buttons
	            List<string> entries = new List<string>();
	            foreach (ObjectInteraction obj in roomObjects)
	            {
					if (obj.onTeamMenu)
						entries.Add(obj.prettyname);
	            }
	            rmenu.Setup(entries);
	            rooming = true;
	        }
	        else if ( mbutton.button.text == sBack ) // GoBack button
	        {
	            if (current != listings)
	            {
	                //InteractDialogMsg idmsg = new InteractDialogMsg();
	                //xmlData = pastXMLs[pastXMLs.Count - 1];
	                //idmsg.LoadXML(xmlData);
	                //idmsg.baseXML = xmlData;
	                //idmsg.baseobj = interactObject;
	
	                //Setup(idmsg);
	
	                //pastXMLs.RemoveAt(pastXMLs.Count - 1);
	                //rooming = false;
	
	                current = current.parent;
	                rooming = false;
	                SetupRight(current);
	            }
	            else
	            {
	                Visible = false;
	            }
	        }
			// clear buttons
	        for (i = 0; i < buttons.Count; i++)
	        {
	            buttons[i].on = false;
	        }
		}

        buttons = rmenu.GetButtons();
        for (i = 0; i < buttons.Count; i++)
        {
            if (rooming)
            {
                if (buttons[i].on)
                {
                    interactObject = null;
                    // Find matching Object by name (allows for onTeamMenu to work during runtime)
                    foreach (ObjectInteraction oi in roomObjects)
                    {
                        if (buttons[i].button.text == oi.prettyname)
                        {
                            interactObject = oi;
                            break;
                        }
                    }
                    if (interactObject == null) break; // Safety measure

                    InteractDialogMsg idmsg = new InteractDialogMsg();
                    xmlData = interactObject.originXML;
                    ScriptedObject so = interactObject.GetComponent<ScriptedObject>();
                    if (so != null)
                        idmsg.items = so.QualifiedInteractions();
                    else
                        idmsg.items = interactObject.ItemResponse;
					
                    idmsg.baseXML = xmlData;
                    idmsg.baseobj = interactObject;

					// change the title bar (or first element of left column for now) to be
					// this button name
					title.text = buttons[i].button.text;

					Setup(idmsg);					

                    pastXMLs.Clear();
                    rooming = false;
                    break;
                }
            }
            else
            {
                if (buttons[i].on)
                {
                    if (i < current.subCategories.Count)
                    {
                        current = current.subCategories[i];
                        SetupRight(current);
                        break;
                    }
                    else
                    {
                        InteractionMap im = current.items[i - current.subCategories.Count];
                        
                        // Activate interaction!
                        interactObject.PutMessage(new InteractMsg(interactObject.gameObject, im, im.log));
                        current=listings; // reset the menu for next time PAA
                        Visible = false;
                        break;
                    }
                }
            }
            buttons[i].on = false;
        }
    }
Esempio n. 36
0
    public virtual ObjectInteraction Pickup(ObjectInteraction objPicked, PlayerInventory  pInv)
    {
        //completes the pickup.

        objPicked.PickedUp=true;
        if (objPicked.GetComponent<Container>()!=null)
        {
            Container.SetPickedUpFlag(objPicked.GetComponent<Container>(),true);
            Container.SetItemsParent(objPicked.GetComponent<Container>(),InvMarker.transform);
            Container.SetItemsPosition (objPicked.GetComponent<Container>(),InvMarker.transform.position);
        }
        UWHUD.instance.CursorIcon=objPicked.GetInventoryDisplay().texture;
        pInv.ObjectInHand=objPicked.transform.name;
        //////pInv.JustPickedup=true;//To stop me throwing it away immediately.
        if (objPicked.GetComponent<Rigidbody>() !=null)
        {
            GameWorldController.FreezeMovement(objPicked.gameObject);
        }
        //Clone the object into the inventory
                if (WindowDetectUW.UsingRoomManager==true)
                {
                        GameObject objClone = Instantiate(objPicked.gameObject);
                        objClone.name=objPicked.name;
                        objPicked.name=objPicked.name+ "_destroyed";
                        //objPicked.transform.DestroyChildren();
                        DestroyImmediate(objPicked.gameObject);

                        objClone.transform.position = InvMarker.transform.position;
                        objClone.transform.parent=InvMarker.transform;
                        objClone.GetComponent<ObjectInteraction>().Pickup();
                        /*
                        UniqueIdentifier uid=objClone.GetComponent<UniqueIdentifier>();
                        if (uid!=null)
                        {
                                //uid.Id=uid.GetInstanceID().ToString();
                        }
                        */
                        objClone.GetComponent<ObjectInteraction>().Pickup();
                        return objClone.GetComponent<ObjectInteraction>();
                }
                else
                {
                        objPicked.transform.position=InvMarker.transform.position;
                        objPicked.transform.parent=InvMarker.transform;
                        objPicked.Pickup();
                        return objPicked;
                }

        //objPicked.transform.position = InvMarker.transform.position;
        //objPicked.transform.parent=InvMarker.transform;

        //objPicked.Pickup();//Call pickup event for this object.
    }
Esempio n. 37
0
	protected void GotoObj( ObjectInteraction objint )
	{
		if ( objint == null )
			return;
		
        interactObject = objint;
				
		// change title
		if ( label != null )
			label.text = interactObject.prettyname;
	
        InteractDialogMsg idmsg = new InteractDialogMsg();
        xmlData = interactObject.originXML;
        ScriptedObject so = interactObject.GetComponent<ScriptedObject>();
        if (so != null)
            idmsg.items = so.QualifiedInteractions();
        else
            idmsg.items = interactObject.ItemResponse;
        //idmsg.LoadXML(xmlData);
    	idmsg.baseXML = xmlData;
        idmsg.baseobj = interactObject;
	
        Setup(idmsg);
	}