DoopelPonger
|
Important class that handles all user input. More...
Public Types | |
enum | InputTriggerOption { InputTriggerOption.PLAYER_0_MOVEMENT, InputTriggerOption.PLAYER_1_MOVEMENT, InputTriggerOption.PLAYER_0_POWER, InputTriggerOption.PLAYER_1_POWER, InputTriggerOption.PLAYER_0_SHIELD, InputTriggerOption.PLAYER_1_SHIELD, InputTriggerOption.MENU_UP, InputTriggerOption.MENU_DOWN, InputTriggerOption.MENU_SELECT, InputTriggerOption.MENU_BACK, InputTriggerOption.PAUSE } |
The type of listeners classes can register to receive input for. More... | |
enum | InputCheckerType { InputCheckerType.CONTINUOUS_PRESS, InputCheckerType.RELEASE, InputCheckerType.SINGLE_PRESS_UPDATE, InputCheckerType.SINGLE_PRESS_FIXED_UPDATE } |
Controls how the registered listener will get notified. More... | |
Public Member Functions | |
delegate void | MovementTrigger (float movement) |
delegate void | ButtonPressTrigger () |
delegate bool | StoppableButtonPressTrigger () |
delegate void | AnyButtonPressTrigger (KeyCode keyCode) |
void | Awake () |
Initialize data structures used by the manager. More... | |
void | Update () |
Check with all the registered InputCheckers to see what work should be done on the next FixedUpdate tick. More... | |
void | FixedUpdate () |
Drain the queue of listeners to notify a key has been pressed. More... | |
void | RegisterMovementTrigger (InputTriggerOption triggerOption, MovementTrigger trigger, string tag) |
Register to be notified of a movement trigger when an InputTriggerOption being triggered. More... | |
void | RegisterAnyKeyPressedTrigger (AnyButtonPressTrigger trigger) |
Register to be notified when any key is pressed. When the any key listener is registered it prevents all other listeners from being notified. More... | |
void | RegisterStoppableButtonPressTrigger (InputTriggerOption triggerOption, StoppableButtonPressTrigger trigger, string tag) |
Register for a listener that can break the chain of listener notifications, useful for UI when players shouldn't move when paused. More... | |
void | RegisterButtonPressTrigger (InputTriggerOption triggerOption, ButtonPressTrigger trigger, string tag, params InputCheckerType[] inputCheckerTypes) |
Register for a listener to be notified when the triggerOption is pressed. More... | |
void | DeregisterAnyKeyPressedTrigger () |
Remove the any key pressed listener. More... | |
void | DeregisterTrigger (InputTriggerOption triggerOption, string tag) |
Remove the triggerOption and tag from the listeners. More... | |
Important class that handles all user input.
The class has a way for classes to register callbacks based on input issued by the user. To register callbacks, code supplies the InputTriggerOption they want to get notified on and the function this class should call. This class then has a mapping from InputTriggerOption to Actions. Those Actions are then linked to KeyCodes. InputTriggerOptions have a 1 to many relationship for Actions and Actions have a 1 to 1 relationship with KeyCodes. This three tier structure is used so that dependencies can say "Hey notify me when player 0 activates the shield" The player 0 shield InputTriggerOption can then map to the player 0 shield primary and player 0 shield secondary actions. And finally each action can be mapped to a user configurable KeyCode (left and right arrow can spawn the shield).
|
strong |
Controls how the registered listener will get notified.
CONTINUOUS_PRESS will make sure the callback is triggered every FixedUpdate tick the key is held down RELEASE will make sure the callback is triggered the FixuedUpdate tick the key is released SINGLE_PRESS_UPDATE will make sure the callback is triggered only on the frame the key is pressed SINGLE_PRESS_FIXED_UPDATE will make sure the callback is triggered only on the FixedUpdate tick after the key is pressed
Enumerator | |
---|---|
CONTINUOUS_PRESS | |
RELEASE | |
SINGLE_PRESS_UPDATE | |
SINGLE_PRESS_FIXED_UPDATE |
|
strong |
delegate void InputManager.AnyButtonPressTrigger | ( | KeyCode | keyCode | ) |
Callback for the listeners that want to be notified when any key is pressed, don't care what the key is.
keyCode | Key pressed. |
void InputManager.Awake | ( | ) |
Initialize data structures used by the manager.
delegate void InputManager.ButtonPressTrigger | ( | ) |
Callback for listeners that want to know when a key is pressed.
void InputManager.DeregisterAnyKeyPressedTrigger | ( | ) |
Remove the any key pressed listener.
void InputManager.DeregisterTrigger | ( | InputTriggerOption | triggerOption, |
string | tag | ||
) |
Remove the triggerOption and tag from the listeners.
triggerOption | Input to remove |
tag | The matching tag to the triggerOption to remove. |
void InputManager.FixedUpdate | ( | ) |
Drain the queue of listeners to notify a key has been pressed.
delegate void InputManager.MovementTrigger | ( | float | movement | ) |
Callback for listeners of values between -1 to 1. The use in this game is movement where 0 is not moving, -1 is down, and 1 is up.
movement | The value between -1 to 1, calculated from buttons being pressed. |
void InputManager.RegisterAnyKeyPressedTrigger | ( | AnyButtonPressTrigger | trigger | ) |
Register to be notified when any key is pressed. When the any key listener is registered it prevents all other listeners from being notified.
trigger | Callback for when any key is pressed. |
void InputManager.RegisterButtonPressTrigger | ( | InputTriggerOption | triggerOption, |
ButtonPressTrigger | trigger, | ||
string | tag, | ||
params InputCheckerType [] | inputCheckerTypes | ||
) |
Register for a listener to be notified when the triggerOption is pressed.
triggerOption | When the trigger should be notified. |
trigger | Callback to notify. |
tag | Unique identifier used to remove the registered listener. |
inputCheckerTypes | When during the Update/FixedUpdate ticks the listener should be notified. |
void InputManager.RegisterMovementTrigger | ( | InputTriggerOption | triggerOption, |
MovementTrigger | trigger, | ||
string | tag | ||
) |
Register to be notified of a movement trigger when an InputTriggerOption being triggered.
triggerOption | The input to trigger the notification on. |
trigger | The callback method. |
tag | Unique identifier used to remove the registered listener. |
void InputManager.RegisterStoppableButtonPressTrigger | ( | InputTriggerOption | triggerOption, |
StoppableButtonPressTrigger | trigger, | ||
string | tag | ||
) |
Register for a listener that can break the chain of listener notifications, useful for UI when players shouldn't move when paused.
triggerOption | When the trigger should be notified. |
trigger | Callback to notify. |
tag | Unique identifier used to remove the registered listener. |
delegate bool InputManager.StoppableButtonPressTrigger | ( | ) |
Callback for listeners that want to know when a key is pressed and also want to prevent other input listeners from getting notifications.
void InputManager.Update | ( | ) |
Check with all the registered InputCheckers to see what work should be done on the next FixedUpdate tick.