Пример #1
0
 void OnGUI()
 {
     if (ShowInv)   //vykreslení inventáře
     {
         //_inventorySettings.DrawBackGround();
         _inventorySettings.DrawEmptyItems();
         _armorSettings.DrawEmptyItems();
         _inventorySettings.DrawFullItems();
         _armorSettings.DrawFullItems();
         if (InventorySettings.InventoryItemList.Any(s => s.Rect.Contains(MyInput.CurrentMousePosition())))
         {
             _inventorySettings.DrawOnHover();
         }
         if (ArmorSettings.ArmorItemList.Any(s => s.Rect.Contains(MyInput.CurrentMousePosition())))
         {
             _armorSettings.DrawOnHover();
         }
     }
     if (ShowDrop)  //vykreslení dropu
     {
         //_drop.DrawEmptyItems();
         _drop.DrawFullItems();
     }
     if (ShowInv)   //kvůli vykreslovacím vrstvám
     {
         _slotManagement.DrawMovingItem();
         _armorSettings.DrawItemInfo();
         _inventorySettings.DrawItemInfo();
         _slotManagement.DrawStacking();
     }
     if (ShowDrop)  //kvůli vykreslovacím vrstvám
     {
         _drop.DrawItemInfo();
     }
 }
Пример #2
0
 public void DrawStacking()
 {
     //vykreslení stacků
     if (_eDragAndDrop == EDragAndDrop.Stack)
     {
         GUI.Box(new Rect(MyInput.CurrentMousePosition().x - 20, MyInput.CurrentMousePosition().y - 20, 20, 20), _click.ToString());
     }
 }
Пример #3
0
 public void DrawStatus()
 {
     if (!Grabed)
     {
         if (Rect.Contains(MyInput.CurrentMousePosition()))
         {
             GUI.Box(DrawTreatment.ScreenRectThreatment(new Rect(Rect.xMax, Rect.yMax, 100, 100)), Name + "\n" + Type + "\n" + Subtype);
         }
     }
 }
Пример #4
0
 private void SetItemGrabed(SlotItem slotItem)
 {
     _grabedItem   = slotItem.Item;                                                             //nastavení grab itemu na slotitem
     _previousSlot = slotItem;                                                                  //nastavení předchozího slotu
     SetDropStats(slotItem, _grabedItem, false, true);
     slotItem.Occupied = false;                                                                 //inventarový item již neni obsazen
     _grabPosition     = DeltaPosition(slotItem.Item.Position, MyInput.CurrentMousePosition()); //nastavení defaultní pozice kvůli posunování textury na pozici kurzoru
     _eDragAndDrop     = EDragAndDrop.Drag;                                                     //nastavení na statu na drag
     SetPickStats(slotItem.Item, MyInput.CurrentMousePosition() - _grabPosition);
 }
Пример #5
0
 private void DropService(List <SlotItem> slotList)
 {
     if (slotList.Any(s => s.Rect.Overlaps(_grabedItem.Rect)))
     {
         if (slotList.Any(s => s.Rect.Contains(MyInput.CurrentMousePosition()) && !s.Occupied && CanIPutToSlot(s, _grabedItem)))
         {   //přidání do inventáře
             DropItem(slotList.Find(s => s.Rect.Contains(MyInput.CurrentMousePosition()) && !s.Occupied && CanIPutToSlot(s, _grabedItem)), EWhereDrop.Inventory);
         }
         else if (slotList.Any(s => s.Rect.Contains(MyInput.CurrentMousePosition()) && s.Occupied && CanWeStack(s.Item, _grabedItem)))
         {   //stackování
             DropItem(slotList.Find(s => s.Rect.Contains(MyInput.CurrentMousePosition()) && s.Occupied && CanWeStack(s.Item, _grabedItem)), EWhereDrop.Stack);
         }
         else
         {                                             //jinak hození na předchozí pozici
             _previousSlot.Item = _grabedItem;         //pozice je předchozí
             _eDragAndDrop      = EDragAndDrop.None;   //nastavení na none
             SetDropStats(_previousSlot, _grabedItem); //nastavení příslušných atributů
             _grabedItem = null;
             AddRemoveStats(_previousSlot);
         }
     }
 }
Пример #6
0
 public virtual void DrawOnHover()
 {
     if (_itemList == null)
     {
         return;
     }
     foreach (SlotItem inventoryItem in _itemList.Where(inventoryItem => inventoryItem.Rect.Contains(MyInput.CurrentMousePosition())))
     {
         inventoryItem.DrawOnHower();
     }
 }
