コード例 #1
0
        public UISlot GetSelectedSlot()
        {
            UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel();
            UISlot      selected_slot  = selected_panel?.GetSelectSlot();

            return(selected_slot);
        }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        private void OnPressUse()
        {
            UISlotPanel selected_panel = UISlotPanel.GetFocusedPanel();
            UISlot      selected_slot  = selected_panel?.GetSelectSlot();

            if (selected_slot != null)
            {
                selected_slot.KeyPressUse();
            }
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
        public void Navigate(UISlotPanel panel, Vector2 dir)
        {
            UISlot current = panel?.GetSelectSlot();

            if (panel == null || current == null)
            {
                if (IsLeft(dir))
                {
                    panel = default_left;
                }
                else if (IsRight(dir))
                {
                    panel = default_right;
                }
                else if (IsUp(dir))
                {
                    panel = default_top;
                }
                else if (IsDown(dir))
                {
                    panel = default_down;
                }
                panel.Focus();
            }
            else
            {
                if (IsLeft(dir) && current.left)
                {
                    NavigateTo(current.left, dir);
                }
                else if (IsRight(dir) && current.right)
                {
                    NavigateTo(current.right, dir);
                }
                else if (IsUp(dir) && current.top)
                {
                    NavigateTo(current.top, dir);
                }
                else if (IsDown(dir) && current.down)
                {
                    NavigateTo(current.down, dir);
                }
                else
                {
                    NavigateAuto(panel, dir);
                }
            }
        }