Ejemplo n.º 1
0
 protected void OnSelectCharacterItem(UICharacterItem ui)
 {
     if (!ui.Data.characterItem.NotEmptySlot())
     {
         CacheCharacterItemSelectionManager.DeselectSelectedUI();
         return;
     }
     if (uiItemDialog != null)
     {
         uiItemDialog.selectionManager = CacheCharacterItemSelectionManager;
         uiItemDialog.Setup(ui.Data, BasePlayerCharacterController.OwningCharacter, ui.IndexOfData);
         uiItemDialog.Show();
     }
 }
Ejemplo n.º 2
0
 public override void Hide()
 {
     // Close storage
     if (storageType != StorageType.None)
     {
         BasePlayerCharacterController.OwningCharacter.RequestCloseStorage();
     }
     // Clear data
     storageType = StorageType.None;
     weightLimit = 0;
     slotLimit   = 0;
     // Hide
     CacheCharacterItemSelectionManager.DeselectSelectedUI();
     base.Hide();
 }
Ejemplo n.º 3
0
        public void UpdateData()
        {
            if (storageType == StorageType.None)
            {
                return;
            }

            int selectedIdx = CacheCharacterItemSelectionManager.SelectedUI != null?CacheCharacterItemSelectionManager.IndexOf(CacheCharacterItemSelectionManager.SelectedUI) : -1;

            CacheCharacterItemSelectionManager.DeselectSelectedUI();
            CacheCharacterItemSelectionManager.Clear();
            totalWeight = 0;
            usedSlots   = 0;
            IList <CharacterItem> characterItems = BasePlayerCharacterController.OwningCharacter.StorageItems;

            CacheCharacterItemList.Generate(characterItems, (index, characterItem, ui) =>
            {
                UICharacterItem uiCharacterItem = ui.GetComponent <UICharacterItem>();
                uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.StorageItems), BasePlayerCharacterController.OwningCharacter, index);
                uiCharacterItem.Show();
                if (characterItem.NotEmptySlot())
                {
                    totalWeight += characterItem.GetItem().weight *characterItem.amount;
                    usedSlots++;
                }
                UICharacterItemDragHandler dragHandler = uiCharacterItem.GetComponentInChildren <UICharacterItemDragHandler>();
                if (dragHandler != null)
                {
                    dragHandler.SetupForStorageItems(uiCharacterItem);
                }
                CacheCharacterItemSelectionManager.Add(uiCharacterItem);
                if (selectedIdx == index)
                {
                    uiCharacterItem.OnClickSelect();
                }
            });
        }