GetItemAt() 공개 메소드

public GetItemAt ( int index ) : string
index int
리턴 string
예제 #1
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 (int i = 0; i < cn.MaxCapacity(); i++)
     {
         string ItemName = cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = GameObject.Find(cn.GetItemAt(i));
             if (item != null)
             {
                 if (item.GetComponent <ObjectInteraction>() != null)
                 {
                     item.GetComponent <ObjectInteraction>().PickedUp = NewValue;
                     if (item.GetComponent <ObjectInteraction>().ItemType == ObjectInteraction.A_PICK_UP_TRIGGER)
                     {                        //Special case
                         item.GetComponent <a_pick_up_trigger>().Activate();
                         if (item == null)
                         {                            //Use trigger is no more.
                             cn.RemoveItemFromContainer(i);
                         }
                     }
                     else if (item.GetComponent <Container>() != null)
                     {
                         Container.SetPickedUpFlag(item.GetComponent <Container>(), NewValue);
                     }
                 }
             }
         }
     }
 }
예제 #2
0
    public float getInventoryWeight()
    {
        float answer = 0.0f;

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

        //Get the weight of the gronk container as that is alway the top level of the inventory
        for (int i = 0; i < playerContainer.MaxCapacity(); i++)
        {
            if (playerContainer.GetItemAt(i) != "")
            {
                GameObject objItem = GameObject.Find(playerContainer.GetItemAt(i));
                if (objItem != null)
                {
                    answer += objItem.GetComponent <ObjectInteraction>().GetWeight();
                }
                else
                {
                    answer += 0;
                }
            }
        }
        return(answer);
    }
예제 #3
0
    public void Refresh()
    {    //Force a full refresh of inventory display
        Container cn = GameObject.Find(currentContainer).GetComponent <Container>();

        bHelm          = true;
        bChest         = true;
        bLegs          = true;
        bBoots         = true;
        bGloves        = true;
        bRightShoulder = true;
        bLeftShoulder  = true;
        bRightHand     = true;
        bLeftHand      = true;
        bRightRing     = true;
        bLeftRing      = true;
        for (short i = 11; i <= 18; i++)
        {
            sBackPack[i - 11] = cn.GetItemAt((short)(ContainerOffset + i - 11));
            bBackPack[i - 11] = true;
        }
        if (UWHUD.instance.Encumberance.enabled == true)
        {
            UWHUD.instance.Encumberance.text = Mathf.Round(getEncumberance()).ToString();
        }
        UpdateLightSources();
    }
예제 #4
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);
                 }
             }
         }
     }
 }
예제 #5
0
 public static void SetItemsParent(Container cn, Transform Parent)
 {
     for (int i = 0; i < cn.MaxCapacity(); i++)
     {
         string ItemName = cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = GameObject.Find(cn.GetItemAt(i));
             if (item != null)
             {
                 item.transform.parent = Parent;
                 if (item.GetComponent <Container>() != null)
                 {
                     Container.SetItemsParent(item.GetComponent <Container>(), Parent);
                 }
             }
         }
     }
 }
예제 #6
0
 public static void SetItemsParent(Container cn, Transform Parent)
 {
     for (int i =0; i<=cn.MaxCapacity ();i++)
     {
         string ItemName=cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = GameObject.Find (cn.GetItemAt(i));
             if (item != null)
             {
                 item.transform.parent=Parent;
                 if (item.GetComponent<Container>()!=null)
                 {
                     Container.SetItemsParent(item.GetComponent<Container>(),Parent);
                 }
             }
         }
     }
 }
예제 #7
0
 public static void SetItemsPosition(Container cn, Vector3 Position)
 {
     for (int i = 0; i < cn.MaxCapacity(); i++)
     {
         string ItemName = cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = GameObject.Find(cn.GetItemAt(i));
             if (item != null)
             {
                 item.transform.position = Position;
                 if (item.GetComponent <Container>() != null)
                 {
                     Container.SetItemsPosition(item.GetComponent <Container>(), Position);
                 }
             }
         }
     }
 }
