Example #1
0
        public void SetData(NewItem stack, ButtonArgument arg = null)
        {
            this.stack = stack;
            onPointerEvent.RemoveAllListeners();
            CommonAttributes atr = stack.GetAttribute <CommonAttributes>();

            if (atr)
            {
                this.image.sprite = atr.GetSprite();
            }


            if (arg != null)
            {
                foreach (UnityAction argument in arg.onClickCallback)
                {
                    onPointerEvent.AddListener(argument);
                }
            }
        }
Example #2
0
        public void AddItem(NewItem itm)
        {
            CommonAttributes attr = itm.GetAttribute <CommonAttributes>();

            if (attr && attr.isStackable)
            {
                int index = Items.FindIndex(a => a.item == itm);
                if (index != -1)
                {
                    items[index].amount++;
                }
                if (items[index].amount <= 0)
                {
                    items.Add(new ItemStack(itm));
                }
            }
            else
            {
                items.Add(new ItemStack(itm));
            }
        }