Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RunningGameState

Hierarchy

Index

Constructors

constructor

Methods

cancelAllAsyncOperations

  • cancelAllAsyncOperations(): void

doSave

  • doSave(syncWithServer?: boolean, force?: boolean): any
  • Saves the game

    Parameters

    • Default value syncWithServer: boolean = true
    • Default value force: boolean = false

    Returns any

filterInput

  • filterInput(): boolean
  • Filters the input (keybindings)

    Returns boolean

getDivElement

  • getDivElement(): HTMLElement
  • Returns the html element of the state

    Returns HTMLElement

getHasFadeIn

  • getHasFadeIn(): boolean

getHasFadeOut

  • getHasFadeOut(): boolean
  • Should return whether to fade out the game state. This will then apply the right css classes for the fadeout and wait the delay before moving states

    Returns boolean

getHasUnloadConfirmation

  • getHasUnloadConfirmation(): boolean

getInOutFadeTime

  • getInOutFadeTime(): 0 | 200
  • Should return how many mulliseconds to fade in / out the state. Not recommended to override!

    Returns 0 | 200

    Time in milliseconds to fade out

getInnerHTML

  • getInnerHTML(): string

getKey

  • getKey(): any
  • Returns the states key

    Returns any

getMultiplayerCore

  • getMultiplayerCore(): any
  • Returns any

getPauseOnFocusLost

  • getPauseOnFocusLost(): boolean

getThemeMusic

  • getThemeMusic(): any

goBackToMenu

  • goBackToMenu(): void
  • Goes back to the menu state

    Returns void

goToAchievements

  • goToAchievements(achievementsToHighlight?: any): void
  • Goes to the achievements state

    Parameters

    • Default value achievementsToHighlight: any = null

    Returns void

goToPerks

  • goToPerks(): void
  • Goes to the perks state

    Returns void

goToSettings

  • goToSettings(): void
  • Goes back to the settings state

    Returns void

internalCleanUpClickDetectors

  • internalCleanUpClickDetectors(): void

internalEnterCallback

  • internalEnterCallback(payload: any, callCallback?: boolean): void
  • Internal callback when entering the state. Do not override!

    Parameters

    • payload: any

      Arbitrary data passed from the state which we are transferring from

    • Default value callCallback: boolean = true

      Whether to call the onEnter callback

    Returns void

internalGetFadeInOutTime

  • internalGetFadeInOutTime(): number
  • Internal method to compute the time to fade in / out

    Returns number

    time to fade in / out in ms

internalGetFullHtml

  • internalGetFullHtml(): string
  • Internal method to get the HTML of the game state.

    Returns string

internalLeaveCallback

  • internalLeaveCallback(): void
  • Internal callback when the state is left. Do not override!

    Returns void

internalOnAppPauseCallback

  • internalOnAppPauseCallback(): void

internalOnAppResumeCallback

  • internalOnAppResumeCallback(): void

internalOnBeforeExitCallback

  • internalOnBeforeExitCallback(): void

internalRegisterCallback

  • internalRegisterCallback(stateManager: any, app: any): void
  • Internal callback from the manager. Do not override!

    Parameters

    • stateManager: any
    • app: any

    Returns void

isInGameoverAnimation

  • isInGameoverAnimation(): boolean
  • Returns if this state is currently in the gameover animation

    Returns boolean

isMultiplayer

  • isMultiplayer(): any
  • Helper method to figure out if we are currently in multiplayer

    Returns any

moveToState

  • moveToState(stateKey: any, payload?: object, skipFadeOut?: boolean): void
  • Transfers to a new state

    Parameters

    • stateKey: any

      The id of the new state

    • Default value payload: object = {}
    • Default value skipFadeOut: boolean = false

    Returns void

mpHandleConnectionClose

  • mpHandleConnectionClose(): void

mpHandlePacket

  • mpHandlePacket(packet: any): boolean

onAppPause

  • onAppPause(): void

onAppResume

  • onAppResume(): void
  • Callback when the app got resumed (on android, this means in foreground again)

    Returns void

