示例#1
0
        private void RegisterConsumItem()
        {
            Consum hp1 = new Consum(1, 5, 100, 90, "1001", "hp1", "초급 체력포션", "hp +50", "potion", true, consumSpriteList[0], null);
            Consum mp1 = new Consum(1, 5, 100, 90, "1002", "mp1", "초급 마나포션", "mp +50", "potion", true, consumSpriteList[1], null);

            consumItemList.Add(hp1);
            consumItemList.Add(mp1);
        }
示例#2
0
        // 아이템 사용
        public void Use(InventorySlot usedSlot, SlotItem usedItem)
        {
            // 사용아이템일 때
            if (usedItem is ICommon)        //IUsable 인터페이스를 지원하는지 확인
            {
                ICommon usableItem = usedItem as ICommon;
                //사용 이벤트가 있을 경우 실행

                if (usableItem.Usable)
                {
                    usableItem.UseEvent?.Invoke(usedItem);
                    OnItemUsed?.Invoke(usedItem);
                }
            }

            // 장비템아이일 때
            else if (usedItem is IEquipment)
            {
                IEquipment equipment = usedItem as IEquipment;

                // 장착
                if (equipment.Usable)
                {
                    if (equipment.TargetSlot.Item == null)
                    {
                        Move(usedItem, equipment.TargetSlot);   // target Slot 지정안하면 오류
                    }
                    else
                    {
                        Switch(usedItem, equipment.TargetSlot.Item);
                    }

                    equipment.UseEvent?.Invoke(usedItem);
                    equipment.TargetSlot.slotManager.Refresh(usedItem.Tab);
                    OnItemUsed?.Invoke(usedItem);
                }
            }
            // 소비아이템일 때

            else if (usedItem is Consum)
            {
                Consum consum = usedItem as Consum;

                if (consum.Usable)
                {
                    // 개수 -1
                    usedItem.Count--;
                    if (usedItem.Count < 1)
                    {
                        usedItem.Tab.Remove(usedItem);
                    }


                    consum.UseEvent?.Invoke(usedItem);
                    OnItemUsed?.Invoke(usedItem);
                }
            }
        }
示例#3
0
        public static SlotItem ConsumItemClone(int index)
        {
            Consum newItem = new Consum(consumItemList[index].Count, consumItemList[index].MaxCount, consumItemList[index].BuyPrice
                                        , consumItemList[index].SellPrice, consumItemList[index].Id, consumItemList[index].Name
                                        , consumItemList[index].DisplayName, consumItemList[index].Description, consumItemList[index].Type
                                        , consumItemList[index].Usable, consumItemList[index].Icon, consumItemList[index].UseEvent);

            return(newItem);
        }