Reference Source Test
public class | source

Input

Handles game mouse and keyboard input

Constructor Summary

Public Constructor
public

constructor(game: Game)

Default constructor

Member Summary

Public Members
public

A reference to the Chat class

public

An instance of the client

public

The cursor

public

Whether or not the cursor is visible

public

All loaded cursors

public

An instance of the game

public

The entity being hovered over

public

A moving target's color

public

mouse: {x: Number, y: Number}

Information about the mouse position

public

A new instance of the cursor (for changing cursors)

public

The new target color

public

A reference to the overlay handler

public

previousClick: MouseEvent

The previous mouse click envent

public

previousKey: KeyboardEvent

The previous key pressed

public

An instance of the game renderer

public

Whether or not the selected cell is visible

public

The select x position

public

The select y position

public

This is the animation for the target cell spinner sprite (only on desktop)

public

The color of the target

public

Data on the targeted entity

public

Whether or not the target is visible

Method Summary

Public Methods
public

click(position: Object)

Handle clicking events

public

Returns the interface actions

public

Get an attack cursor (bow or sword) depending on if the player is ranged or not

public

getCoords(): {x: Number, y: Number}

Get the coordinates from the mouse relative to the canvas grid

public

Returns an instance of the player

public

getTargetData(): { sprite: Sprite, x: Number, y: Number, width: Number, height: Number, dy: Number, dw: Number, dh: Number, }

Get data about the current target

public

handle(inputType: Modules, data: Object)

Handle input

public

Returns whether or not the player can attack this entity

public

Returns whether or not this entity can be targeted

public

keyMove(position: Object)

Handle key presses to move the player in a direction

public

keyUp(key: Modules)

Handle keyUp events

public

Load cursors

public

Load spinner sprite, chat handler and overlay

public

Move the cursor or display a different cursor depending on what the player is hovering over

public

Set an attack target

public

setCoords(event: MouseEvent)

Sets the coordinates of the mouse relative to the offset of the canvas

public

setCursor(cursor: Cusror)

Set a new cursor

public

Set a passive target

public

Set the selectedX and selectedY positions

public

Change the cursor if visible and newCursor doesn't equal cursor

Public Constructors

public constructor(game: Game) source

Default constructor

Params:

NameTypeAttributeDescription
game Game

instance of the game

Public Members

public chatHandler: Chat source

A reference to the Chat class

public client: Client source

An instance of the client

public cursor: Cursor source

The cursor

public cursorVisible: Boolean source

Whether or not the cursor is visible

public cursors: Object<Cursor> source

All loaded cursors

public game: Game source

An instance of the game

public hovering: Entity source

The entity being hovered over

public mobileTargetColour: String source

A moving target's color

public mouse: {x: Number, y: Number} source

Information about the mouse position

public newCursor: Cursor source

A new instance of the cursor (for changing cursors)

public newTargetColour: String source

The new target color

public overlay: Overlay source

A reference to the overlay handler

public previousClick: MouseEvent source

The previous mouse click envent

public previousKey: KeyboardEvent source

The previous key pressed

public renderer: Renderer source

An instance of the game renderer

public selectedCellVisible: Boolean source

Whether or not the selected cell is visible

public selectedX: Number source

The select x position

public selectedY: Number source

The select y position

public targetAnimation: * source

This is the animation for the target cell spinner sprite (only on desktop)

public targetColour: String source

The color of the target

public targetData: Entity source

Data on the targeted entity

public targetVisible: Boolean source

Whether or not the target is visible

Public Methods

public click(position: Object) source

Handle clicking events

Params:

NameTypeAttributeDescription
position Object

the x,y coordinates of the click position

public getActions(): Actions source

Returns the interface actions

Return:

Actions

game interface actions

public getAttackCursor(): Cursor source

Get an attack cursor (bow or sword) depending on if the player is ranged or not

Return:

Cursor

the cursor to use for attacking

public getCoords(): {x: Number, y: Number} source

Get the coordinates from the mouse relative to the canvas grid

Return:

{x: Number, y: Number}

returns the grid x,y coordinates

public getPlayer(): Entity source

Returns an instance of the player

Return:

Entity

the player's entity

public getTargetData(): { sprite: Sprite, x: Number, y: Number, width: Number, height: Number, dy: Number, dw: Number, dh: Number, } source

Get data about the current target

Return:

{ sprite: Sprite, x: Number, y: Number, width: Number, height: Number, dy: Number, dw: Number, dh: Number, }

target data

public handle(inputType: Modules, data: Object) source

Handle input

Params:

NameTypeAttributeDescription
inputType Modules

the Modules.InputType to handle

data Object

data related to the input (keycode, coordinates, etc)

public isAttackable(entity: Entity): Boolean source

Returns whether or not the player can attack this entity

Params:

NameTypeAttributeDescription
entity Entity

the entity they want to attack

Return:

Boolean

returns true if they can attack this entity

public isTargetable(entity: Entity): Boolean source

Returns whether or not this entity can be targeted

Params:

NameTypeAttributeDescription
entity Entity

the entity to check if it can be targeted or not

Return:

Boolean

returns true player can target this entity

public keyMove(position: Object) source

Handle key presses to move the player in a direction

Params:

NameTypeAttributeDescription
position Object

The x,y coordinates of the click position

public keyUp(key: Modules) source

Handle keyUp events

Params:

NameTypeAttributeDescription
key Modules

the Modules.Keys that was triggered

public loadCursors() source

Load cursors

public loadInput() source

Load spinner sprite, chat handler and overlay

public moveCursor() source

Move the cursor or display a different cursor depending on what the player is hovering over

public setAttackTarget() source

Set an attack target

public setCoords(event: MouseEvent) source

Sets the coordinates of the mouse relative to the offset of the canvas

Params:

NameTypeAttributeDescription
event MouseEvent

the mouse move or mouse click event

public setCursor(cursor: Cusror) source

Set a new cursor

Params:

NameTypeAttributeDescription
cursor Cusror

the cursor to use

public setPassiveTarget() source

Set a passive target

public setPosition(x: Number, y: Number) source

Set the selectedX and selectedY positions

Params:

NameTypeAttributeDescription
x Number

X coordinate

y Number

Y coordinate

public updateCursor() source

Change the cursor if visible and newCursor doesn't equal cursor