Game
Creates an instance of the game
Constructor Summary
| Public Constructor | ||
| public |
constructor(client: Client) Keep track of the game logic and the HTML5 canvas |
|
Member Summary
| Public Members | ||
| public |
Controls the game music and sfx |
|
| public |
A reference to the chat bubbles controller |
|
| public |
An instance of the client application |
|
| public |
Returns server/config.json => devClient value |
|
| public |
An array of entities in the game |
|
| public |
guild: Guild A reference to a guild |
|
| public |
An ID used to identify the player after they've been given a handshake by the Node server |
|
| public |
Used to display additional information on the screen (ie level up and hits and health/exp regeneration) |
|
| public |
Controls all of the game's input |
|
| public |
Controls the interface in the game |
|
| public |
Last time (used for renderer??) |
|
| public |
Whether or not the map is loaded |
|
| public |
An instance of the game's map |
|
| public |
An array of mesages from the web socket |
|
| public |
Used to find paths of entities |
|
| public |
An instance of the player |
|
| public |
An instance of the game's player handler |
|
| public |
The pointer shown on the HTML5 canvas |
|
| public |
How many players are in the game, defaults to -1 |
|
| public |
True if there is currently pvp combat |
|
| public |
Whether or not the game is ready |
|
| public |
An instance of the renderer |
|
| public |
|
|
| public |
An instance of the web socket used to talk to the node server |
|
| public |
Whether or not the game is started |
|
| public |
A reference to the player's LocalStorage |
|
| public |
Used for rendering fame ticks |
|
| public |
An instance of the updater |
|
| public |
zoning: Zoning Used to figure out direction |
|
Method Summary
| Public Methods | ||
| public |
animationCallback(id: String, info: Array) Handles incoming animation packet data from the server |
|
| public |
audioCallback(song: String) Handles an audio track change notification from the server |
|
| public |
bankCallback(opcode: Number, info: Array) Handles incoming bank packet data from the server |
|
| public |
blinkCallback(instance: String) Triggers an item blink effect for the given entity instance |
|
| public |
chatCallback(info: Object) Handles an incoming chat message from the server |
|
| public |
combatCallback(data: Array) Handles incoming combat packet data from the server |
|
| public |
Connect to the nodeJS server and setup all the server to client callback messages |
|
| public |
Instantiates the local player entity |
|
| public |
deathCallback(id: String) Handles the player death event from the server |
|
| public |
despawnCallback(id: Number): Boolean Callback for removing a spawned entity |
|
| public |
enchantCallback(opcode: Number, info: Object) Handles incoming enchantment operation data from the server |
|
| public |
entityListCallback(data: Array<Entity>): Boolean Callback for when the list of entities is done loading and adds the new entities to the screen |
|
| public |
equipmentCallback(action: Number, info: Object): Boolean Callback for when player equipment is done loading |
|
| public |
experienceCallback(info: Object) Handles incoming experience gain data and updates the player's level display |
|
| public |
Finds a path for a character to a target grid position, optionally ignoring entities |
|
| public |
Returns the camera instance from the renderer |
|
| public |
Returns the entity at the given grid position, optionally ignoring the local player |
|
| public |
Returns the current UI scale factor from the client |
|
| public |
Returns a Sprite instance by name from the entity controller |
|
| public |
Returns the local storage controller instance |
|
| public |
Returns the saved password from local storage |
|
| public |
Returns the saved username from local storage |
|
| public |
guildCallback(opcode: Number, info: Object) Handles incoming guild operation data from the server |
|
| public |
handleDisconnection(noError: *) This function is responsible for handling sudden disconnects of a player whilst in the game, not menu-based errors. |
|
| public |
handshakeCallback(data: Messages): Boolean Callback for when the server has acknowledged the client connection then it creates the player object, makes sure the map is loaded, and if the user is registering or logging in it handles player registration or login requests |
|
| public |
Returns whether the player has opted to save their login credentials |
|
| public |
healCallback(info: Object) Handles incoming heal packet data and updates entity hit points |
|
| public |
Pre-populates the login form fields with saved username and password from storage |
|
| public |
inventoryCallback(opcode: Number, info: Array) Handles incoming inventory packet data from the server |
|
| public |
Load all of the game controllers |
|
| public |
Load the game map data |
|
| public |
Load the HTML5 canvas renderer layers for:
|
|
| public |
Invoked once all sprites have been loaded |
|
| public |
Callback for when the map data is done loading |
|
| public |
moveCharacter(character: Character, x: Number, y: Number) Moves a character entity to the specified grid position |
|
| public |
movePlayer(x: Number, y: Number) Moves the local player to the specified grid position |
|
| public |
movementCallback(data: Object<Messages>): Boolean Callback for entity movement |
|
| public |
Responds to a network ping from the server with a pong |
|
| public |
notificationCallback(opcode: Number, message: String) Handles incoming notification messages from the server |
|
| public |
npcCallback(opcode: Number, info: Object) Handles incoming NPC interaction packet data from the server |
|
| public |
Routes an input event to the input handler |
|
| public |
pointerCallback(opcode: Number, info: Object) Handles incoming pointer/waypoint indicator data from the server |
|
| public |
pointsCallback(data: Array) Handles incoming hit points and mana updates for an entity |
|
| public |
populationCallback(population: Number) Handles the server population count update |
|
| public |
postLoad() Call this after the player has been welcomed by the server and the client received the connection. |
|
| public |
projectileCallback(opcode: Number, info: Object) Handles incoming projectile packet data from the server |
|
| public |
pvpCallback(id: String, pvp: Boolean) Handles a PVP flag update for an entity |
|
| public |
questCallback(opcode: Number, info: Object) Handles incoming quest progress and completion data from the server |
|
| public |
resize() Handles a window resize event by updating the renderer and pointer positions |
|
| public |
respawn() Sends a respawn request to the server and plays the revive sound effect |
|
| public |
respawnCallback(id: String, x: Number, y: Number) Handles the player respawn event, repositioning them and resetting their state |
|
| public |
Sets the audio controller if one has not already been assigned |
|
| public |
Sets the bubble chat controller if one has not already been assigned |
|
| public |
setEntityController(entities: Entities) Sets the entity controller instance if one has not already been assigned |
|
| public |
Sets the info display controller if one has not already been assigned |
|
| public |
Sets the input handler instance if one has not already been assigned |
|
| public |
setInterface(intrface: Interface) Sets the UI interface controller if one has not already been assigned |
|
| public |
setMessages(messages: Messages) Sets the messages handler instance if one has not already been assigned |
|
| public |
setPathfinder(pathfinder: Pathfinder) Sets the pathfinder instance if one has not already been assigned |
|
| public |
setPlayerMovement(direction: Number) Sets the current movement direction of the player |
|
| public |
setPointer(pointer: Pointer) Sets the pointer/waypoint indicator controller if one has not already been assigned |
|
| public |
setRenderer(renderer: Renderer) Sets the renderer instance if one has not already been assigned |
|
| public |
Sets the socket instance if one has not already been assigned |
|
| public |
setStorage(storage: Storage) Sets the storage controller instance if one has not already been assigned |
|
| public |
setUpdater(updater: Updater) Sets the updater instance if one has not already been assigned |
|
| public |
shopCallback(opcode: Number, info: Object) Handles incoming shop operation data from the server |
|
| public |
spawnCallback(data: Object): Boolean Triggered when an entity has finished being spawned |
|
| public |
Start the game |
|
| public |
stop() Stop the game, sets started and ready to false |
|
| public |
syncCallback(playerEntity: Entity<Player>): Boolean Callback for when server side sync is done. |
|
| public |
teleportCallback(data: Object<Messages>): Boolean Callback for player teleport |
|
| public |
tick() Calls the renderer to draw to the HTML5 canvas if the game is ready and requests animations if the game is started |
|
| public |
Sends a trade request to the specified player |
|
| public |
Resets all of the controllers, storage and entities in the game. |
|
| public |
welcomeCallback(playerData: Object): Boolean The callback for when the welcome message for brand new players is done. |
|
Public Constructors
Public Members
public id: Number source
An ID used to identify the player after they've been given a handshake by the Node server
Public Methods
public animationCallback(id: String, info: Array) source
Handles incoming animation packet data from the server
public audioCallback(song: String) source
Handles an audio track change notification from the server
Params:
| Name | Type | Attribute | Description |
| song | String | the name of the song to play |
public bankCallback(opcode: Number, info: Array) source
Handles incoming bank packet data from the server
public blinkCallback(instance: String) source
Triggers an item blink effect for the given entity instance
Params:
| Name | Type | Attribute | Description |
| instance | String | the entity instance ID to blink |
public chatCallback(info: Object) source
Handles an incoming chat message from the server
Params:
| Name | Type | Attribute | Description |
| info | Object | the chat message object containing id, text, name, and display options |
public combatCallback(data: Array) source
Handles incoming combat packet data from the server
Params:
| Name | Type | Attribute | Description |
| data | Array | the combat packet data array |
public connect(): Boolean source
Connect to the nodeJS server and setup all the server to client callback messages
public deathCallback(id: String) source
Handles the player death event from the server
Params:
| Name | Type | Attribute | Description |
| id | String | the entity instance ID of the dead entity |
public despawnCallback(id: Number): Boolean source
Callback for removing a spawned entity
Params:
| Name | Type | Attribute | Description |
| id | Number | the id of the entity that needs to be removed |
public enchantCallback(opcode: Number, info: Object) source
Handles incoming enchantment operation data from the server
public entityListCallback(data: Array<Entity>): Boolean source
Callback for when the list of entities is done loading and adds the new entities to the screen
public equipmentCallback(action: Number, info: Object): Boolean source
Callback for when player equipment is done loading
public experienceCallback(info: Object) source
Handles incoming experience gain data and updates the player's level display
Params:
| Name | Type | Attribute | Description |
| info | Object | the experience data containing id, experience, level, and amount |
public findPath(character: Character, x: Number, y: Number, ignores: Array): Array source
Finds a path for a character to a target grid position, optionally ignoring entities
public getEntityAt(x: Number, y: Number, ignoreSelf: Boolean): Entity | null source
Returns the entity at the given grid position, optionally ignoring the local player
public getSprite(spriteName: String): Sprite source
Returns a Sprite instance by name from the entity controller
Params:
| Name | Type | Attribute | Description |
| spriteName | String | the name of the sprite to retrieve |
public guildCallback(opcode: Number, info: Object) source
Handles incoming guild operation data from the server
public handleDisconnection(noError: *) source
This function is responsible for handling sudden disconnects of a player whilst in the game, not menu-based errors.
Params:
| Name | Type | Attribute | Description |
| noError | * |
public handshakeCallback(data: Messages): Boolean source
Callback for when the server has acknowledged the client connection then it creates the player object, makes sure the map is loaded, and if the user is registering or logging in it handles player registration or login requests
Params:
| Name | Type | Attribute | Description |
| data | Messages | server network message |
public hasRemember(): Boolean source
Returns whether the player has opted to save their login credentials
public healCallback(info: Object) source
Handles incoming heal packet data and updates entity hit points
Params:
| Name | Type | Attribute | Description |
| info | Object | the heal data containing id, type, and amount |
public implementStorage() source
Pre-populates the login form fields with saved username and password from storage
public inventoryCallback(opcode: Number, info: Array) source
Handles incoming inventory packet data from the server
public loadRenderer(): Boolean source
Load the HTML5 canvas renderer layers for:
- background
- foreground
- text
- entities
- cursor
public moveCharacter(character: Character, x: Number, y: Number) source
Moves a character entity to the specified grid position
public movePlayer(x: Number, y: Number) source
Moves the local player to the specified grid position
public notificationCallback(opcode: Number, message: String) source
Handles incoming notification messages from the server
public npcCallback(opcode: Number, info: Object) source
Handles incoming NPC interaction packet data from the server
public pointerCallback(opcode: Number, info: Object) source
Handles incoming pointer/waypoint indicator data from the server
public pointsCallback(data: Array) source
Handles incoming hit points and mana updates for an entity
Params:
| Name | Type | Attribute | Description |
| data | Array | the points packet data array containing id, hitPoints, and mana |
public populationCallback(population: Number) source
Handles the server population count update
Params:
| Name | Type | Attribute | Description |
| population | Number | the current number of players online |
public postLoad() source
Call this after the player has been welcomed by the server and the client received the connection.
public projectileCallback(opcode: Number, info: Object) source
Handles incoming projectile packet data from the server
public questCallback(opcode: Number, info: Object) source
Handles incoming quest progress and completion data from the server
public respawnCallback(id: String, x: Number, y: Number) source
Handles the player respawn event, repositioning them and resetting their state
public setAudio(audio: Audio) source
Sets the audio controller if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| audio | Audio | the audio controller to set |
public setBubble(bubble: Bubble) source
Sets the bubble chat controller if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| bubble | Bubble | the bubble controller to set |
public setEntityController(entities: Entities) source
Sets the entity controller instance if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| entities | Entities | the entity controller to set |
public setInfo(info: Info) source
Sets the info display controller if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| info | Info | the info controller to set |
public setInput(input: Input) source
Sets the input handler instance if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| input | Input | the input handler to set |
public setInterface(intrface: Interface) source
Sets the UI interface controller if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| intrface | Interface | the interface controller to set |
public setMessages(messages: Messages) source
Sets the messages handler instance if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| messages | Messages | the messages handler to set |
public setPathfinder(pathfinder: Pathfinder) source
Sets the pathfinder instance if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| pathfinder | Pathfinder | the pathfinder instance to set |
public setPlayerMovement(direction: Number) source
Sets the current movement direction of the player
Params:
| Name | Type | Attribute | Description |
| direction | Number | the movement direction constant |
public setPointer(pointer: Pointer) source
Sets the pointer/waypoint indicator controller if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| pointer | Pointer | the pointer controller to set |
public setRenderer(renderer: Renderer) source
Sets the renderer instance if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| renderer | Renderer | the renderer instance to set |
public setSocket(socket: Socket) source
Sets the socket instance if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| socket | Socket | the socket instance to set |
public setStorage(storage: Storage) source
Sets the storage controller instance if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| storage | Storage | the storage controller to set |
public setUpdater(updater: Updater) source
Sets the updater instance if one has not already been assigned
Params:
| Name | Type | Attribute | Description |
| updater | Updater | the updater instance to set |
public shopCallback(opcode: Number, info: Object) source
Handles incoming shop operation data from the server
public spawnCallback(data: Object): Boolean source
Triggered when an entity has finished being spawned
Params:
| Name | Type | Attribute | Description |
| data | Object | entity id |
public syncCallback(playerEntity: Entity<Player>): Boolean source
Callback for when server side sync is done. Used to make sure the player's information doesn't differntiate from what the server has for them
public tick() source
Calls the renderer to draw to the HTML5 canvas if the game is ready and requests animations if the game is started
public tradeWith(player: Player) source
Sends a trade request to the specified player
Params:
| Name | Type | Attribute | Description |
| player | Player | the player entity to trade with |
public unload(): Boolean source
Resets all of the controllers, storage and entities in the game. Stops all audio too. Sets the game to a totally blank state so that it can be initialized like a new game all over again
public welcomeCallback(playerData: Object): Boolean source
The callback for when the welcome message for brand new players is done. Loads the player data and sets their starting position then calls this.postLoad()
Params:
| Name | Type | Attribute | Description |
| playerData | Object | the data needed to load the player |
Reference
Source
Test
