Ejemplo n.º 1
0
        public IEnumerator Refresh()
        {
            void RefreshInventoryAction(
                EzInventory inventory,
                List <EzItemSet> itemSets
                )
            {
                if (inventory.InventoryName != _inventoryModel.Name)
                {
                    return;
                }

                _inventory = inventory;
                _itemSets  = itemSets;
                _itemSets.Sort((o1, o2) => o1.SortValue != o2.SortValue ? o1.SortValue - o2.SortValue : (int)(o2.Count - o1.Count));

                _onGetInventory.RemoveListener(RefreshInventoryAction);

                onWatchInventoryEvent.Invoke(_inventory, _itemSets);
            }

            _onGetInventory.AddListener(RefreshInventoryAction);
            yield return(InventoryController.GetInventory(
                             _client,
                             _session,
                             _inventoryNamespaceName,
                             _inventoryModel.Name,
                             _onGetInventory,
                             _onError
                             ));
        }
Ejemplo n.º 2
0
        public void OnChangeInventory(
            EzInventory inventory,
            List <EzItemSet> itemSets
            )
        {
            for (var i = 0; i < gridLayoutGroup.transform.childCount; i++)
            {
                Destroy(gridLayoutGroup.transform.GetChild(i).gameObject);
            }

            foreach (var itemSet in _watcher.ItemSets)
            {
                var item = Instantiate(inventoryItemPrefab, gridLayoutGroup.transform);
                item.Initialize(
                    itemSet
                    );
                item.onClickItem.AddListener(OnClickItem);
            }

            for (var i = _watcher.ItemSets.Count; i < inventory.CurrentInventoryMaxCapacity; i++)
            {
                Instantiate(inventoryItemEmptyPrefab, gridLayoutGroup.transform);
            }

            capacity.text =
                $"Capacity: {inventory.CurrentInventoryCapacityUsage} / {inventory.CurrentInventoryMaxCapacity}";
        }
Ejemplo n.º 3
0
        public void OnChangeInventory(
            EzInventory unit,
            List <EzItemSet> itemSets
            )
        {
            for (var i = 0; i < gridLayoutGroup.transform.childCount; i++)
            {
                Destroy(gridLayoutGroup.transform.GetChild(i).gameObject);
            }

            foreach (var itemSet in _watcher.ItemSets)
            {
                var item = Instantiate(unitItemPrefab, gridLayoutGroup.transform);
                item.Initialize(
                    _watcher.ItemModels.First(itemModel => itemModel.Name == itemSet.ItemName),
                    itemSet
                    );
                item.onClickItem.AddListener(OnClickItem);
                item.gameObject.SetActive(true);
            }

            for (var i = _watcher.ItemSets.Count; i < unit.CurrentInventoryMaxCapacity; i++)
            {
                var item = Instantiate(unitItemEmptyPrefab, gridLayoutGroup.transform);
                item.gameObject.SetActive(true);
            }

            capacity.text =
                $"Capacity: {unit.CurrentInventoryCapacityUsage} / {unit.CurrentInventoryMaxCapacity}";
        }
Ejemplo n.º 4
0
 public EzGetInventoryResult(
     GetInventoryResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzInventory(result.item);
     }
 }
Ejemplo n.º 5
0
 public void OnChangeGold(
     EzInventory inventory,
     List <EzItemSet> itemSet
     )
 {
     if (_watcher.ItemSets == null || _watcher.ItemSets.Count == 0)
     {
         amount.text = "0 G";
     }
     else
     {
         amount.text = $"{_watcher.ItemSets[0].Count} G";
     }
 }
Ejemplo n.º 6
0
 public EzGetItemResult(
     GetItemSetResult result
     )
 {
     Items = new List <EzItemSet>();
     foreach (var item_ in result.items)
     {
         Items.Add(new EzItemSet(item_));
     }
     if (result.itemModel != null)
     {
         ItemModel = new EzItemModel(result.itemModel);
     }
     if (result.inventory != null)
     {
         Inventory = new EzInventory(result.inventory);
     }
 }
Ejemplo n.º 7
0
 public EzGetItemWithSignatureResult(
     GetItemWithSignatureResult result
     )
 {
     Items = new List <EzItemSet>();
     foreach (var item_ in result.items)
     {
         Items.Add(new EzItemSet(item_));
     }
     if (result.itemModel != null)
     {
         ItemModel = new EzItemModel(result.itemModel);
     }
     if (result.inventory != null)
     {
         Inventory = new EzInventory(result.inventory);
     }
     Body      = result.body;
     Signature = result.signature;
 }
Ejemplo n.º 8
0
        private void AcquireAction(
            EzInventory inventory,
            List <EzItemSet> itemSets,
            int acquireValue
            )
        {
            if (inventory.InventoryName != _inventoryModel.Name)
            {
                return;
            }

            _inventory = inventory;
            foreach (var itemSet in itemSets)
            {
                _itemSets = _itemSets.Where(item => item.Name != itemSet.Name).ToList();
                _itemSets.Add(itemSet);
            }
            _itemSets.Sort((o1, o2) => o1.SortValue != o2.SortValue ? o1.SortValue - o2.SortValue : (int)(o2.Count - o1.Count));

            onWatchInventoryEvent.Invoke(_inventory, _itemSets);
        }
Ejemplo n.º 9
0
        public void OnChangeInventory(
            EzInventory unit,
            List <EzItemSet> itemSets
            )
        {
            for (var i = 0; i < gridLayoutGroup.transform.childCount; i++)
            {
                Destroy(gridLayoutGroup.transform.GetChild(i).gameObject);
            }

            foreach (var itemSet in _unitWatcher.ItemSets)
            {
                var item = Instantiate(unitItemPrefab, gridLayoutGroup.transform);
                item.Initialize(
                    _unitWatcher.ItemModels.First(itemModel => itemModel.Name == itemSet.ItemName),
                    itemSet
                    );
                if (_form != null && _form.Slots.Select(slot => slot?.PropertyId).Contains(itemSet.ItemSetId))
                {
                    Instantiate(usingPrefab, item.transform);
                }
                else
                {
                    item.onClickItem.AddListener(OnClickItem);
                }

                item.gameObject.SetActive(true);
            }

            for (var i = _unitWatcher.ItemSets.Count; i < unit.CurrentInventoryMaxCapacity; i++)
            {
                var item = Instantiate(unitItemEmptyPrefab, gridLayoutGroup.transform);
                item.gameObject.SetActive(true);
            }

            capacity.text =
                $"Capacity: {unit.CurrentInventoryCapacityUsage} / {unit.CurrentInventoryMaxCapacity}";
        }