C# 클래스 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.
파일 보기 프로젝트 열기: ErraticUnicorn/MOSH

공개 메소드들

메소드 설명
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

비공개 메소드들

메소드 설명
nullCheck ( ) : void

메소드 상세

changeKeyControl() 공개 정적인 메소드

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
리턴 void

getKeyControl() 공개 정적인 메소드

Returns the current Key mapped to this KeyInputType
public static getKeyControl ( KeyInputType inputType ) : Keys
inputType KeyInputType
리턴 Keys

getKeyControls() 공개 정적인 메소드

Used for saving purposes only
public static getKeyControls ( ) : Keys[]
리턴 Keys[]

getNewKeyPressed() 공개 정적인 메소드

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

handleCharacterMovement() 공개 정적인 메소드

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
리턴 void

handleInGameMenu() 공개 정적인 메소드

public static handleInGameMenu ( ) : void
리턴 void

handleInteractions() 공개 정적인 메소드

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
리턴 void

handlePickpocketing() 공개 정적인 메소드

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
리턴 void

handleShooting() 공개 정적인 메소드

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
리턴 void

handleSimpleScreen() 공개 정적인 메소드

public static handleSimpleScreen ( AbstractScreen sender ) : void
sender AbstractScreen
리턴 void

isKeyDown() 공개 정적인 메소드

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

isKeyPressed() 공개 정적인 메소드

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
리턴 bool

isKeyUnpressed() 공개 정적인 메소드

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
리턴 bool

isKeyUp() 공개 정적인 메소드

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

isNewKeyPressed() 공개 정적인 메소드

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

keyControlExists() 공개 정적인 메소드

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)
리턴 bool

loadDefaultKeys() 공개 정적인 메소드

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

loadKeyControls() 공개 정적인 메소드

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
리턴 void

update() 공개 정적인 메소드

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