예제 #8
0
 public static int GetFreeSlot(Container cn)
 {    //Returns an available slot on the current container.
     for (short i = 0; i <= cn.MaxCapacity(); i++)
     {
         if (cn.GetItemAt(i) == "")
         {
             return(i);
         }
     }
     return(-1);
 }
예제 #9
0
 public static int GetFreeSlot(Container cn)
 {
     //Returns an available slot on the current container.
     for (int i=0;i<=cn.MaxCapacity();i++)
     {
         if (cn.GetItemAt (i)=="")
         {
             return i;
         }
     }
     return -1;
 }
예제 #10
0
    public static void SortContainer(Container cn)
    {
        //Debug.Log ("Sorting container");
        //Flattens the contents of a container so that they occupy the first slots
        int    currFreeSlot = -1;
        string ItemName;
        bool   GetNextSlot = true;

        for (short i = 0; i <= cn.MaxCapacity(); i++)
        {
            //Find the first free slot
            if (GetNextSlot == true)
            {
                for (short j = 0; j <= cn.MaxCapacity(); j++)
                {
                    ItemName = cn.GetItemAt(j);
                    if (ItemName == "")
                    {
                        currFreeSlot = j;
                        GetNextSlot  = false;
                        break;
                    }
                }
            }
            if ((i > currFreeSlot) && (currFreeSlot != -1))
            {
                ItemName = cn.GetItemAt(i);
                if (ItemName != "")
                {                //Move this item to the free slot
                    cn.RemoveItemFromContainer(i);
                    cn.AddItemToContainer(ItemName, currFreeSlot);
                    GetNextSlot  = true;
                    currFreeSlot = -1;
                }
            }
        }
    }
 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 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);
             }
         }
     }
 }
예제 #13
0
    /* public void Refresh(int slotIndex)
     * {//Force a refresh of a specific slot
     *   switch (slotIndex)
     *   {
     *       case 0://Helm
     *           bHelm = true;
     *           break;
     *       case 1://Chest
     *           bChest = true;
     *           break;
     *       case 2://Leggings
     *           bLegs = true;
     *           break;
     *       case 3://Boots
     *           bBoots = true;
     *           break;
     *       case 4://Gloves
     *           bGloves = true;
     *           break;
     *       case 5://ShoulderRight
     *           bRightShoulder = true;
     *           break;
     *       case 6://ShoulderLeft
     *           bLeftShoulder = true;
     *           break;
     *       case 7://HandRight
     *           bRightHand = true;
     *           break;
     *       case 8://HandLeft
     *           bLeftHand = true;
     *           break;
     *       case 9://RingRight
     *           bRightRing = true;
     *           break;
     *       case 10://RingLeft
     *           bLeftRing = true;
     *           break;
     *       default://Inventory Slots 0-7
     *           if ((slotIndex >= 11) && (slotIndex <= 18))
     *           {
     *               bBackPack[slotIndex - 11] = true;
     *           }
     *           break;
     *   }
     * }*/

    public void Refresh()
    {//Force a full refresh of inventory display
        Container cn = GameObject.Find(currentContainer).GetComponent <Container>();

        sHelm          = sHelm;
        sChest         = sChest;
        sLegs          = sLegs;
        sBoots         = sBoots;
        sGloves        = sGloves;
        sRightShoulder = sRightShoulder;
        sLeftShoulder  = sLeftShoulder;
        sRightHand     = sRightHand;
        // sRightHand = null;
        sLeftHand  = sLeftHand;
        sRightRing = sRightRing;
        sLeftRing  = sLeftRing;
        for (short i = 11; i <= 18; i++)
        {
            //if (cn.GetItemAt((short)(ContainerOffset + i - 11))!=null)
            // {
            // sBackPack[i - 11] = cn.GetItemAt((short)(ContainerOffset + i - 11));
            setBackPack(i - 11, cn.GetItemAt((short)(ContainerOffset + i - 11)));
            //}
            //else
            //{
            //   setBackPack(i - 11, null);
            //sBackPack[i - 11] = null;
            //}
            //bBackPack[i - 11] = true;
        }
        if (UWHUD.instance.Encumberance.enabled == true)
        {
            UWHUD.instance.Encumberance.text = Mathf.Round(getEncumberance()).ToString();
        }
        UpdateLightSources();
    }
