Пример #1
0
 public static void SetItemsParent(Container cn, Transform Parent)
 {
     for (short i = 0; i <= cn.MaxCapacity(); i++)
     {
         string ItemName = cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = cn.GetGameObjectAt(i);                 //GameObject.Find (cn.GetItemAt(i));
             if (item != null)
             {
                 item.transform.parent = Parent;
                 if (Parent == GameWorldController.instance.LevelMarker())
                 {
                     GameWorldController.MoveToWorld(item);
                 }
                 else
                 {
                     GameWorldController.MoveToInventory(item);
                 }
                 if (item.GetComponent <Container>() != null)
                 {
                     Container.SetItemsParent(item.GetComponent <Container>(), Parent);
                 }
             }
         }
     }
 }
Пример #2
0
    private bool PickUpSeed()
    {
        ObjectLoaderInfo newseed = ObjectLoader.newObject(290, 40, 16, 1, 256);

        newseed.is_quant = 1;
        ObjectInteraction newseedobj = ObjectInteraction.CreateNewObject
                                       (
            CurrentTileMap(),
            newseed,
            CurrentObjectList().objInfo,
            GameWorldController.instance.InventoryMarker.gameObject,
            CurrentTileMap().getTileVector(TileMap.ObjectStorageTile, TileMap.ObjectStorageTile)
                                       );

        GameWorldController.MoveToInventory(newseedobj.gameObject);
        UWCharacter.Instance.ResurrectPosition = Vector3.zero;
        UWCharacter.Instance.ResurrectLevel    = 0;
        UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 9));
        CurrentObjectInHand = newseedobj;
        //newseedobj.UpdateAnimation();
        //UWHUD.instance.CursorIcon = newseedobj.GetWorldDisplay().texture;
        UWCharacter.InteractionMode      = UWCharacter.InteractionModePickup;
        InteractionModeControl.UpdateNow = true;

        objInt().consumeObject();
        return(true);
    }
Пример #3
0
    /// <summary>
    /// Spawn leftovers after eating in UW2
    /// </summary>
    protected void LeftOvers()
    {
        int LeftOverToCreate = -1;

        switch (item_id)
        {
        case 176:
        case 177:    //meat
            LeftOverToCreate = 197; break;

        case 186:    //honeycomb
            LeftOverToCreate = 210; break;

        case 187:
        case 188:
        case 189:    //bottles.
            LeftOverToCreate = 317; break;
        }

        if (LeftOverToCreate != -1)
        {
            ObjectLoaderInfo newobjt = ObjectLoader.newWorldObject(LeftOverToCreate, 40, 0, 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.gameObject);
            CurrentObjectInHand         = created;
            UWCharacter.InteractionMode = UWCharacter.InteractionModePickup;
        }
    }
Пример #4
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);
    }
Пример #5
0
    public void GiveKeyOfTruth()
    {
        if (HasGivenKey == false)
        {
            //Code to spawn key of truth in player hand
            //Debug.Log ("You get the key of truth");
            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_none_of_your_skills_improved_));            //No skills appear
            //inputctrl.text=UWHUD.instance.MessageScroll.text;
            Shrine.HasGivenKey = true;
            //create the key of truth.
            ObjectLoaderInfo newobjt = ObjectLoader.newObject(225, 0, 0, 0, 256);
            GameObject       key     = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject;
            GameWorldController.MoveToInventory(key);
            ObjectInteraction myObjInt = key.GetComponent <ObjectInteraction>();


            /*ObjectInteraction myObjInt = ObjectInteraction.CreateNewObject(225);
             * myObjInt.gameObject.transform.parent=GameWorldController.instance.InventoryMarker.transform;
             * GameWorldController.MoveToInventory(myObjInt.gameObject);*/
            UWCharacter.Instance.playerInventory.ObjectInHand = myObjInt.name;
            UWHUD.instance.CursorIcon        = myObjInt.GetInventoryDisplay().texture;
            UWCharacter.InteractionMode      = UWCharacter.InteractionModePickup;
            InteractionModeControl.UpdateNow = true;
        }
    }
Пример #6
0
    /// <summary>
    /// Creates the fish that the player has caught.
    /// </summary>
    /// <returns>The fish.</returns>
    ObjectInteraction CreateFish()
    {
        ObjectLoaderInfo  newobjt = ObjectLoader.newObject(182, 40, 0, 1, 256);
        ObjectInteraction fishy   = ObjectInteraction.CreateNewObject(CurrentTileMap(), newobjt, CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position);

        fishy.gameObject.name = ObjectLoader.UniqueObjectName(newobjt);
        fishy.isquant         = 1;
        GameWorldController.MoveToInventory(fishy.gameObject);
        return(fishy);
    }
    /// <summary>
    /// Creates the fish that the player has caught.
    /// </summary>
    /// <returns>The fish.</returns>
    GameObject CreateFish()
    {
        ObjectLoaderInfo newobjt = ObjectLoader.newObject(182, 40, 0, 1, 256);
        GameObject       fishy   = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject;

        fishy.name = ObjectLoader.UniqueObjectName(newobjt);
        GameWorldController.MoveToInventory(fishy);
        //newobjt.index= UWCharacter.Instance.playerInventory.ItemCounter++;

        //fishy.GetComponent<Food>().Nutrition=5;
        return(fishy);       // ObjectInteraction.CreateNewObject(182).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;
            }
        }
    }
Пример #9
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();
    }
Пример #10
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);
    }
Пример #11
0
    private void MusicInstrumentInteaction()
    {
        if (Input.GetKeyDown("1"))
        {
            PlayNote(1);
        }
        if (Input.GetKeyDown("2"))
        {
            PlayNote(2);
        }
        if (Input.GetKeyDown("3"))
        {
            PlayNote(3);
        }
        if (Input.GetKeyDown("4"))
        {
            PlayNote(4);
        }
        if (Input.GetKeyDown("5"))
        {
            PlayNote(5);
        }
        if (Input.GetKeyDown("6"))
        {
            PlayNote(6);
        }
        if (Input.GetKeyDown("7"))
        {
            PlayNote(7);
        }
        if (Input.GetKeyDown("8"))
        {
            PlayNote(8);
        }
        if (Input.GetKeyDown("9"))
        {
            PlayNote(9);
        }
        if (Input.GetKeyDown("0"))
        {
            PlayNote(10);
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            //000~001~251~You put the instrument down.
            PlayingInstrument = false;
            CurrentInstrument = "";
            WindowDetectUW.WaitingForInput           = false;
            UWCharacter.Instance.playerMotor.enabled = true;
            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, StringController.str_you_put_the_instrument_down_));
            GameWorldController.instance.getMus().Resume();
            //354237875
            if (_RES == GAME_UW1)
            {
                if ((NoteRecord == "354237875") && (objInt().item_id == 292))            //Flute only
                {
                    //UWHUD.instance.MessageScroll.Add ("Eyesnack would be proud of your playing");
                    if ((GameWorldController.instance.LevelNo == 2) && (Quest.instance.isCupFound == false) && (objInt().item_id == 292))
                    {
                        int tileX = TileMap.visitTileX;
                        int tileY = TileMap.visitTileY;
                        if (((tileX >= 23) || (tileX <= 27)) && ((tileY >= 43) || (tileY <= 45)))
                        {
                            //create the cup of wonder.

                            ObjectLoaderInfo newobjt = ObjectLoader.newObject(174, 0, 0, 0, 256);
                            GameObject       cup     = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newobjt, GameWorldController.instance.InventoryMarker.gameObject, GameWorldController.instance.InventoryMarker.transform.position).gameObject;
                            GameWorldController.MoveToInventory(cup);
                            ObjectInteraction myObjInt = cup.GetComponent <ObjectInteraction>();

                            /*	ObjectInteraction myObjInt = ObjectInteraction.CreateNewObject(174);
                             * myObjInt.gameObject.transform.parent=GameWorldController.instance.InventoryMarker.transform;
                             * GameWorldController.MoveToInventory(myObjInt.gameObject);*/
                            UWCharacter.Instance.playerInventory.ObjectInHand = myObjInt.name;
                            UWHUD.instance.CursorIcon        = myObjInt.GetInventoryDisplay().texture;
                            UWCharacter.InteractionMode      = UWCharacter.InteractionModePickup;
                            InteractionModeControl.UpdateNow = true;
                            Quest.instance.isCupFound        = true;
                            //An object appears in the air and falls into your hands
                            UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 136));
                        }
                    }
                }
            }
        }
    }
Пример #12
0
 public void PlayerSlotLeftClick()
 {
     if (TradeSlot.Locked)
     {
         return;
     }
     if (UWCharacter.Instance.playerInventory.ObjectInHand != "")
     {
         //put the object in hand in this slot.
         if (objectInSlot == "")
         {            //Empty slot
             GameObject objToMove = UWCharacter.Instance.playerInventory.GetGameObjectInHand();
             if (objToMove != null)
             {
                 if (objToMove.transform.parent != GameWorldController.instance.DynamicObjectMarker())
                 {                    //Object needs to be moved to world
                     //objToMove.transform.parent= GameWorldController.instance.DynamicObjectMarker();
                     GameWorldController.MoveToWorld(objToMove);
                     ConversationVM.BuildObjectList();
                 }
                 objectInSlot = UWCharacter.Instance.playerInventory.ObjectInHand;
                 UWCharacter.Instance.playerInventory.ObjectInHand = "";
                 SlotImage.texture         = UWHUD.instance.CursorIcon;
                 UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault;
                 Selected = true;
             }
         }
         else
         {            //Swap the objects
             GameObject objInSlot = GetGameObjectInteraction().gameObject;
             GameObject objInHand = UWCharacter.Instance.playerInventory.GetGameObjectInHand();
             if (objInSlot != null)
             {
                 objInSlot.transform.parent = GameWorldController.instance.InventoryMarker.transform;
                 GameWorldController.MoveToInventory(objInSlot);                    //This will call rebuild list
             }
             if (objInHand != null)
             {
                 if (objInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker())
                 {                    //Object needs to be moved to world
                     //objInHand.transform.parent= GameWorldController.instance.DynamicObjectMarker();
                     GameWorldController.MoveToWorld(objInHand);
                 }
             }
             objectInSlot              = objInHand.name;
             SlotImage.texture         = objInHand.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture;
             UWHUD.instance.CursorIcon = objInSlot.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture;
             UWCharacter.Instance.playerInventory.ObjectInHand = objInSlot.name;
             ConversationVM.BuildObjectList();
             Selected = true;
         }
     }
     else
     {
         if (objectInSlot != "")
         {
             //Pickup the object in the slot
             UWCharacter.Instance.playerInventory.SetObjectInHand(objectInSlot);
             UWHUD.instance.CursorIcon = UWCharacter.Instance.playerInventory.GetGameObject(objectInSlot).GetComponent <ObjectInteraction>().GetInventoryDisplay().texture;
             objectInSlot      = "";
             SlotImage.texture = Blank;
             Selected          = false;
             GameObject objToMove = UWCharacter.Instance.playerInventory.GetGameObjectInHand();
             if (objToMove != null)
             {
                 objToMove.transform.parent = GameWorldController.instance.InventoryMarker.transform;
                 GameWorldController.MoveToInventory(objToMove);                    //This will call rebuild list
                 objToMove.GetComponent <object_base>().PickupEvent();
             }
         }
     }
     if (objectInSlot == "")
     {
         Quantity.text = "";
     }
     else
     {
         int qty = GetGameObjectInteraction().GetQty();
         if (qty <= 1)
         {
             Quantity.text = "";
         }
         else
         {
             Quantity.text = qty.ToString();
         }
     }
 }
