package com.uoc.educationalVG.memorycon;

import java.util.List;

import com.uoc.educationalVG.framework.Game;
import com.uoc.educationalVG.framework.Graphics;
import com.uoc.educationalVG.framework.Input.TouchEvent;
import com.uoc.educationalVG.utils.Assets;
import com.uoc.educationalVG.utils.Settings;

/**
 * @author "Beginning Android 4 Games Development"
 * @author (adapted by Sergi Colina)
 * 
 */
public class HighscoreScreen extends GameScreen {
	String lines[] = new String[5];

	public HighscoreScreen(Game game) {
		super(game);

		for (int i = 0; i < 5; i++) {
			lines[i] = "" + (i + 1) + ". " + Settings.getHighscores()[i];
		}
	}

	@Override
	public void update(float deltaTime) {
		List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
		game.getInput().getKeyEvents();

		int len = touchEvents.size();
		for (int i = 0; i < len; i++) {
			TouchEvent event = touchEvents.get(i);
			if (event.type == TouchEvent.TOUCH_UP) {
				if (Settings.isSoundEnabled())
					Assets.getClick().play(1);
				//Assets.getExitmusic().dispose();
				Assets.getExitmusic().stop();
				game.setScreen(new MainMenuScreen(game));
				return;
			}
		}
	}

	@Override
	public void present(float deltaTime) {
		Graphics g = game.getGraphics();
		g.drawPixmap(Assets.getHighScoresScreen(), 0, 0);
		int y = 200;
		for (int i = 0; i < 5; i++) {
			drawText(g, lines[i], Assets.getNumbers2(), 110, y);
			y += 40;
		}
	}

	@Override
	public void pause() {

	}

	@Override
	public void resume() {

	}

	@Override
	public void dispose() {

	}
}
