Пример #1
0
 public void Awake()
 {
     _items = new InventoryEntry[maxSize];
     onItemChangedCallback += checkFull;
     onSizeChangedCallback += checkFull;
     checkFull();
 }
Пример #2
0
        internal virtual void ReplaceWithFake(int type)
        {
            if (real && item.stack > 0)
            {
                //	Main.player[Main.myPlayer].QuickSpawnItem(RecipeBrowserWindow.lookupItemSlot.item.type, RecipeBrowserWindow.lookupItemSlot.item.stack);

                Player player = Main.player[Main.myPlayer];
                item.position = player.Center;
                Item item2 = player.GetItem(player.whoAmI, item, false, true);
                if (item2.stack > 0)
                {
                    int num = Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, item2.type, item2.stack, false, (int)item.prefix, true, false);
                    Main.item[num].newAndShiny = false;
                    if (Main.netMode == 1)
                    {
                        NetMessage.SendData(21, -1, -1, null, num, 1f, 0f, 0f, 0, 0, 0);
                    }
                }
                item = new Item();
            }

            item.SetDefaults(type);
            real = type == 0;
            backgroundTexture = real ? defaultBackgroundTexture : backgroundTextureFake;
            OnItemChanged?.Invoke();
        }
Пример #3
0
        public override void Click(UIMouseEvent evt)
        {
            Player player = Main.LocalPlayer;

            if (player.itemAnimation == 0 && player.itemTime == 0)
            {
                if (real)
                {
                    Item item = Main.mouseItem.Clone();
                    Main.mouseItem = this.item.Clone();
                    if (Main.mouseItem.type > 0)
                    {
                        Main.playerInventory = true;
                    }
                    this.item = item.Clone();
                }
                else
                {
                    item = Main.mouseItem.Clone();
                    Main.mouseItem.SetDefaults(0);
                    real = true;
                }
                if (item.type == 0)
                {
                    real = true;
                }
                OnItemChanged?.Invoke();
            }
            backgroundTexture = real ? defaultBackgroundTexture : backgroundTextureFake;
        }
Пример #4
0
    public int space = 10;  // Amount of item spaces

    //void Start()
    //{
    //    if (inventoryType == InventoryType.NULL)
    //        Debug.LogError("inventory type of " + name + " is null");
    //    else if (inventoryType == InventoryType.Player)
    //    {
    //        UI = UIController.instance.inventoryUI.GetComponent<UIforInventory>();
    //        SetInventoryToUI();
    //    }
    //    else if (inventoryType == InventoryType.Trader)
    //    {
    //        UI = UIController.instance.tradeUI.GetComponentInChildren<UIforInventory>();
    //        if (UI.inventory == null)
    //            SetInventoryToUI();
    //    }
    //}

    //public void SetInventoryToUI()
    //{
    //    if (inventoryType == InventoryType.Player)
    //    {
    //        UIController.instance.playerInventory = this;
    //    }
    //    else if (inventoryType == InventoryType.Trader)
    //    {
    //        UIController.instance.traderInventory = this;
    //    }
    //    UI.inventory = this;
    //    onItemChangedCallback += UI.UpdateUI;
    //    UI.UpdateUI();
    //}

    public void SetInventoryToUI()
    {
        if (inventoryType == InventoryType.NULL)
        {
            Debug.LogError("inventory type of " + name + " is null");
        }
        else if (inventoryType == InventoryType.Player)
        {
            UI = UIController.instance.inventoryUI.GetComponent <UIforInventory>();
            UIController.instance.playerInventory = this;
        }
        else if (inventoryType == InventoryType.Trader)
        {
            UI = UIController.instance.tradeUI.GetComponentInChildren <UIforInventory>();
            UIController.instance.traderInventory = this;
        }
        else if (inventoryType == InventoryType.Loot)
        {
            UI = UIController.instance.lootUI.GetComponentInChildren <UIforInventory>();
            UIController.instance.lootInventory = this;
        }
        UI.inventory           = this;
        onItemChangedCallback += UI.UpdateUI;
        UI.UpdateUI();
    }
Пример #5
0
        internal virtual void ReplaceWithFake(int type)
        {
            if (real && item.stack > 0)
            {
                //	Main.player[Main.myPlayer].QuickSpawnItem(RecipeBrowserWindow.lookupItemSlot.item.type, RecipeBrowserWindow.lookupItemSlot.item.stack);

                Player player = Main.player[Main.myPlayer];
                item.position = player.Center;
                Item item2 = player.GetItem(player.whoAmI, item, false, true);
                if (item2.stack > 0)
                {
                    int num = Item.NewItem((int)player.position.X, (int)player.position.Y, player.width, player.height, item2.type, item2.stack, false, (int)item.prefix, true, false);
                    Main.item[num].newAndShiny = false;
                    if (Main.netMode == 1)
                    {
                        NetMessage.SendData(21, -1, -1, null, num, 1f, 0f, 0f, 0, 0, 0);
                    }
                    else
                    {
                        // TODO: Detect PreSaveAndQuit only.
                        RecipeBrowser.instance.Logger.Warn("RecipeBrowser: You left an item in the recipe browser with a full inventory and have lost the item: " + item2.Name);
                    }
                }
                item = new Item();
            }

            item.SetDefaults(type);
            real = type == 0;
            backgroundTexture = real ? defaultBackgroundTexture : backgroundTextureFake;
            OnItemChanged?.Invoke();
        }
Пример #6
0
    void Start()
    {
        space_count = 0;
        slots       = new Item[space];
        items_count = new int[space];

        //Unequips items when items changed
        onItemChangedCallback += RefreshEquippedItem;
    }
Пример #7
0
    public void Move(int sourceIndex, int destIndex)
    {
        var destItem = _items[destIndex];

        _items[destIndex]   = _items[sourceIndex];
        _items[sourceIndex] = destItem;

        OnItemChanged?.Invoke(destIndex);
        OnItemChanged?.Invoke(sourceIndex);
    }
Пример #8
0
        public void Move(int sourceSlot, int destinationSlot)
        {
            var destinationItem = _items[destinationSlot];

            _items[destinationSlot] = _items[sourceSlot];
            _items[sourceSlot]      = destinationItem;

            OnItemChanged?.Invoke(destinationSlot);
            OnItemChanged?.Invoke(sourceSlot);
        }
Пример #9
0
 public Item UseItem(int index)
 {
     if (index < slots.Count)
     {
         Item item = slots[index];
         slots.Remove(slots[index]);
         OnItemChanged?.Invoke(this, EventArgs.Empty);
         return(item);
     }
     return(Item.Null);
 }
Пример #10
0
 public void AddItem(Item item)
 {
     if (slots.Count < Capacity)
     {
         slots.Add(item);
         OnItemChanged?.Invoke(this, EventArgs.Empty);
     }
     else
     {
         OnInventoryFull?.Invoke(this, EventArgs.Empty);
     }
 }
Пример #11
0
        public void Init()
        {
            equipmentManager = GameController.instance.playerManager.equipmentManager;
            equipmentManager.onItemUnequip += AddAfterUnequip;
            equipmentManager.onItemEquip   += Remove;

            onItemUse = null;
            onLoot    = null;
            onItemsChangedCallback = null;
            onLootEnd = null;

            defaultItemGameObject = Resources.Load <GameObject>("Equipments/EmptyItem");
        }
Пример #12
0
    public void SellEquipmentItem(Item item)
    {
        goldAmount += item.GetPrice();

        //reset index
        firstEmptyItemIndex = Math.Min(selectedItemIndex, firstEmptyItemIndex);

        //destroy
        itemList[selectedItemIndex] = null;
        OnItemChanged?.Invoke(this, new OnItemChangedArgs {
            index = selectedItemIndex
        });
        selectedItemIndex = -1;
    }