Пример #13
0
    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.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)
            {
                UWCharacter.Instance.playerInventory.ObjectInHand = QuantityObj.name;
                UWHUD.instance.CursorIcon = QuantityObj.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture;
                if (this.slotIndex >= 11)
                {
                    UWCharacter.Instance.playerInventory.GetCurrentContainer().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.newObject(objI.item_id, objI.quality, objI.owner, quant, -1);
                newObj.is_quant = 1;
                ObjectInteraction NewObjI = ObjectInteraction.CreateNewObject(GameWorldController.instance.currentTileMap(), newObj, GameWorldController.instance.CurrentObjectList().objInfo, GameWorldController.instance.InventoryMarker, GameWorldController.instance.InventoryMarker.transform.position);
                GameWorldController.MoveToInventory(NewObjI);
                UWCharacter.Instance.playerInventory.ObjectInHand = NewObjI.name;
                UWHUD.instance.CursorIcon = NewObjI.GetInventoryDisplay().texture;
                ObjectInteraction.Split(objI, NewObjI);
                UWCharacter.Instance.playerInventory.Refresh(slotIndex);
                QuantityObj = null;


                /*	GameObject Split = Instantiate(QuantityObj);//What we are picking up.
                 *      Split.GetComponent<ObjectInteraction>().link =quant;
                 *      Split.name = Split.name+"_"+UWCharacter.Instance.summonCount++;
                 *      Split.transform.parent=UWCharacter.Instance.playerInventory.InventoryMarker.transform;//this.transform.parent;
                 *      QuantityObj.GetComponent<ObjectInteraction>().link=QuantityObj.GetComponent<ObjectInteraction>().link-quant;
                 *      UWCharacter.Instance.playerInventory.ObjectInHand= Split.name;
                 *      UWHUD.instance.CursorIcon= Split.GetComponent<ObjectInteraction>().GetInventoryDisplay().texture;
                 *      ObjectInteraction.Split (Split.GetComponent<ObjectInteraction>(),QuantityObj.GetComponent<ObjectInteraction>());
                 *      UWCharacter.Instance.playerInventory.Refresh (slotIndex);
                 *      QuantityObj=null;//Clear out to avoid weirdness.*/
            }
        }
    }
Пример #14
0
    public void PlayerSlotLeftClick()
    {
        if (TradeSlot.Locked)
        {
            return;
        }
        ObjectInteraction objIntAtSlot = GetGameObjectInteraction();

        if (CurrentObjectInHand != null)
        {
            //put the object in hand in this slot.
            if (objectInSlot == null)
            {            //Empty slot
                if (CurrentObjectInHand != null)
                {
                    if (CurrentObjectInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker())
                    {                    //Object needs to be moved to world
                        GameWorldController.MoveToWorld(CurrentObjectInHand);
                        ConversationVM.BuildObjectList();
                    }
                    objectInSlot        = CurrentObjectInHand;
                    SlotImage.texture   = UWHUD.instance.CursorIcon;
                    CurrentObjectInHand = null;
                    Selected            = true;
                }
            }
            else
            {            //Swap the objects
                if (objIntAtSlot != null)
                {
                    objIntAtSlot.transform.parent = GameWorldController.instance.InventoryMarker.transform;
                    GameWorldController.MoveToInventory(objIntAtSlot);                    //This will call rebuild list
                }
                if (CurrentObjectInHand != null)
                {
                    if (CurrentObjectInHand.transform.parent != GameWorldController.instance.DynamicObjectMarker())
                    {                    //Object needs to be moved to world
                        GameWorldController.MoveToWorld(CurrentObjectInHand);
                    }
                }
                objectInSlot        = CurrentObjectInHand;
                SlotImage.texture   = CurrentObjectInHand.GetInventoryDisplay().texture;
                CurrentObjectInHand = objIntAtSlot;
                ConversationVM.BuildObjectList();
                Selected = true;
            }
        }
        else
        {
            if (objectInSlot != null)
            {
                //Pickup the object in the slot
                CurrentObjectInHand = objIntAtSlot;
                objectInSlot        = null;
                SlotImage.texture   = Blank;
                Selected            = false;
                if (CurrentObjectInHand != null)
                {
                    CurrentObjectInHand.transform.parent = GameWorldController.instance.InventoryMarker.transform;
                    GameWorldController.MoveToInventory(CurrentObjectInHand);                    //This will call rebuild list
                    CurrentObjectInHand.GetComponent <object_base>().PickupEvent();
                }
            }
        }
        if (objectInSlot == null)
        {
            Quantity.text = "";
        }
        else
        {
            int qty = GetGameObjectInteraction().GetQty();
            if (qty <= 1)
            {
                Quantity.text = "";
            }
            else
            {
                Quantity.text = qty.ToString();
            }
        }
    }