示例#1
0
        private void MakeShop()
        {
            InventoryTab ShopFirstTab  = TabManager.GetTab("ShopFirstTab");
            InventoryTab ShopSecondTab = TabManager.GetTab("ShopSecondTab");


            ShopFirstTab.Add(ItemData.ConsumItemClone(0));
            ShopFirstTab.Add(ItemData.ConsumItemClone(1));

            ShopSecondTab.Add(ItemData.EquipmentItemClone(0));
            ShopSecondTab.Add(ItemData.EquipmentItemClone(1));
            ShopSecondTab.Add(ItemData.EquipmentItemClone(2));
            ShopSecondTab.Add(ItemData.CommonItemClone(0));
            ShopSecondTab.Add(ItemData.CommonItemClone(1));


            InventoryTab InvenFirstTab = TabManager.GetTab("InvenFirstTab");

            InvenFirstTab.Add(ItemData.ConsumItemClone(0), 19);
            InvenFirstTab.Add(ItemData.EquipmentItemClone(0), 13);

            InventoryTab QuickFirstTab = TabManager.GetTab("QuickFirstTab");

            QuickFirstTab.Add(ItemData.EquipmentItemClone(0), 0);
            QuickFirstTab.Add(ItemData.ConsumItemClone(0), 5);
        }
示例#2
0
        //아이템 구매
        public static void Buy(ref int money, SlotItem item, InventoryTab targetTab, Action buyFailEvent = null, Action tabFullEvent = null)
        {
            if (item is ITradable)
            {
                ITradable tradableItem = item as ITradable;

                //아이템이 추가될 탭이 꽉 찼을 경우 이벤트 발생 및 종료
                if (targetTab.IsFull)
                {
                    tabFullEvent?.Invoke();
                    return;
                }

                //아이템 구매
                if (money >= tradableItem.BuyPrice)
                {
                    money -= tradableItem.BuyPrice;
                    targetTab.Add(item, true);
                }
                else
                {
                    buyFailEvent?.Invoke();  //돈이 부족할 경우 이벤트 실행및 종료
                }
            }
        }