Reference Source Test
public class | source

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

map: Map

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

shop: *

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: *, info: *)

public

audioCallback(song: *)

public

bankCallback(opcode: *, info: *)

public

blinkCallback(instance: *)

public

chatCallback(info: *)

public

combatCallback(data: *)

public

Connect to the nodeJS server and setup all the server to client callback messages

public
public

deathCallback(id: *)

public

Callback for removing a spawned entity

public

enchantCallback(opcode: *, info: *)

public

Callback for when the list of entities is done loading and adds the new entities to the screen

public

Callback for when player equipment is done loading

public
public

findPath(character: *, x: *, y: *, ignores: *): *

public

getCamera(): *

public

getEntityAt(x: *, y: *, ignoreSelf: *): *

public
public

getSprite(spriteName: *): *

public

getStorage(): *

public
public
public

guildCallback(opcode: *, info: *)

public

handleDisconnection(noError: *)

This function is responsible for handling sudden disconnects of a player whilst in the game, not menu-based errors.

public

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
public

healCallback(info: *)

public
public

inventoryCallback(opcode: *, info: *)

public

Load all of the game controllers

public

Load the game map data

public

Load the HTML5 canvas renderer layers for:

  • background
  • foreground
  • text
  • entities
  • cursor
public
public

Callback for when the map data is done loading

public

moveCharacter(character: *, x: *, y: *)

public

movePlayer(x: *, y: *)

public

Callback for entity movement

public
public

notificationCallback(opcode: *, message: *)

public

npcCallback(opcode: *, info: *)

public

onInput(inputType: *, data: *)

public

pointerCallback(opcode: *, info: *)

public

pointsCallback(data: *)

public

populationCallback(population: *)

public

Call this after the player has been welcomed by the server and the client received the connection.

public

projectileCallback(opcode: *, info: *)

public

pvpCallback(id: *, pvp: *)

public

questCallback(opcode: *, info: *)

public

resize()

public
public

respawnCallback(id: *, x: *, y: *)

public

setAudio(audio: *)

public

setBubble(bubble: *)

public

setEntityController(entities: *)

public

setInfo(info: *)

public

setInput(input: *)

public

setInterface(intrface: *)

public

setMessages(messages: *)

public

setPathfinder(pathfinder: *)

public

setPlayerMovement(direction: *)

public

setPointer(pointer: *)

public

setRenderer(renderer: *)

public

setSocket(socket: *)

public

setStorage(storage: *)

public

setUpdater(updater: *)

public

shopCallback(opcode: *, info: *)

public

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

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

tradeWith(player: *)

public

Resets all of the controllers, storage and entities in the game.

public

The callback for when the welcome message for brand new players is done.

Public Constructors

public constructor(client: Client) source

Keep track of the game logic and the HTML5 canvas

Params:

NameTypeAttributeDescription
client Client

an instance of the client application

Public Members

public audio: Audio source

Controls the game music and sfx

public bubble: Bubble source

A reference to the chat bubbles controller

public client: Client source

An instance of the client application

public development: Boolean source

Returns server/config.json => devClient value

public entities: Array<Entity> source

An array of entities in the game

public guild: Guild source

A reference to a guild

public id: Number source

An ID used to identify the player after they've been given a handshake by the Node server

public info: Info source

Used to display additional information on the screen (ie level up and hits and health/exp regeneration)

public input: Input source

Controls all of the game's input

public interface: Interface source

Controls the interface in the game

public lastTime: Boolean source

Last time (used for renderer??)

public loaded: Boolean source

Whether or not the map is loaded

public map: Map source

An instance of the game's map

public messages: Messages source

An array of mesages from the web socket

public pathfinder: Pathfinder source

Used to find paths of entities

public player: Player source

An instance of the player

public playerHandler: PlayerHandler source

An instance of the game's player handler

public pointer: Pointer source

The pointer shown on the HTML5 canvas

public population: Number source

How many players are in the game, defaults to -1

public pvp: Boolean source

True if there is currently pvp combat

public ready: Boolean source

Whether or not the game is ready

public renderer: Renderer source

An instance of the renderer

public shop: * source

public socket: Socket source

An instance of the web socket used to talk to the node server

public started: Boolean source

Whether or not the game is started

public storage: Object source

A reference to the player's LocalStorage

public time: Date source

Used for rendering fame ticks

public updater: Updater source

An instance of the updater

public zoning: Zoning source

Used to figure out direction

Public Methods

public animationCallback(id: *, info: *) source

Params:

NameTypeAttributeDescription
id *
info *

public audioCallback(song: *) source

Params:

NameTypeAttributeDescription
song *

public bankCallback(opcode: *, info: *) source

Params:

NameTypeAttributeDescription
opcode *
info *

public blinkCallback(instance: *) source

Params:

NameTypeAttributeDescription
instance *

public chatCallback(info: *) source

Params:

NameTypeAttributeDescription
info *

public combatCallback(data: *) source

Params:

NameTypeAttributeDescription
data *

public connect(): Boolean source

Connect to the nodeJS server and setup all the server to client callback messages

Return:

Boolean

public createPlayer() source

public deathCallback(id: *) source

Params:

NameTypeAttributeDescription
id *

public despawnCallback(id: Number): Boolean source

Callback for removing a spawned entity

Params:

NameTypeAttributeDescription
id Number

the id of the entity that needs to be removed

Return:

Boolean

public enchantCallback(opcode: *, info: *) source

Params:

NameTypeAttributeDescription
opcode *
info *

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

Params:

NameTypeAttributeDescription
data Array<Entity>

array of entities

Return:

Boolean

public equipmentCallback(action: Number, info: Object): Boolean source

Callback for when player equipment is done loading

