Esempio n. 1
0
        void Update()
        {
            pause_panel.SetVisible(TheGame.Get().IsPausedByPlayer());

            foreach (PlayerControls controls in PlayerControls.GetAll())
            {
                if (controls.IsPressPause() && !TheGame.Get().IsPausedByPlayer())
                {
                    TheGame.Get().Pause();
                }
                else if (controls.IsPressPause() && TheGame.Get().IsPausedByPlayer())
                {
                    TheGame.Get().Unpause();
                }
            }

            //Gamepad auto focus
            UISlotPanel focus_panel = UISlotPanel.GetFocusedPanel();

            if (focus_panel != pause_panel && TheGame.Get().IsPausedByPlayer() && PlayerControls.IsAnyGamePad())
            {
                pause_panel.Focus();
            }
            if (focus_panel == pause_panel && !TheGame.Get().IsPausedByPlayer())
            {
                UISlotPanel.UnfocusAll();
            }
        }
Esempio n. 2
0
        protected override void Update()
        {
            base.Update();

            if (IsVisible() && character != null && select != null)
            {
                float dist = (interact_pos - character.transform.position).magnitude;
                if (dist > select.use_range * 1.2f)
                {
                    Hide();
                }
            }

            if (IsVisible())
            {
                Vector3 dir = TheCamera.Get().GetFacingFront();
                transform.rotation = Quaternion.LookRotation(dir, Vector3.up);
            }

            if (IsVisible() && select == null)
            {
                Hide();
            }

            //Auto focus
            UISlotPanel focus_panel = UISlotPanel.GetFocusedPanel();

            if (focus_panel != this && IsVisible() && PlayerControls.IsAnyGamePad())
            {
                Focus();
            }
        }
        public UISlot GetSelectedSlot()
        {
            UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel();
            UISlot      selected_slot  = selected_panel?.GetSelectSlot();

            return(selected_slot);
        }
        void Update()
        {
            PlayerControls controls = PlayerControls.Get(player_id);

            if (!controls.IsGamePad())
            {
                return;
            }

            if (controls.IsUIPressLeft())
            {
                Navigate(Vector2.left);
            }
            else if (controls.IsUIPressRight())
            {
                Navigate(Vector2.right);
            }
            else if (controls.IsUIPressUp())
            {
                Navigate(Vector2.up);
            }
            else if (controls.IsUIPressDown())
            {
                Navigate(Vector2.down);
            }

            //Stop navigate if out of focus
            UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel();

            if (selected_panel != null && !selected_panel.IsVisible())
            {
                StopNavigate();
            }
            else if (selected_panel != null && selected_panel.GetSelectSlot() != null && !selected_panel.GetSelectSlot().IsVisible())
            {
                StopNavigate();
            }

            //Controls
            if (controls.IsPressUISelect())
            {
                OnPressSelect();
            }

            if (controls.IsPressUIUse())
            {
                OnPressUse();
            }

            if (controls.IsPressUICancel())
            {
                OnPressCancel();
            }

            if (controls.IsPressAttack())
            {
                OnPressAttack();
            }
        }
        public bool IsPanelFocusItem()
        {
            UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel();
            UISlot      slot           = selected_panel?.GetSelectSlot();
            ItemSlot    islot          = (slot != null && slot is ItemSlot) ? (ItemSlot)slot : null;

            return(islot != null && islot.GetItem() != null);
        }
        public int GetSelectedIndex()
        {
            UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel();

            if (selected_panel != null)
            {
                return(selected_panel.selection_index);
            }
            return(-1);
        }
        private void OnPressAttack()
        {
            UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel();

            if (selected_panel is InventoryPanel || selected_panel is EquipPanel)
            {
                ItemSlotPanel.CancelSelectionAll();
                UISlotPanel.UnfocusAll();
            }
        }
        private void OnPressUse()
        {
            UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel();
            UISlot      selected_slot  = selected_panel?.GetSelectSlot();

            if (selected_slot != null)
            {
                selected_slot.KeyPressUse();
            }
        }
        protected override void Update()
        {
            base.Update();

            //Auto focus
            UISlotPanel focus_panel = UISlotPanel.GetFocusedPanel();

            if (focus_panel != this && IsVisible() && PlayerControls.IsAnyGamePad())
            {
                prev_panel = focus_panel;
                Focus();
            }
        }
        private void OnPressCancel()
        {
            UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel();
            UISlot      selected_slot  = selected_panel?.GetSelectSlot();

            if (selected_slot != null)
            {
                selected_slot.KeyPressCancel();
            }

            if (ReadPanel.Get().IsVisible())
            {
                ReadPanel.Get().Hide();
            }
        }
Esempio n. 11
0
        protected override void RefreshPanel()
        {
            base.RefreshPanel();

            PlayerCharacter player = GetPlayer();

            if (player != null)
            {
                CraftStation station = player.Crafting.GetCraftStation();
                if (current_staton != station)
                {
                    current_staton = station;
                    RefreshCategories();
                }
            }

            //Gamepad auto controls
            PlayerControls controls    = PlayerControls.Get(GetPlayerID());
            CraftSubPanel  sub_panel   = CraftSubPanel.Get(GetPlayerID());
            UISlotPanel    focus_panel = UISlotPanel.GetFocusedPanel();

            if (focus_panel != this && focus_panel != sub_panel && !TheUI.Get().IsBlockingPanelOpened() &&
                controls.IsGamePad() && player != null && !player.Crafting.IsBuildMode())
            {
                Focus();
                CraftInfoPanel.Get(GetPlayerID())?.Hide();
            }
            if (focus_panel == this)
            {
                selection_index = Mathf.Clamp(selection_index, 0, CountActiveSlots() - 1);

                UISlot slot = GetSelectSlot();
                if (prev_slot != slot || !sub_panel.IsVisible())
                {
                    OnClick(slot);
                    sub_panel.selection_index = 0;
                    prev_slot = slot;
                }
            }
        }
Esempio n. 12
0
        protected override void RefreshPanel()
        {
            base.RefreshPanel();

            //Gamepad auto controls
            PlayerCharacter player     = GetPlayer();
            CraftInfoPanel  info_panel = CraftInfoPanel.Get(GetPlayerID());

            if (UISlotPanel.GetFocusedPanel() == this)
            {
                selection_index = Mathf.Clamp(selection_index, 0, CountActiveSlots() - 1);

                UISlot slot = GetSelectSlot();
                if (player != null && !player.Crafting.IsBuildMode())
                {
                    if (prev_slot != slot || !info_panel.IsVisible())
                    {
                        OnClick(slot);
                        prev_slot = slot;
                    }
                }
            }
        }
 public UISlotPanel GetFocusedPanel()
 {
     return(UISlotPanel.GetFocusedPanel());
 }