C# Class SunsetHigh.KeyboardManager

Static class that has three purposes: 1) To easily tell if a key is held down or has been just pressed, 2) To handle complex keyboard input for the game with simple method calls, 3) To store custom key controls for the game.
Afficher le fichier Open project: ErraticUnicorn/MOSH

Méthodes publiques

Méthode Description
changeKeyControl ( KeyInputType inputType, Keys key ) : void

Change the key input needed to trigger a given game function; used for customizing key controls

getKeyControl ( KeyInputType inputType ) : Keys

Returns the current Key mapped to this KeyInputType

getKeyControls ( ) : Keys[]

Used for saving purposes only

getNewKeyPressed ( ) : Keys

Returns one key that has just been pressed (assuming it's the only key pressed)

handleCharacterMovement ( Character character, float elapsed ) : void

Ts Character movement in 8 directions; call this method in the Game's update cycle (AFTER calling KeyboardManager.update())

handleInGameMenu ( ) : void
handleInteractions ( Hero hero, List targets ) : void

Handles the Hero talking with Characters. Will be expanded later to "interact" with scenery as well.

handlePickpocketing ( Hero hero, List targets ) : void

Handles the Hero's pickpocketing ability; call this method in the Game's update cycle (AFTER calling KeyboardManager.update())

handleShooting ( Hero hero ) : void

Handles Hero's "weapon" ability; call this method in the Game's update cycle (AFTER calling KeyboardManager.update())

handleSimpleScreen ( AbstractScreen sender ) : void
isKeyDown ( Keys key ) : bool

Checks if the given key is currently down (pressed)

isKeyPressed ( Keys key ) : bool

Checks if the given key has just been pressed (i.e. it is down now and was not pressed in the previous update)

isKeyUnpressed ( Keys key ) : bool

Checks if the given key has just been released (i.e. it is up now and was pressed in the previous update)

isKeyUp ( Keys key ) : bool

Checks if the given key is currently up (not pressed)

isNewKeyPressed ( ) : bool

Checks if any new key has just been pressed (and was not down previously)

keyControlExists ( Keys key, KeyInputType exclude ) : bool

A check for whether the given key is already registered with a certain type of input. Called when customizing key controls

loadDefaultKeys ( ) : void

Used for loading the default key controls when starting a game (or resetting controls)

loadKeyControls ( Keys loadableKeys ) : void

Used for loading in custom key controls when restoring a saved game

update ( ) : void

Updates the keyboard input; call this method in the Game's update cycle

Private Methods

Méthode Description
nullCheck ( ) : void

Method Details

changeKeyControl() public static méthode

Change the key input needed to trigger a given game function; used for customizing key controls
public static changeKeyControl ( KeyInputType inputType, Keys key ) : void
inputType KeyInputType The game function
key Keys The new key to press
Résultat void

getKeyControl() public static méthode

Returns the current Key mapped to this KeyInputType
public static getKeyControl ( KeyInputType inputType ) : Keys
inputType KeyInputType
Résultat Keys

getKeyControls() public static méthode

Used for saving purposes only
public static getKeyControls ( ) : Keys[]
Résultat Keys[]

getNewKeyPressed() public static méthode

Returns one key that has just been pressed (assuming it's the only key pressed)
public static getNewKeyPressed ( ) : Keys
Résultat Keys

handleCharacterMovement() public static méthode

Ts Character movement in 8 directions; call this method in the Game's update cycle (AFTER calling KeyboardManager.update())
public static handleCharacterMovement ( Character character, float elapsed ) : void
character Character The character to control (presumably main character)
elapsed float The time that elapsed since the last update
Résultat void

handleInGameMenu() public static méthode

public static handleInGameMenu ( ) : void
Résultat void

handleInteractions() public static méthode

Handles the Hero talking with Characters. Will be expanded later to "interact" with scenery as well.
public static handleInteractions ( Hero hero, List targets ) : void
hero Hero The main character
targets List List of interactables in the scene
Résultat void

handlePickpocketing() public static méthode

Handles the Hero's pickpocketing ability; call this method in the Game's update cycle (AFTER calling KeyboardManager.update())
public static handlePickpocketing ( Hero hero, List targets ) : void
hero Hero The main character
targets List List of characters in the scene; one that is in range is chosen randomly
Résultat void

handleShooting() public static méthode

Handles Hero's "weapon" ability; call this method in the Game's update cycle (AFTER calling KeyboardManager.update())
public static handleShooting ( Hero hero ) : void
hero Hero
Résultat void

handleSimpleScreen() public static méthode

public static handleSimpleScreen ( AbstractScreen sender ) : void
sender AbstractScreen
Résultat void

isKeyDown() public static méthode

Checks if the given key is currently down (pressed)
public static isKeyDown ( Keys key ) : bool
key Keys The key to check for
Résultat bool

isKeyPressed() public static méthode

Checks if the given key has just been pressed (i.e. it is down now and was not pressed in the previous update)
public static isKeyPressed ( Keys key ) : bool
key Keys The key to check for
Résultat bool

isKeyUnpressed() public static méthode

Checks if the given key has just been released (i.e. it is up now and was pressed in the previous update)
public static isKeyUnpressed ( Keys key ) : bool
key Keys The key to check for
Résultat bool

isKeyUp() public static méthode

Checks if the given key is currently up (not pressed)
public static isKeyUp ( Keys key ) : bool
key Keys The key to check for
Résultat bool

isNewKeyPressed() public static méthode

Checks if any new key has just been pressed (and was not down previously)
public static isNewKeyPressed ( ) : bool
Résultat bool

keyControlExists() public static méthode

A check for whether the given key is already registered with a certain type of input. Called when customizing key controls
public static keyControlExists ( Keys key, KeyInputType exclude ) : bool
key Keys The possible key to shift the input type to
exclude KeyInputType Input type to exclude (i.e. the input being considered)
Résultat bool

loadDefaultKeys() public static méthode

Used for loading the default key controls when starting a game (or resetting controls)
public static loadDefaultKeys ( ) : void
Résultat void

loadKeyControls() public static méthode

Used for loading in custom key controls when restoring a saved game
public static loadKeyControls ( Keys loadableKeys ) : void
loadableKeys Keys A Keys[] representation of the key controls
Résultat void

update() public static méthode

Updates the keyboard input; call this method in the Game's update cycle
public static update ( ) : void
Résultat void