onBackButton

  • onBackButton(): void
  • Handles the back button of the device (on desktop: escape key)

    Returns void

onBackgroundTick

  • onBackgroundTick(dt: any): void

onBeforeExit

  • onBeforeExit(): any

onEnter

  • onEnter(payload: any): void
  • Parameters

    • payload: any

    Returns void

onInitializationFailure

  • onInitializationFailure(err: any): void
  • Called when the game somehow failed to initialize. Resets everything to basic state and then goes to the main menu, showing the error

    Parameters

    • err: any

    Returns void

onLeave

  • onLeave(): void
  • Returns void

onRender

  • onRender(dt: any): void
  • Render callback

    Parameters

    • dt: any

    Returns void

onResized

  • onResized(w: any, h: any): void
  • Parameters

    • w: any
    • h: any

    Returns void

saveThenGoToState

  • saveThenGoToState(stateId: any, payload: any): void
  • Moves to a state outside of the game

    Parameters

    • stateId: any
    • payload: any

    Returns void

showLanguageChooser

  • showLanguageChooser(dialogs: any, buttonSelector?: string): void
  • Shows a language chooser dialog

    Parameters

    • dialogs: any
    • Default value buttonSelector: string = "button.languageChoose"

    Returns void

stage10GameRunning

  • stage10GameRunning(): void
  • The final stage where this game is running and updating regulary.

    Returns void

stage3CreateCore

  • stage3CreateCore(): void
  • Creates the game core instance, and thus the root

    Returns void

stage4aInitEmptyGame

  • stage4aInitEmptyGame(): void
  • Initializes a new empty game

    Returns void

stage4bResumeGame

  • stage4bResumeGame(): void
  • Resumes an existing game

    Returns void

stage4c1MPWaitPlayersJoined

  • stage4c1MPWaitPlayersJoined(): void
  • Waits until all other players are joined and we get the confirmation to load further

    Returns void

stage4c2MPWaitInitialDump

  • stage4c2MPWaitInitialDump(): void
  • Sends the loading finished packet to the gameserver and waits until the server sends the initial dump

    Returns void

stage5FirstUpdate

  • stage5FirstUpdate(): void
  • Performs the first game update on the game which initializes most caches and thus

    Returns void

stage6PostLoadHook

  • stage6PostLoadHook(): void
  • Call the post load hook, this means that we have loaded the game, and all systems can operate and start to work now.

    Returns void

stage7Warmup

  • stage7Warmup(): void
  • This makes the game idle and draw for a while, because we run most code this way the V8 engine can already start to optimize it. Also this makes sure the resources are in the VRAM and we have a smooth experience once we start.

    Returns void

stage8mpWaitLogicBudget

  • stage8mpWaitLogicBudget(): void
  • Returns void

stageDestroyed

  • stageDestroyed(): void
  • This stage destroys the whole game, used to cleanup

    Returns void

stageGameOverAnimation

  • stageGameOverAnimation(): void
  • The animation of the playerbase getting destroyed

    Returns void

stageGameOverFinished

  • stageGameOverFinished(__namedParameters: object): void
  • This stage is entered once the game is lost (only singleplayer)

    Parameters

    • __namedParameters: object
      • day: any
      • difficulty: any
      • layout: any
      • stats: any
      • timePlayed: any

    Returns void

stageGameOverMultiplayerFinished

  • stageGameOverMultiplayerFinished(): void
  • This stage is entered once the game is lost (only multiplayer)

    Returns void

stageLeavingGame

  • stageLeavingGame(): void
  • When leaving the game

    Returns void

switchStage

  • switchStage(stage: any): boolean
  • Switches the game into another sub-state

    Parameters

    • stage: any

    Returns boolean

trackClicks

  • trackClicks(element: any, handler: any, args?: object): void
  • Tracks clicks on a given element and calls the given callback on this state. If you want to call another function wrap it inside a lambda.

    Parameters

    • element: any

      The element to track clicks on

    • handler: any

      The handler to call

    • Default value args: object = {}

      Click detector arguments

    Returns void