예제 #1
0
 /// <summary>
 /// Updates the position of the selector based on the user's input.
 /// </summary>
 void selectorPositionUpdate()
 {
     if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow) || joystick.IsButtonPressed(JoystickMenuInput.DpadButtons.Up))
     {
         if (index == 0)
         {
             Index = 2;
         }
         else
         {
             Index--;
         }
     }
     if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow) || joystick.IsButtonPressed(JoystickMenuInput.DpadButtons.Down))
     {
         if (index == 2)
         {
             Index = 0;
         }
         else
         {
             Index++;
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Get input from the player and update the index based on their input.
 /// </summary>
 void changeSelectedElement()
 {
     // If the player presses an up button,
     if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow) || joystick.IsButtonPressed(JoystickMenuInput.DpadButtons.Up))
     {
         // If they're at the top of the button list,
         if (index == 0)
         {
             // Move to the bottom
             Index = 2;
         }
         // If they're on any other element,
         else
         {
             // Lower index, moving up
             Index--;
         }
     }
     // If the player presses a down button,
     else if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow) || joystick.IsButtonPressed(JoystickMenuInput.DpadButtons.Down))
     {
         // If they're already at the bottom of the list,
         if (index == 2)
         {
             // Go back to the top
             Index = 0;
         }
         // If they're on any other element,
         else
         {
             // Add to index, going down
             Index++;
         }
     }
 }
    /*
     * IEnumerator DpadSpriteSetter()
     * {
     *
     * }
     */

    /// <summary>
    /// Convert input from the dpad into an index in ControllerButtonPrompts.
    /// </summary>
    /// <returns>
    /// An index in ControllerButtonPrompts.
    /// 4 = default
    /// 5 = left
    /// 6 = up
    /// 7 = right
    /// 8 = down
    /// </returns>
    int DpadInputConverter()
    {
        if (joystick.IsButtonPressed(JoystickMenuInput.DpadButtons.Left))
        {
            return(5);
        }
        else if (joystick.IsButtonPressed(JoystickMenuInput.DpadButtons.Up))
        {
            return(6);
        }
        else if (joystick.IsButtonPressed(JoystickMenuInput.DpadButtons.Right))
        {
            return(7);
        }
        else if (joystick.IsButtonPressed(JoystickMenuInput.DpadButtons.Down))
        {
            return(8);
        }
        else
        {
            return(4);
        }
    }