Пример #13
0
        public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
        {
            var follower = users[indexPath.Row];

            var cell = (FollowerCollectionViewCell)collectionView.DequeueReusableCell(FollowerCollectionViewCell.Key, indexPath);

            cell.UpdateCell(userId, follower.Id, follower.ImagePath, follower.Username, follower.UserTag);

            cell.DataContext.OnFollowAction = () =>
            {
                OnItemChanged?.Invoke(this, EventArgs.Empty);
            };

            return(cell);
        }
Пример #14
0
    public void SetItem(Item item)
    {
        if (_ghostItemGameObject != null)
        {
            Destroy(_ghostItemGameObject);
        }

        _currentItem = item;

        if (item != null)
        {
            CreateGhost(item);
        }

        OnItemChanged?.Invoke(_currentItem);
    }
Пример #15
0
    public void SetItem(Item item)
    {
        //Unsubrscribe from old item
        if (currentItem != null)
        {
            currentItem.OnItemChanged -= CurrentItem_OnItemChanged;
        }
        currentItem = item;

        //Subscribe to new item
        if (currentItem != null)
        {
            currentItem.OnItemChanged += CurrentItem_OnItemChanged;
        }
        OnItemChanged?.Invoke(item);
    }
Пример #16
0
        public void SetItem(GameObject item)
        {
            if (_ghostRenderer != null)
            {
                Destroy(_ghostItem);
            }

            _currentItem = item;

            _ghostItem              = Instantiate(item);
            _ghostRenderer          = _ghostItem.GetComponentInChildren <Renderer>();
            _ghostRenderer.material = _ghostMaterial;
            _ghostRenderer.enabled  = false;

            OnItemChanged?.Invoke(item.name);
        }
Пример #17
0
 /// <summary>
 /// Returns the overflowing amount.
 /// </summary>
 public int ModifyAmount(int amount)
 {
     if (TryGetInformation(out ItemSO info) && info.IsStackable)
     {
         this.amount += amount;
         int overflow = this.amount - info.MaxStack;
         if (overflow < 0)
         {
             overflow = 0;
         }
         this.amount -= overflow;
         OnItemChanged?.Invoke(this);
         return(overflow);
     }
     Debug.Log($"{itemName} is missing an SO");
     return(amount);
 }
Пример #18
0
    // Use this for initialization
    void Start()
    {
        inventory              = Inventory.instance;
        onItemChangedCallback += UpdateUI;

        boxCollider      = GetComponent <BoxCollider>();
        boxCollider.size = initialBoxSize;
        //Debug.Log(boxCollider.size); 000이 뜨는데 왜이러는건지?

        bagCanvas.SetActive(false);
        isBagCalled = false;

        slots       = itemsParents.GetComponentsInChildren <InventorySlot>();
        audioSource = GetComponent <AudioSource>();

        currentCanvasLocalPosition = transform.localPosition;
        currentCanvasLocalRotation = transform.localRotation;
    }
        public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
        {
            var post       = posts[indexPath.Row];
            var postAuthor = userReads.Get(post.UserId);

            var cell = (FeedCollectionViewCell)collectionView.DequeueReusableCell(FeedCollectionViewCell.Key, indexPath);

            cell.UpdateCell(post.Id, userId, postAuthor.Id, postAuthor.ImagePath, postAuthor.UserTag, post.ImagePath, post.Description, post.Likes, post.UsesURL);

            cell.DataContext.DeleteItemAction = () =>
            {
                OnItemChanged?.Invoke(this, EventArgs.Empty);
            };

            cell.DataContext.LikeAction = () =>
            {
                OnItemChanged?.Invoke(this, EventArgs.Empty);
            };

            return(cell);
        }
