Пример #1
0
 /// <summary>
 /// Set current window <see cref="vInventoryWindow"/> call automatically when Enabled
 /// </summary>
 /// <param name="inventoryWindow"></param>
 internal void SetCurrentWindow(vInventoryWindow inventoryWindow)
 {
     if (!windows.Contains(inventoryWindow))
     {
         windows.Add(inventoryWindow);
         if (currentWindow != null)
         {
             currentWindow.gameObject.SetActive(false);
         }
         currentWindow = inventoryWindow;
     }
 }
Пример #2
0
        void Start()
        {
            inventory = GetComponentInParent <vInventory>();

            if (equipSlots.Count == 0)
            {
                var equipSlotsArray = GetComponentsInChildren <vEquipSlot>(true);
                equipSlots = equipSlotsArray.vToList();
            }
            rootWindow = GetComponentInParent <vInventoryWindow>();
            foreach (vEquipSlot slot in equipSlots)
            {
                slot.onSubmitSlotCallBack   = OnSubmitSlot;
                slot.onSelectSlotCallBack   = OnSelectSlot;
                slot.onDeselectSlotCallBack = OnDeselect;
                slot.amountText.text        = "";
            }
        }
Пример #3
0
        public virtual void ControlWindowsInput()
        {
            // enable first window
            if ((windows.Count == 0 || windows[windows.Count - 1] == firstWindow))
            {
                if (!firstWindow.gameObject.activeSelf && openInventory.GetButtonDown() && canEquip)
                {
                    firstWindow.gameObject.SetActive(true);
                    isOpen = true;
                    onOpenCloseInventory.Invoke(true);

                    if (!updatedTimeScale)
                    {
                        updatedTimeScale  = true;
                        originalTimeScale = Time.timeScale;
                    }
                    Time.timeScale = timeScaleWhileIsOpen;
                }

                else if (firstWindow.gameObject.activeSelf && (openInventory.GetButtonDown() || cancel.GetButtonDown()))
                {
                    currentEquipArea = null;
                    firstWindow.gameObject.SetActive(false);
                    isOpen = false;
                    onOpenCloseInventory.Invoke(false);

                    Time.timeScale = originalTimeScale;
                    if (updatedTimeScale)
                    {
                        updatedTimeScale = false;
                    }
                }
            }
            if (!isOpen)
            {
                return;
            }
            // disable current window
            if ((windows.Count > 0 && windows[windows.Count - 1] != firstWindow) && cancel.GetButtonDown())
            {
                currentEquipArea = null;
                if (windows[windows.Count - 1].ContainsPop_up())
                {
                    windows[windows.Count - 1].RemoveLastPop_up();
                    return;
                }
                else
                {
                    windows[windows.Count - 1].gameObject.SetActive(false);
                    windows.RemoveAt(windows.Count - 1);// remove last window of the window list
                    if (windows.Count > 0)
                    {
                        windows[windows.Count - 1].gameObject.SetActive(true);
                        currentWindow = windows[windows.Count - 1];
                    }
                    else
                    {
                        currentWindow = null; // clear currentWindow if  window list count == 0
                    }
                }
            }
            // check if currenWindow  that was closed
            if (currentWindow != null && !currentWindow.gameObject.activeSelf)
            {
                // remove currentWindow of the window list
                if (windows.Contains(currentWindow))
                {
                    windows.Remove(currentWindow);
                }
                // set currentWindow if window list have more windows
                if (windows.Count > 0)
                {
                    windows[windows.Count - 1].gameObject.SetActive(true);
                    currentWindow = windows[windows.Count - 1];
                }
                else
                {
                    currentWindow = null;// clear currentWindow if  window list count == 0
                }
            }
        }