Noah Petherbridge
0c22ecae5e
* Add a Level Exit doodad, which for now is a little blue flag on a pole that reads "END" * JavaScript API: global function EndLevel() will end the level. The exit doodad calls this when touched by the player. * Add a "Level Completed" alert box UI to PlayScene with dynamic button layouts. * The alert box pops up when a doodad calls EndLevel() and contains action buttons what to do next. * "Play Again" restarts the current level again. * "Edit Level" if you came from the EditorScene; otherwise this button is not visible. * "Next Level" is a to-be-implemented button to advance in the single player story mode. Only shows up when PlayScene.HasNext=true. * "Exit to Menu" is always visible and closes out to the MainScene.
24 lines
590 B
Go
24 lines
590 B
Go
package scripting
|
|
|
|
/*
|
|
RegisterEventHooks attaches the supervisor level event hooks into a JS VM.
|
|
|
|
Names registered:
|
|
|
|
- EndLevel(): for a doodad to exit the level. Panics if the OnLevelExit
|
|
handler isn't defined.
|
|
*/
|
|
func RegisterEventHooks(s *Supervisor, vm *VM) {
|
|
vm.Set("EndLevel", func() {
|
|
if s.onLevelExit == nil {
|
|
panic("JS EndLevel(): no OnLevelExit handler attached to script supervisor")
|
|
}
|
|
s.onLevelExit()
|
|
})
|
|
}
|
|
|
|
// OnLevelExit registers an event hook for when a Level Exit doodad is reached.
|
|
func (s *Supervisor) OnLevelExit(handler func()) {
|
|
s.onLevelExit = handler
|
|
}
|