protected virtual void setSelection(ButtonV2 selection)
    {
        if (selection == null)
        {
            return;
        }

        //resets old selection and displays the current one to the user
        m_CurrentButtonSelection.ButtonState = ButtonV2.ButtonStates.Default;
        m_CurrentButtonSelection = selection;
        m_CurrentButtonSelection.ButtonState = ButtonV2.ButtonStates.Highlightled;
    }
Exemple #2
0
    protected virtual void setSelection(ButtonV2 selection)
    {
        if (selection == null)
        {
            return;
        }

        //resets old selection and displays the current one to the user
        m_CurrentButtonSelection.ButtonState = ButtonV2.ButtonStates.Default;
        m_CurrentButtonSelection = selection;
        m_CurrentButtonSelection.ButtonState = ButtonV2.ButtonStates.Highlightled;
    }
    protected virtual void changeSelection()
    {
        //get the change selection input
        Vector2 selectionInput = InputManager.getMenuChangeSelection(m_ReadInputFrom);

        //if there was input
        if (selectionInput.x != 0.0f || selectionInput.y != 0.0f)
        {
            //reset the timer
            m_Timer = 0.0f;

            //convert the input into an angle
            float angle = Vector2.Angle(selectionInput, new Vector2(1.0f, 0.0f));

            //the conversion doesnt do reflex angles or negatives so adjust the value if needed
            if (selectionInput.y < 0)
            {
                angle *= -1;
            }

            //the next button to be selected
            ButtonV2 nextSelection = null;

            if (angle < -157.5f)
            {
                //centre left
                nextSelection = m_CurrentButtonSelection.getCentreLeftNeighbor();
            }
            else if (angle < -112.5f)
            {
                //bottom left
                nextSelection = m_CurrentButtonSelection.getBottomLeftNeighbor();
            }
            else if (angle < -67.5f)
            {
                //bottom middle
                nextSelection = m_CurrentButtonSelection.getBottomMiddleNeighbor();
            }
            else if (angle < -22.5f)
            {
                //bottom right
                nextSelection = m_CurrentButtonSelection.getBottomRightNeighbor();
            }
            else if (angle < 22.5f)
            {
                //centre right
                nextSelection = m_CurrentButtonSelection.getCentreRightNeighbor();
            }
            else if (angle < 67.5f)
            {
                //top right
                nextSelection = m_CurrentButtonSelection.getTopRightNeighbor();
            }
            else if (angle < 112.5f)
            {
                //top middle
                nextSelection = m_CurrentButtonSelection.getTopMiddleNeighbor();
            }
            else if (angle < 157.5f)
            {
                //top left
                nextSelection = m_CurrentButtonSelection.getTopLeftNeighbor();
            }
            else
            {
                //centre left
                nextSelection = m_CurrentButtonSelection.getCentreLeftNeighbor();
            }
            //set the selection
            setSelection(nextSelection);
        }
    }