Skip to content

Commit

Permalink
Show instructions count for task on success screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
BOOtak committed Oct 8, 2019
1 parent 41912f4 commit 2854ad1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class PlottingScreenState : IState {
"instructionsCount", IOC.atOrFail<Int>("instructionsCount") +
state.instructions.size
)
IOC.put("solutionInstructions", state.instructions.size)
IOC.put("state", States.SUCCESS_SCREEN)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
package org.catinthedark.jvcrplotter.game.states

import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Input
import com.badlogic.gdx.assets.AssetManager
import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.scenes.scene2d.Stage
import org.catinthedark.jvcrplotter.game.Assets.Names.FONT_BIG_GREEN
import org.catinthedark.jvcrplotter.game.Assets
import org.catinthedark.jvcrplotter.game.States
import org.catinthedark.jvcrplotter.game.Tasks
import org.catinthedark.jvcrplotter.game.font
import org.catinthedark.jvcrplotter.game.texture
import org.catinthedark.jvcrplotter.game.ui.HelperDialog
import org.catinthedark.jvcrplotter.lib.IOC
import org.catinthedark.jvcrplotter.lib.atOrFail
import org.catinthedark.jvcrplotter.lib.managed
import org.catinthedark.jvcrplotter.lib.states.IState

class SuccessScreenState: IState {
class SuccessScreenState : IState {
private val hud: Stage by lazy { IOC.atOrFail<Stage>("hud") }
private val am: AssetManager by lazy { IOC.atOrFail<AssetManager>("assetManager") }
private val font: BitmapFont by lazy { am.font(FONT_BIG_GREEN) }
private lateinit var congratsDialog: HelperDialog
private var solutionInstructions: Int = 0

override fun onActivate() {

solutionInstructions = IOC.atOrFail("solutionInstructions")
congratsDialog = HelperDialog(
400, 250, 530, 300,
"Congratulations, comrade!\n" +
"You've solved this task\n" +
"in [RED]$solutionInstructions[] instructions!"
)
}

override fun onUpdate() {
hud.batch.managed {
font.draw(it, "SUCCESS. PRESS SPACE", 10f, 200f)
it.draw(am.texture(Assets.Names.WORKSPACE), 0f, 0f)
}

if (Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) {
congratsDialog.updateAndDraw(hud.batch)
if (congratsDialog.isClosed) {
val currentTaskId = IOC.atOrFail<Int>("currentTaskId")
val nextTaskId = (currentTaskId + 1) % Tasks.taskTextures.size
if (nextTaskId < currentTaskId) {
Expand All @@ -37,6 +43,7 @@ class SuccessScreenState: IState {
IOC.put("currentTaskId", nextTaskId)
IOC.put("state", States.WORKSPACE_SCREEN)
}
congratsDialog.reset()
}
}

Expand Down

0 comments on commit 2854ad1

Please sign in to comment.