Exemplo n.º 1
0
        public virtual void CloseInventory()
        {
            if(isOpen)
            {
               if(! firstWindow.gameObject.activeSelf)
                {
                    for (int i = windows.Count - 1; i > 0; i--)
                    {
                        if (windows[i].ContainsPop_up())
                            windows[i].RemoveLastPop_up();
                        windows[i].gameObject.SetActive(false);

                    }
                }
            
                windows.Clear();
                currentEquipArea = null;
                currentWindow = null;
                firstWindow.gameObject.SetActive(false);
                isOpen = false;
                onOpenCloseInventory.Invoke(false);
                Time.timeScale = originalTimeScale;
                if (updatedTimeScale)
                    updatedTimeScale = false;
            }
         
        }
Exemplo n.º 2
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;
     }
 }
Exemplo n.º 3
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        = "";
            }
        }
Exemplo n.º 4
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
                }
            }
        }
Exemplo n.º 5
0
        public virtual void ControlWindowsInput()
        {
            // enable first window
            if ((windows.Count == 0 || windows[windows.Count - 1] == firstWindow))
            {
                if (!firstWindow.gameObject.activeSelf && openInventory.GetButtonDown() && canEquip)
                {                  
                    OpenInventory();
                    return;
                }

                else if (firstWindow.gameObject.activeSelf && (openInventory.GetButtonDown() || cancel.GetButtonDown()))
                {                   
                    CloseInventory();
                    return;
                }
            }
            if (!isOpen) return;
            // disable current window
            if(openInventory.GetButtonDown())
            {              
                CloseInventory();
                return;
            }
            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        
            }
        }