Params:

NameTypeAttributeDescription
action Number

the equipment action

info Object

information about the equipment

Return:

Boolean

public experienceCallback(info: *) source

Params:

NameTypeAttributeDescription
info *

public findPath(character: *, x: *, y: *, ignores: *): * source

Params:

NameTypeAttributeDescription
character *
x *
y *
ignores *

Return:

*

public getCamera(): * source

Return:

*

public getEntityAt(x: *, y: *, ignoreSelf: *): * source

Params:

NameTypeAttributeDescription
x *
y *
ignoreSelf *

Return:

*

public getScaleFactor(): * source

Return:

*

public getSprite(spriteName: *): * source

Params:

NameTypeAttributeDescription
spriteName *

Return:

*

public getStorage(): * source

Return:

*

public getStoragePassword(): * source

Return:

*

public getStorageUsername(): * source

Return:

*

public guildCallback(opcode: *, info: *) source

Params:

NameTypeAttributeDescription
opcode *
info *

public handleDisconnection(noError: *) source

This function is responsible for handling sudden disconnects of a player whilst in the game, not menu-based errors.

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
data Messages

server network message

Return:

Boolean

public hasRemember(): * source

Return:

*

public healCallback(info: *) source

Params:

NameTypeAttributeDescription
info *

public implementStorage() source

public inventoryCallback(opcode: *, info: *) source

Params:

NameTypeAttributeDescription
opcode *
info *

public loadControllers(): Boolean source

Load all of the game controllers

Return:

Boolean

public loadGameMap(): Boolean source

Load the game map data

Return:

Boolean

public loadRenderer(): Boolean source

Load the HTML5 canvas renderer layers for:

  • background
  • foreground
  • text
  • entities
  • cursor

Return:

Boolean

public loadedSpritesCallback() source

public mapReadyCallback(): Boolean source

Callback for when the map data is done loading

Return:

Boolean

public moveCharacter(character: *, x: *, y: *) source

Params:

NameTypeAttributeDescription
character *
x *
y *

public movePlayer(x: *, y: *) source

Params:

NameTypeAttributeDescription
x *
y *

public movementCallback(data: Object<Messages>): Boolean source

Callback for entity movement

Params:

NameTypeAttributeDescription
data Object<Messages>

message data

Return:

Boolean

public networkCallback() source

public notificationCallback(opcode: *, message: *) source

Params:

NameTypeAttributeDescription
opcode *
message *

public npcCallback(opcode: *, info: *) source

Params:

NameTypeAttributeDescription
opcode *
info *

public onInput(inputType: *, data: *) source

Params:

NameTypeAttributeDescription
inputType *
data *

public pointerCallback(opcode: *, info: *) source

Params:

NameTypeAttributeDescription
opcode *
info *

public pointsCallback(data: *) source

Params:

NameTypeAttributeDescription
data *

public populationCallback(population: *) source

Params:

NameTypeAttributeDescription
population *

public postLoad() source

Call this after the player has been welcomed by the server and the client received the connection.

public projectileCallback(opcode: *, info: *) source

Params:

NameTypeAttributeDescription
opcode *
info *

public pvpCallback(id: *, pvp: *) source

Params:

NameTypeAttributeDescription
id *
pvp *

public questCallback(opcode: *, info: *) source

Params:

NameTypeAttributeDescription
opcode *
info *

public resize() source

public respawn() source

public respawnCallback(id: *, x: *, y: *) source

Params:

NameTypeAttributeDescription
id *
x *
y *

public setAudio(audio: *) source

Params:

NameTypeAttributeDescription
audio *

public setBubble(bubble: *) source

Params:

NameTypeAttributeDescription
bubble *

public setEntityController(entities: *) source

Params:

NameTypeAttributeDescription
entities *

public setInfo(info: *) source

Params:

NameTypeAttributeDescription
info *

public setInput(input: *) source

Params:

NameTypeAttributeDescription
input *

public setInterface(intrface: *) source

Params:

NameTypeAttributeDescription
intrface *

public setMessages(messages: *) source

Params:

NameTypeAttributeDescription
messages *

public setPathfinder(pathfinder: *) source

Params:

NameTypeAttributeDescription
pathfinder *

public setPlayerMovement(direction: *) source

Params:

NameTypeAttributeDescription
direction *

public setPointer(pointer: *) source

Params:

NameTypeAttributeDescription
pointer *

public setRenderer(renderer: *) source

Params:

NameTypeAttributeDescription
renderer *

public setSocket(socket: *) source

Params:

NameTypeAttributeDescription
socket *

public setStorage(storage: *) source

Params:

NameTypeAttributeDescription
storage *

public setUpdater(updater: *) source

Params:

NameTypeAttributeDescription
updater *

public shopCallback(opcode: *, info: *) source

Params:

NameTypeAttributeDescription
opcode *
info *

public spawnCallback(data: Object): Boolean source

Triggered when an entity has finished being spawned

Params:

NameTypeAttributeDescription
data Object

entity id

Return:

Boolean

public start(): Boolean source

Start the game

Return:

Boolean

true if the game was successfully started, false if the game is already running

public stop() source

Stop the game, sets started and ready to false

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

Params:

NameTypeAttributeDescription
playerEntity Entity<Player>

player entity object

Return:

Boolean

false if this entity is not a player type

public teleportCallback(data: Object<Messages>): Boolean source

Callback for player teleport

Params:

NameTypeAttributeDescription
data Object<Messages>

information about the teleport

Return:

Boolean

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: *) source

Params:

NameTypeAttributeDescription
player *

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

Return:

Boolean

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:

NameTypeAttributeDescription
playerData Object

the data needed to load the player

Return:

Boolean