예제 #14
0
 /// <summary>
 /// Force a full refresh of inventory display
 /// </summary>
 public void Refresh()
 {
     sHelm          = sHelm;
     sChest         = sChest;
     sLegs          = sLegs;
     sBoots         = sBoots;
     sGloves        = sGloves;
     sRightShoulder = sRightShoulder;
     sLeftShoulder  = sLeftShoulder;
     sRightHand     = sRightHand;
     // sRightHand = null;
     sLeftHand  = sLeftHand;
     sRightRing = sRightRing;
     sLeftRing  = sLeftRing;
     for (short i = 11; i <= 18; i++)
     {
         setBackPack(i - 11, currentContainer.GetItemAt((short)(ContainerOffset + i - 11)));
     }
     if (UWHUD.instance.Encumberance.enabled == true)
     {
         UWHUD.instance.Encumberance.text = getEncumberance().ToString();
     }
     UpdateLightSources();
 }
예제 #15
0
    /// <summary>
    /// Mixs the rotworm stew.
    /// </summary>
    /// <returns><c>true</c>, if rotworm stew was mixed, <c>false</c> otherwise.</returns>
    bool MixRotwormStew()
    {
        bool hasPort               = false;
        ObjectInteraction port     = null;
        bool hasGreenMushroom      = false;
        ObjectInteraction mushroom = null;
        bool hasCorpse             = false;
        ObjectInteraction corpse   = null;
        bool hasExtraItems         = false;
        //Find a bowl in the players inventory.
        //Check if it only contains port, a rotworm corpse and a greenmushroom.

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

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

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

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

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

                        ObjectInteraction bowlObjectInt = bowl.GetComponent <ObjectInteraction>();
                        bowlObjectInt.ChangeType(283);
                        Destroy(bowlContainer);    //Remove the container from the object.
                        bowl.gameObject.AddComponent <Food>();
                        bowlObjectInt.isquant = 1;
                        bowlObjectInt.link    = 1;
                        return(true);
                    }
                    else
                    {    //We don't have the items
                         //000~001~148~The bowl does not contain the correct ingredients. \n
                        UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 148));
                        return(true);
                    }
                }
            }
            //}
        }
        //000~001~150~You need a bowl to mix the ingredients. \n
        UWHUD.instance.MessageScroll.Add(StringController.instance.GetString(1, 150));
        return(true);
    }
 public void OnClick()
 {
     if (Dragging == true)
     {
         return;
     }
     if ((UWCharacter.Instance.isRoaming == true) || (Quest.instance.InDreamWorld))
     {//No inventory use while using wizard eye.
         return;
     }
     if (UWCharacter.Instance.playerInventory.currentContainer == UWCharacter.Instance.playerInventory.playerContainer) // UWCharacter.Instance.name)
     {                                                                                                                  //Don't do anything on the top level
         UWCharacter.Instance.playerInventory.ContainerOffset = 0;
         BackpackBg.SetActive(false);
         return;
     }
     if (CurrentObjectInHand == null)
     {//Player has no object in their hand. We close up the container.
         ScrollButtonInventory.ScrollValue = 0;
         UWCharacter.Instance.playerInventory.ContainerOffset = 0;
         Container currentContainerObj = UWCharacter.Instance.playerInventory.currentContainer;
         UWCharacter.Instance.playerInventory.currentContainer = currentContainerObj.ContainerParent;
         currentContainerObj.isOpenOnPanel = false;
         //Close child containers as well
         CloseChildContainer(currentContainerObj);
         Container DestinationContainer = UWCharacter.Instance.playerInventory.currentContainer;
         if (UWCharacter.Instance.playerInventory.currentContainer == UWCharacter.Instance.playerInventory.playerContainer)
         {
             GetComponent <RawImage>().texture = UWCharacter.Instance.playerInventory.Blank;
             BackpackBg.SetActive(false);
             if ((DestinationContainer.CountItems() >= 8) && (DestinationContainer != UWCharacter.Instance.playerInventory.playerContainer))
             {
                 InvUp.SetActive(true);
                 InvDown.SetActive(true);
             }
             else
             {
                 InvUp.SetActive(false);
                 InvDown.SetActive(false);
             }
         }
         else
         {
             GetComponent <RawImage>().texture = DestinationContainer.transform.GetComponent <ObjectInteraction>().GetEquipDisplay().texture;
             BackpackBg.SetActive(true);
             if ((DestinationContainer.CountItems() >= 8) && (DestinationContainer != UWCharacter.Instance.playerInventory.playerContainer))
             {
                 InvUp.SetActive(true);
                 InvDown.SetActive(true);
             }
             else
             {
                 InvUp.SetActive(false);
                 InvDown.SetActive(false);
             }
         }
         for (short i = 0; i < 8; i++)
         {
             UWCharacter.Instance.playerInventory.SetObjectAtSlot((short)(i + 11), DestinationContainer.GetItemAt(i));
         }
     }
     else
     {
         if (UWCharacter.InteractionMode != UWCharacter.InteractionModePickup)
         {//Only allow this to happen when in pickup mode.
             return;
         }
         //Move the contents out of the container into the parent.
         //Container CurrentContainer = UWCharacter.Instance.playerInventory.currentContainer; //GameObject.Find(UWCharacter.Instance.playerInventory.currentContainer).GetComponent<Container>();
         Container DestinationContainer = UWCharacter.Instance.playerInventory.currentContainer.ContainerParent; //GameObject.Find(CurrentContainer.ContainerParent).GetComponent<Container>();
         if (Container.TestContainerRules(DestinationContainer, 11, false))
         {
             if (!CurrentObjectInHand.IsStackable())
             {
                 if (DestinationContainer.AddItemToContainer(CurrentObjectInHand))
                 {//Object has moved
                     CurrentObjectInHand = null;
                 }
             }
             else
             {
                 if (DestinationContainer.AddItemMergedItemToContainer(CurrentObjectInHand))
                 {//Object has moved
                     CurrentObjectInHand = null;
                 }
             }
         }
     }
 }
 public void OnClick()
 {
     if (Dragging == true)
     {
         return;
     }
     if (UWCharacter.Instance.playerInventory.currentContainer == UWCharacter.Instance.name)
     {                        //Don't do anything on the top level
         UWCharacter.Instance.playerInventory.ContainerOffset = 0;
         BackpackBg.SetActive(false);
         return;
     }
     if (UWCharacter.Instance.playerInventory.ObjectInHand == "")
     {                        //Player has no object in their hand. We close up the container.
         ScrollButtonInventory.ScrollValue = 0;
         UWCharacter.Instance.playerInventory.ContainerOffset = 0;
         Container currentContainerObj = UWCharacter.Instance.playerInventory.GetCurrentContainer();
         UWCharacter.Instance.playerInventory.currentContainer = currentContainerObj.ContainerParent;
         currentContainerObj.isOpenOnPanel = false;
         //Close child containers as well
         CloseChildContainer(currentContainerObj);
         Container DestinationContainer = UWCharacter.Instance.playerInventory.GetCurrentContainer();
         if (UWCharacter.Instance.playerInventory.currentContainer == UWCharacter.Instance.name)
         {
             GetComponent <RawImage>().texture = UWCharacter.Instance.playerInventory.Blank;
             BackpackBg.SetActive(false);
             if ((DestinationContainer.CountItems() >= 8) && (DestinationContainer != UWCharacter.Instance.playerInventory.playerContainer))
             {
                 InvUp.SetActive(true);
                 InvDown.SetActive(true);
             }
             else
             {
                 InvUp.SetActive(false);
                 InvDown.SetActive(false);
             }
         }
         else
         {
             GetComponent <RawImage>().texture = DestinationContainer.transform.GetComponent <ObjectInteraction>().GetEquipDisplay().texture;
             BackpackBg.SetActive(true);
             if ((DestinationContainer.CountItems() >= 8) && (DestinationContainer != UWCharacter.Instance.playerInventory.playerContainer))
             {
                 InvUp.SetActive(true);
                 InvDown.SetActive(true);
             }
             else
             {
                 InvUp.SetActive(false);
                 InvDown.SetActive(false);
             }
         }
         for (short i = 0; i < 8; i++)
         {
             string sItem = DestinationContainer.GetItemAt(i);
             UWCharacter.Instance.playerInventory.SetObjectAtSlot((short)(i + 11), sItem);
         }
     }
     else
     {
         if (UWCharacter.InteractionMode != UWCharacter.InteractionModePickup)
         {                                    //Only allow this to happen when in pickup mode.
             return;
         }
         //Move the contents out of the container into the parent.
         Container         CurrentContainer     = GameObject.Find(UWCharacter.Instance.playerInventory.currentContainer).GetComponent <Container>();
         Container         DestinationContainer = GameObject.Find(CurrentContainer.ContainerParent).GetComponent <Container>();
         ObjectInteraction item = GameObject.Find(UWCharacter.Instance.playerInventory.ObjectInHand).GetComponent <ObjectInteraction>();
         if (Container.TestContainerRules(DestinationContainer, 11, false))
         {
             //if ((item.isQuant()==false) || (item.isEnchanted()))
             if (!item.IsStackable())
             {
                 if (DestinationContainer.AddItemToContainer(UWCharacter.Instance.playerInventory.ObjectInHand))
                 {                                                            //Object has moved
                     UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault;
                     UWCharacter.Instance.playerInventory.ObjectInHand = "";
                 }
             }
             else
             {
                 if (DestinationContainer.AddItemMergedItemToContainer(item.gameObject))
                 {                                                            //Object has moved
                     UWHUD.instance.CursorIcon = UWHUD.instance.CursorIconDefault;
                     UWCharacter.Instance.playerInventory.ObjectInHand = "";
                 }
             }
         }
     }
 }
