/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package wge3.engine;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;

// Remember to implement statistics

public final class EndGameState extends GameState {
    
    private boolean result;
    private Statistics statistics;
    
    public EndGameState(boolean result, Statistics statistics) {
        this.result = result;
        this.statistics = statistics;
    }
    
    @Override
    public void update(float delta) {
        handleInput();
    }
    
    @Override
    public void draw(Batch batch) {
        batch.begin();
        int maxX = getGraphicsContext().getLogicalWidth();
        int maxY = getGraphicsContext().getLogicalHeight();
        BitmapFont font = getGraphicsContext().getFont();
        
        if (result) {
            font.draw(batch, "You won!", maxX / 2, maxY / 2);
        }
        else {
            font.draw(batch, "You lost!", maxX / 2, maxY / 2);
        }
        
        String player = statistics.getPlayers().get(0);
        font.draw(batch, "You took " + statistics.getStatFromPlayer(player, Statistic.DAMAGETAKEN) + " damage", maxX / 2, maxY / 4);
        
        font.draw(batch, "You dealt " + statistics.getStatFromPlayer(player, Statistic.DAMAGEDEALT) + " damage", maxX / 2, maxY / 3);
        
        font.draw(batch, "You regained " + statistics.getStatFromPlayer(player, Statistic.HEALTHREGAINED) + " health", maxX / 2, maxY / 5);
        
        font.draw(batch, "You fired " + statistics.getStatFromPlayer(player, Statistic.GUNSHOTSFIRED) + " shot" + (statistics.getStatFromPlayer(player, Statistic.GUNSHOTSFIRED) == 1 ? "" : "s"), maxX / 2, maxY / 6);
        
        font.draw(batch, "You used " + statistics.getStatFromPlayer(player, Statistic.TELEPORTERSUSED) + " teleporter" + (statistics.getStatFromPlayer(player, Statistic.TELEPORTERSUSED) == 1 ? "" : "s"), maxX / 2, maxY / 7);
        
        batch.end();
    }
    
    @Override
    public void handleInput() {
        if (Gdx.input.isTouched()) {
            getStateManager().popState();
        }
    }
    
    @Override
    public void dispose() {
    }
}

@@ -250,16 +250,52 @@
 dx.Gdx;%0A
+import com.badlogic.gdx.Input.Keys;%0A
 import c
@@ -692,32 +692,139 @@
  %0A    @Override%0A
+    public void enter() %7B%0A        Gdx.input.setInputProcessor(getInputHandler());%0A    %7D%0A    %0A    @Override%0A
     public void 
@@ -2384,16 +2384,30 @@
 t.is
-Touched(
+KeyPressed(Keys.ESCAPE
 )) %7B

Use esc to exit EndGameState