Exemplo n.º 1
0
        static private void ChangeSorting(Players.Data player)
        {
            // Cache
            Transform stashPanelHolder           = GetStashPanel(player.UI);
            InventoryContentDisplay inventory    = GetPlayerStashInventoryPanel(stashPanelHolder).GetComponent <InventoryContentDisplay>();
            ContainerDisplay        chestDisplay = GetChestStashInventoryPanel(stashPanelHolder).GetComponent <ContainerDisplay>();

            // Sort
            ItemListDisplay.SortingType nextSorting = default;
            switch (chestDisplay.m_lastSortingType)
            {
            case ItemListDisplay.SortingType.ByList: nextSorting = ItemListDisplay.SortingType.ByWeight; break;

            case ItemListDisplay.SortingType.ByWeight: nextSorting = ItemListDisplay.SortingType.ByDurability; break;

            case ItemListDisplay.SortingType.ByDurability: nextSorting = ItemListDisplay.SortingType.ByList; break;
            }
            foreach (var containerDisplay in new[] { inventory.m_pouchDisplay, inventory.m_bagDisplay, chestDisplay })
            {
                containerDisplay.SortBy(nextSorting);
            }
            UpdateStashName(player);

            // Select first
            GameObject selectedObject = EventSystem.current.GetCurrentSelectedGameObject(player.ID);

            if (selectedObject != null &&
                selectedObject.TryGetComponent(out ItemDisplay currentItem) &&
                currentItem.ParentItemListDisplay != null)
            {
                currentItem.ParentItemListDisplay.m_assignedDisplays.First().OnSelect();
            }
        }
Exemplo n.º 2
0
    void Awake()
    {
        if (myContainerDisplay == null)
        {
            myContainerDisplay = gameObject.GetComponentInChildren<ContainerDisplay>();
        }

        if (myContainerDisplay == null)
        {
            myContainerDisplay = gameObject.GetComponent<ContainerDisplay>();
        }

        startPos = this.transform.localPosition;
        UpdatePos();


        if (myContainerDisplay != null)
        {
            if (myContainerDisplay.IsWindowActive())
                this.transform.localPosition = inPos;
            else
                this.transform.localPosition = outPos;
        }

        if (tween == null)
        {
            tween = this.GetComponent<TweenPosition>();
            tween.enabled = false;
        }
    }
Exemplo n.º 3
0
        static private void SwitchToStash(Players.Data player)
        {
            if (EventSystem.current.GetCurrentSelectedGameObject(player.ID).TryGetComponent(out ItemDisplay currentItem) &&
                currentItem.m_refItem == null)
            {
                return;
            }

            // Cache
            ContainerDisplay   chest      = GetChestStashInventoryPanel(GetStashPanel(player.UI)).GetComponent <ContainerDisplay>();
            List <ItemDisplay> chestItems = chest.m_assignedDisplays;
            int currentID = chestItems.IndexOf(currentItem);

            // Execute
            if (currentID >= chestItems.Count - 1)
            {
                chestItems.First().OnSelect();
            }
            else if (currentID >= 0)
            {
                int nextID = currentID + chestItems.Count / 2;
                if (chestItems.IsIndexValid(nextID))
                {
                    chestItems[nextID].OnSelect();
                }
                else
                {
                    chestItems.Last().OnSelect();
                }
            }
            else if (chestItems.IsNotEmpty())
            {
                chestItems.First().OnSelect();
            }
        }
Exemplo n.º 4
0
    void Awake()
    {
        if (myContainerDisplay == null)
        {
            myContainerDisplay = gameObject.GetComponentInChildren <ContainerDisplay>();
        }

        if (myContainerDisplay == null)
        {
            myContainerDisplay = gameObject.GetComponent <ContainerDisplay>();
        }

        startPos = this.transform.localPosition;
        UpdatePos();


        if (myContainerDisplay != null)
        {
            if (myContainerDisplay.IsWindowActive())
            {
                this.transform.localPosition = inPos;
            }
            else
            {
                this.transform.localPosition = outPos;
            }
        }

        if (tween == null)
        {
            tween         = this.GetComponent <TweenPosition>();
            tween.enabled = false;
        }
    }
Exemplo n.º 5
0
        public void TestContainerDisplay()
        {
            Serial serial = 0x1000;
            ushort gumpId = 100;

            var expected = new ContainerDisplay(serial, gumpId).Compile();

            using var ns = PacketTestUtilities.CreateTestNetState();
            ns.SendDisplayContainer(serial, gumpId);

            var result = ns.SendPipe.Reader.TryRead();

            AssertThat.Equal(result.Buffer[0].AsSpan(0), expected);
        }
Exemplo n.º 6
0
        public void TestContainerDisplay()
        {
            Serial serial = 0x1000;
            ushort gumpId = 100;

            var data = new ContainerDisplay(serial, gumpId).Compile();

            Span <byte> expectedData = stackalloc byte[7];
            var         pos          = 0;

            expectedData.Write(ref pos, (byte)0x24); // Packet ID
            expectedData.Write(ref pos, serial);
            expectedData.Write(ref pos, gumpId);

            AssertThat.Equal(data, expectedData);
        }
Exemplo n.º 7
0
        static private void UpdateStashName(Players.Data player)
        {
            // Cache
            Transform        stashPanelHolder = GetStashPanel(player.UI);
            ContainerDisplay chestDisplay     = GetChestStashInventoryPanel(stashPanelHolder).GetComponent <ContainerDisplay>();
            Text             stashTitle       = GetChestStashTitle(stashPanelHolder).GetComponent <Text>();

            // Execute
            stashTitle.text = "Stash";
            switch (chestDisplay.m_lastSortingType)
            {
            case ItemListDisplay.SortingType.ByList: break;

            case ItemListDisplay.SortingType.ByWeight: stashTitle.text += "<color=lime> (sorted by Weight)</color>"; break;

            case ItemListDisplay.SortingType.ByDurability: stashTitle.text += "<color=orange> (sorted by Durability)</color>"; break;
            }
        }
Exemplo n.º 8
0
 void Awake()
 {
     containerDisplay = gameObject.GetComponent <ContainerDisplay>();
     Debug.Log(containerDisplay);
 }
Exemplo n.º 9
0
 void Awake()
 {
     myContainer = GetComponent<ContainerDisplay>();
 }
Exemplo n.º 10
0
 void Awake()
 {
     myContainer = GetComponent <ContainerDisplay>();
 }
Exemplo n.º 11
0
 void Awake()
 {
     containerDisplay = gameObject.GetComponent<ContainerDisplay>();
     Debug.Log(containerDisplay);
 }