Пример #7
0
        public void MoveBetweenTwoLists(params List <SlotItem>[] listOfLists)
        {
            if (listOfLists.Where(s => s != null).All(s => s.Count > 0))
            {
                if (Input.GetMouseButtonDown(0) && (_eDragAndDrop == EDragAndDrop.Pick || _eDragAndDrop == EDragAndDrop.Stack)) //uchpen předmět
                {
                    foreach (List <SlotItem> slotList in listOfLists.Where(s => s != null).Where(s => s.Count > 0))
                    {
                        if (Input.GetKey(KeyCode.LeftShift) && slotList.Any(s => s.Rect.Contains(MyInput.CurrentMousePosition()) && s.Item != null && !s.Item.Grabed))
                        {
                            _eDragAndDrop = EDragAndDrop.Stack;
                            _click++;                                                                                                                  //přičítání počtu kliků
                            SlotItem actSlotItem = slotList.Find(s => s != null && s.Rect.Contains(MyInput.CurrentMousePosition()) && s.Item != null); //najdení slotu itemů
                            Item     newItem     = new Item(actSlotItem.Item);                                                                         //vytvoření nového itemu
                            _grabPosition = DeltaPosition(actSlotItem.Position, MyInput.CurrentMousePosition());
                            if (actSlotItem.Item.ActualStack > 0)
                            {
                                newItem.ActualStack = _click;       //zápis stacků do itemu
                                actSlotItem.Item.ActualStack--;     //odečtení staků
                            }
                            if (actSlotItem.Item.ActualStack == 0)
                            {
                                RemoveItem(actSlotItem); //odstraň item
                            }
                            _grabedItem = newItem;       //nastav jako uchycený item
                            SetPickStats(newItem, MyInput.CurrentMousePosition() - _grabPosition);
                        }
                        //sebrání itemu na který bylo kliknuto
                        else if (slotList.Any(s => s.Rect.Contains(MyInput.CurrentMousePosition()) && s.Item != null && !s.Item.Grabed) && _grabedItem == null)
                        {
                            SetItemGrabed(slotList.Find(s => s != null && s.Rect.Contains(MyInput.CurrentMousePosition()) && s.Item != null));
                        }
                    }
                }
                else if (Input.GetKeyUp(KeyCode.LeftShift) && _eDragAndDrop == EDragAndDrop.Stack)
                {
                    //pokud pustím shift a stackuju
                    _eDragAndDrop = EDragAndDrop.Drop;
                    _click        = 0;
                }

                if (_eDragAndDrop == EDragAndDrop.Drop)
                {
                    //neustálé nastavování hodnot
                    SetPickStats(_grabedItem, MyInput.CurrentMousePosition() - _grabPosition);
                }
                if (Input.GetMouseButtonUp(0) && _eDragAndDrop == EDragAndDrop.Drag)
                {
                    //pokud neni zmáčknuto tlačítko myši a je drag
                    _eDragAndDrop = EDragAndDrop.Drop;
                    AddRemoveStats(_previousSlot, false);
                }
                else if (Input.GetMouseButtonDown(0) && _eDragAndDrop == EDragAndDrop.Drop)
                {
                    bool saved = false;
                    foreach (List <SlotItem> slotList in listOfLists.Where(s => s != null))
                    {
                        //výběr ze všech listů které nejsou null a obsahují kurzor(kolidují s rectem)
                        if (_grabedItem != null)
                        {
                            if (
                                slotList.Any(s => s.Rect.Contains(MyInput.CurrentMousePosition()) || s.Rect.Overlaps(_grabedItem.Rect)))
                            {
                                saved = true;
                                DropService(slotList);
                            }
                        }
                    }
                    if (!saved && _eDragAndDrop != EDragAndDrop.Drag)
                    {   //ošetření aby nebylo drag(tzn. pokud budu dávat na stack a ten stack bude neprázdný a zbydou mi itemy tak je to nezahodí)
                        _eDragAndDrop = EDragAndDrop.None;
                        RemoveItem(_previousSlot);
                    }
                }
                else if (_eDragAndDrop == EDragAndDrop.None)
                {
                    //pokud je state none automaticky nastaví na pick...
                    _eDragAndDrop = EDragAndDrop.Pick;
                }
            }
        }
Пример #8
0
 public void InventoryInteract()
 {
     if (Input.GetMouseButtonDown(1))
     {
         SlotItem slotItem = InventorySettings.InventoryItemList.Find(s => s.Rect.Contains(MyInput.CurrentMousePosition()));
         if (slotItem != null)
         {
             if (slotItem.Item != null)
             {
                 if (slotItem.Item.Type == EType.Consumable)
                 {
                     Player.OnAddCurrentHealth(slotItem.Item.ItemStats[0].Value);
                     if (!StackUnderflow(slotItem.Item, 1))
                     {
                         slotItem.Item.ActualStack--;
                     }
                     else
                     {
                         slotItem.Occupied = false;
                         slotItem.Item     = null;
                     }
                 }
             }
         }
     }
 }