예제 #18
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 (int i =0; i<=cn.MaxCapacity();i++)
     {
         string ItemName=cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = GameObject.Find (cn.GetItemAt(i));
             if (item !=null)
             {
                 if (item.GetComponent<ObjectInteraction>()!=null)
                 {
                     item.GetComponent<ObjectInteraction>().PickedUp=NewValue;
                     if (item.GetComponent<ObjectInteraction>().GetItemType()==ObjectInteraction.A_PICK_UP_TRIGGER)
                     {//Special case
                         item.GetComponent<a_pick_up_trigger>().Activate();
                         //if (item==null)
                         //{//Use trigger is no more.
                         cn.RemoveItemFromContainer(i);
                         //}
                     }
                     else if (item.GetComponent<Container>()!=null)
                     {
                         Container.SetPickedUpFlag(item.GetComponent<Container>(),NewValue);
                     }
                 }
             }
         }
     }
 }
예제 #19
0
 public static void SortContainer(Container cn)
 {
     //Debug.Log ("Sorting container");
     //Flattens the contents of a container so that they occupy the first slots
     int currFreeSlot=-1;
     string ItemName;
     bool GetNextSlot=true;
     for (int i=0;i<=cn.MaxCapacity();i++)
     {
         //Find the first free slot
         if (GetNextSlot==true)
         {
             for (int j=0;j<=cn.MaxCapacity();j++)
             {
                 ItemName=cn.GetItemAt(j);
                 if (ItemName=="")
                 {
                     currFreeSlot=j;
                     GetNextSlot=false;
                     break;
                 }
             }
         }
         if ((i>currFreeSlot) &&(currFreeSlot!=-1))
         {
             ItemName=cn.GetItemAt(i);
             if (ItemName!="")
             {//Move this item to the free slot
                 cn.RemoveItemFromContainer(i);
                 cn.AddItemToContainer(ItemName,currFreeSlot);
                 GetNextSlot=true;
                 currFreeSlot=-1;
             }
         }
     }
 }