Пример #20
0
 protected void OnSelectChanged(UIChangeEventArgs e)
 {
     //nao sei pq, mas nao funciona se eu deixo o value=@eItem
     Console.WriteLine("alterou combo item");
     SelectedValue = ConverterHelper.TryChangeType <ValueType>(e.Value, out var value) ? value : default;
     SelectedValueChanged?.Invoke(SelectedValue);
     if (IsFirstItemNull && e.Value == null)
     {
         OnItemChanged?.Invoke(null);
         return;
     }
     if (Items != null)
     {
         foreach (object obj in Items)
         {
             var valor = ReflectionHelper.GetPropertyValue(obj, ValueField);
             if (!valor.Equals(e.Value))
             {
                 continue;
             }
             OnItemChanged?.Invoke(obj);
             break;
         }
     }
     else if (ComboItems != null)
     {
         foreach (EComboBoxItem item in ComboItems)
         {
             if (item.Value != e.Value as string)
             {
                 continue;
             }
             OnItemChanged?.Invoke(item);
             break;
         }
     }
 }
Пример #21
0
    public void SellStackableItem(Item item, int amount)
    {
        IStackableItem stackableItem  = item as IStackableItem;
        int            originalAmount = stackableItem.GetAmount();

        if (originalAmount == amount)
        {
            goldAmount += stackableItem.GetTotalPrice();

            //update index
            firstEmptyItemIndex = Math.Min(selectedItemIndex, firstEmptyItemIndex);

            //update link
            if (null != stackableItem.GetPrevSameItem())
            {
                IStackableItem prevStameItem = stackableItem.GetPrevSameItem();
                prevStameItem.SetNextSameItem(stackableItem.GetNextSameItem());
            }
            if (null != stackableItem.GetNextSameItem())
            {
                IStackableItem nextSameItem = stackableItem.GetNextSameItem();
                nextSameItem.SetPrevSameItem(stackableItem.GetPrevSameItem());
            }
            //destory
            itemList[selectedItemIndex] = null;
            OnItemChanged?.Invoke(this, new OnItemChangedArgs {
                index = selectedItemIndex
            });
            selectedItemIndex = -1;
        }
        else
        {
            goldAmount += stackableItem.GetTotalPrice();
            stackableItem.SetAmount(originalAmount - amount);
        }
    }
Пример #22
0
 /// <summary>
 /// Assigns an item to the slot.
 /// </summary>
 public void SetItem(InventoryItem item)
 {
     Item = item;
     OnItemChanged?.Invoke(item);
 }
Пример #23
0
 public void SetItemNumber(GItem item, float number)
 {
     item.CurrentAmount = (int)number;
     OnItemChanged.Invoke(item);
 }
Пример #24
0
 public void SetArmorStats(Quipment quipment)
 {
     quipmentArmor = quipment.defenceMof;
     totalArmor   += quipmentArmor;
     OnItemChanged?.Invoke(this, EventArgs.Empty);
 }
Пример #25
0
 public void SetWeaponStats(Weapon weapon)
 {
     weapomAttack = weapon.damageMod;
     totalDamage += weapomAttack;
     OnItemChanged?.Invoke(this, EventArgs.Empty);
 }
Пример #26
0
 public void InvokeItemChanged() => OnItemChanged?.Invoke();
Пример #27
0
 private void NetListOnOnItemChanged(UIComponent component, NetTypeItemEventArgs value)
 {
     OnItemChanged?.Invoke(this, value);
 }
Пример #28
0
 private void CurrentItem_OnItemChanged(Item item)
 {
     OnItemChanged?.Invoke(item);
 }
Пример #29
0
 private void ItemChanged(SyncList <Item> .Operation op, int itemIndex)
 {
     OnItemChanged?.Invoke(op, itemIndex);
 }
Пример #30
0
 protected virtual void InvokeOnItemCellChanged(PackageItemChangedInfo changedInfo)
 {
     OnItemChanged?.Invoke(changedInfo);
 }