Skip to content

Commit

Permalink
feat(gameStateManager): add message and notification when the level i…
Browse files Browse the repository at this point in the history
…s complete
  • Loading branch information
meszaros-lajos-gyorgy committed Sep 18, 2023
1 parent 46a7f33 commit c91ab51
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions assets/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,10 @@
"goblin_this_game_is_shit": {
"english": "This game is shit!!!",
"german": "Dieses spiel ist scheiße!!!"
},

"level-completed": {
"english": "Congratulations, you have completed the map! Feel free to stay on the map as long as you like and keep exploring!",
"german": "Herzlichen Glückwunsch, Sie haben die Karte fertiggestellt! Bleiben Sie gerne so lange auf der Karte, wie Sie möchten, und erkunden Sie weiter!"
}
}
16 changes: 15 additions & 1 deletion src/gameStateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { Audio, Entity, Settings } from 'arx-level-generator'
import { ScriptSubroutine } from 'arx-level-generator/scripting'
import { Sound, SoundFlags } from 'arx-level-generator/scripting/classes'
import { Variable } from 'arx-level-generator/scripting/properties'
import { delay, resetDelay } from './misc/scripting/delay.js'

const notification = new Sound(Audio.system.filename, SoundFlags.EmitFromPlayer)
const achievement = new Sound(Audio.system3.filename, SoundFlags.EmitFromPlayer)
const levelUp = new Sound('player_level_up', SoundFlags.EmitFromPlayer)

const tutorialWelcome = new ScriptSubroutine('tutorial_welcome', () => {
return `
Expand Down Expand Up @@ -50,6 +52,14 @@ const achievementListenLarge = new ScriptSubroutine('achievement_found_games_lar
`
})

const levelCompleted = new ScriptSubroutine('level_complete', () => {
return `
${levelUp.play()}
herosay [level-completed]
quest [level-completed]
`
})

const achievementLittering = new ScriptSubroutine('achievement_littering', () => {
return `
${achievement.play()}
Expand All @@ -65,7 +75,7 @@ export const createGameStateManager = (settings: Settings) => {
const playerFoundAnyGames = new Variable('bool', 'player_found_any_games', false)
const isGoblinReadyForSuicide = new Variable('bool', 'is_goblin_ready_for_suicide', false)
const isGoblinDead = new Variable('bool', 'is_goblin_dead', false)
const haveLittered = new Variable('bool', 'have_littered', false)
const haveLittered = new Variable('bool', 'player_littered', false)

manager.script?.properties.push(numberOfCollectedGames, playerFoundAnyGames, isGoblinReadyForSuicide, isGoblinDead)

Expand All @@ -76,6 +86,7 @@ export const createGameStateManager = (settings: Settings) => {
achievementListenSmall,
achievementListenMedium,
achievementListenLarge,
levelCompleted,
achievementLittering,
)

Expand All @@ -88,6 +99,8 @@ export const createGameStateManager = (settings: Settings) => {
}

manager.script?.on('game_collected', () => {
resetDelay()

return `
if (${playerFoundAnyGames.name} == 0) {
set ${playerFoundAnyGames.name} 1
Expand All @@ -106,6 +119,7 @@ export const createGameStateManager = (settings: Settings) => {
}
if (${numberOfCollectedGames.name} == 8) {
${achievementListenLarge.invoke()}
${delay(1000)} ${levelCompleted.invoke()}
}
`
})
Expand Down

0 comments on commit c91ab51

Please sign in to comment.