예제 #20
0
 public static void SetItemsPosition(Container cn, Vector3 Position)
 {
     for (int i =0; i<=cn.MaxCapacity();i++)
     {
         string ItemName=cn.GetItemAt(i);
         if (ItemName != "")
         {
             GameObject item = GameObject.Find (cn.GetItemAt(i));
             if (item!=null)
             {
                 item.transform.position=Position;
                 if (item.GetComponent<Container>()!=null)
                 {
                     Container.SetItemsPosition(item.GetComponent<Container>(),Position);
                 }
             }
         }
     }
 }
예제 #21
0
 void OnClick()
 {
     if (playerUW.playerInventory.currentContainer == playerUW.name)
     {        //Don't do anything on the top level
         playerUW.playerInventory.ContainerOffset = 0;
         return;
     }
     if (playerUW.playerInventory.ObjectInHand == "")
     {        //Player has no object in their hand. We close up the container.
         ScrollButtonInventory.ScrollValue        = 0;
         playerUW.playerInventory.ContainerOffset = 0;
         Container currentContainerObj = playerUW.playerInventory.GetCurrentContainer();
         playerUW.playerInventory.currentContainer = currentContainerObj.ContainerParent;
         currentContainerObj.isOpenOnPanel         = false;
         //Close child containers as well
         CloseChildContainer(currentContainerObj);
         Container DestinationContainer = playerUW.playerInventory.GetCurrentContainer();
         if (playerUW.playerInventory.currentContainer == "Gronk")
         {
             GetComponent <UITexture>().mainTexture = playerUW.playerInventory.Blank;
         }
         else
         {
             GetComponent <UITexture>().mainTexture = DestinationContainer.transform.GetComponent <ObjectInteraction>().GetInventoryDisplay().texture;
         }
         for (int i = 0; i < 8; i++)
         {
             string sItem = DestinationContainer.GetItemAt(i);
             playerUW.playerInventory.SetObjectAtSlot(i + 11, sItem);
         }
     }
     else
     {
         if (UWCharacter.InteractionMode != UWCharacter.InteractionModePickup)
         {            //Only allow this to happen when in pickup mode.
             return;
         }
         //Move the contents out of the container into the parent.
         Container         CurrentContainer     = GameObject.Find(playerUW.playerInventory.currentContainer).GetComponent <Container>();
         Container         DestinationContainer = GameObject.Find(CurrentContainer.ContainerParent).GetComponent <Container>();
         ObjectInteraction item = GameObject.Find(playerUW.playerInventory.ObjectInHand).GetComponent <ObjectInteraction>();
         if (Container.TestContainerRules(DestinationContainer, 11))
         {
             if ((item.isQuant == false) || (item.isEnchanted))
             {
                 if (DestinationContainer.AddItemToContainer(playerUW.playerInventory.ObjectInHand))
                 {                    //Object has moved
                     playerUW.CursorIcon = playerUW.CursorIconDefault;
                     playerUW.playerInventory.ObjectInHand = "";
                 }
             }
             else
             {
                 if (DestinationContainer.AddItemMergedItemToContainer(item.gameObject))
                 {                    //Object has moved
                     playerUW.CursorIcon = playerUW.CursorIconDefault;
                     playerUW.playerInventory.ObjectInHand = "";
                 }
             }
         }
     }
 }