Classes
Members
callback
Callback executed with true/false when game starts/ends
- Source:
delay
Shared delay, set initially and updated once the game starts
- Source:
gameStarted
Game status flag, supposed to be set on remote event
- Source:
gameStatus
GameStatusForm, created and destroyed by show/close game status methods
- Source:
joinDlg
Dialogue, created and destroyed by invitePlayers/joinGame methods
- Source:
maxDelay
Maximum delay, limits the slider
- Source:
minDelay
Minumum delay, limits the slider
- Source:
players
Player list, contains User objects
- Source:
playing
Status flag, set in joinGame method
- Source:
sounds
Object containing all URLs of all sounds
- Source:
startTime
Start time in milliseconds, set once the game starts - owner only
- Source:
totalPlayers
Number of players at the moment of creation, copied from the shared object
- Source:
Methods
addIndicator(baseMesh, icon, coloropt)
Helper method to attach an icon above the avatar.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
baseMesh |
Mesh | avatar parent mesh | ||
icon |
String | URL of the icon to attach | ||
color |
* |
<optional> |
new BABYLON.Color4(1,1,1,1) | optional color |
- Source:
attachSounds()
Attach sounds to avatar mesh, called when player joins; this implementation does nothing.
- Source:
avatarPosition()
Helper method, returns current position the avatar, in either 1st or 3rd person view.
- Source:
changePlayerStatus(playerEvent, soundName, icon, color)
Adds and indicator to an avatar, and optionally plays a sound.
Parameters:
Name | Type | Description |
---|---|---|
playerEvent |
Object | object containing className and id of the player (can be User object) |
soundName |
String | name of the sound, one of this.sound, passed to playSound |
icon |
String | URL of the texture, passed to addIndicator |
color |
* | passed to addIndicator |
- Source:
closeGameStatus()
Close GameStatusForm if currently open, and restore the HUD.
- Source:
detachSounds()
Remove all sounds from avatar mesh, called when player quits.
Iterates over all keys of this.sounds object, and calls removeSound for each.
- Source:
dispose()
Clean up dialogue and status form, indicators, detach sounds
- Source:
enableMovement()
Enables or disables movement for any kind of camera.
- Source:
invitePlayers()
Typically the first thing to do. Game owner joins the game at once, everyone else gets the dialogue,
that triggers this.joinGame() as callback.
- Source:
joinGame(yes)
Join the game - shows game status and sends game join command to the server.
Parameters:
Name | Type | Description |
---|---|---|
yes |
boolean |
- Source:
playerJoins(player)
Helper method to be executed when a player joins the game, including the one that starts the game.
Adds the player to the player list, and calls attachSounds witht he player avatar.
When local player joins the game, the callback is called with true (if set).
Requires player avatar to be already loaded - may not be safe for async usage.
Parameters:
Name | Type | Description |
---|---|---|
player |
Object | object containing className and id of the player (User object will do) |
- Source:
playerQuits(player)
Helper method to be executed when a player quits the game, including the game owner.
Finds the player avatar and detaches attached sounds and indicator, then removes it from the player list.
If this player has quit, also closes the the game status.
Parameters:
Name | Type | Description |
---|---|---|
player |
Object | object containing className and id of the player (User object will do) |
- Source:
playSound()
Stops currently playing sound, and plays a sound attached to the avatar, if available. Sets SoundPlaying member field of the avatar mesh.
- Source:
quitGame()
Quit the game - sends the command to the server, optionally calls this.callback with false.
- Source:
remoteChange(vrObject, changes)
Main method of the game. Receives all events that happen in the game, and is supposed to implement scene changes.
Parameters:
Name | Type | Description |
---|---|---|
vrObject |
Game | game object |
changes |
Object | custom game event |
- Source:
removeIndicator()
Removes and disposes indicator from the base mesh and from list of indicators.
- Source:
removeSound()
If the mesh contains field specified by soundName, detaches it, disposes, and deletes.
- Source:
showGameStatus()
Creates a new HUD row, and opens a new GameStatusForm to start or join the game.
- Source:
startGame()
If the game is owned by current user, sends start event.
- Source:
startRequested()
Calls either showGameStatus, or invitePlayers, as appropriate.
Supposed to be executed on button click, if game instance already exists.
- Source:
updateStatus()
Sets number of players in game status form, if currently open.
- Source: