PrincipalGame.GameOver = function(game){

}

PrincipalGame.GameOver.prototype = {

	init: function(){

	},
	preload: function(){
		//this.load.audio('gameOver','assets/audio/gameOver.ogg');
	},
	create: function(){
		// +++ Bg +++
		/*
		var bmd = this.game.add.bitmapData(this.game.width, this.game.height);

		bmd.ctx.beginPath();
		bmd.ctx.rect(0, 0, width, height);
		bmd.ctx.fillStyle = '#000000';
		bmd.ctx.fill();
		this.game.add.sprite(0, 0, bmd);
		*/

		this.game.add.sprite(0, 0, 'fondo6');
		this.game.add.sprite(0, 275, 'ciudad6');
		// --- Bg ---

		this.imgGameOver = this.game.add.sprite(this.game.width / 2, this.game.height / 2 - 200, 'gameover');
		this.imgGameOver.anchor.setTo(0.5, 0.5);

		//this.txt = game.add.text(this.game.width / 2, 50, 'Game Over!!!', { font: "24px Arial", fill: "#00FF00", align: "center" });
		//this.txt.anchor.setTo(0.5, 0.5);

		if (counter > HIGH_SCORE)
		{
			HIGH_SCORE = counter;
		}

		this.txt = game.add.text(this.game.width / 2, 220, 'HIGH SCORE   ' + counterPrint(HIGH_SCORE),
				{ font: "30px Arial", fill: "#FFFFFF", align: "center" });
		this.txt.anchor.setTo(0.5, 0.5);

		this.txt = game.add.text(this.game.width / 2, 300,
				'You survived just ' + counterPrint(totalTimeSurvived) + '!',
				{ font: "24px Arial", fill: "#00FF00", align: "center" });
		this.txt.anchor.setTo(0.5, 0.5);

		this.txt = game.add.text(this.game.width / 2 + 75, 330,
				'...too bad',
				{ font: "24px Arial", fill: "#00FF00", align: "center" });
		this.txt.anchor.setTo(0.5, 0.5);

		this.txt = game.add.text(this.game.width / 2, 370,
				'Monsters appeared: ' + MONSTERS,
				{ font: "24px Arial", fill: "#00FF00", align: "center" });
		this.txt.anchor.setTo(0.5, 0.5);

		this.Music_sound = this.game.add.audio('gameOver');
		this.Music_sound.volume = 3;
		if (0 == 0)
		{
			this.Music_sound.play();
		}

		this.game.input.onDown.add(
		    function(){
		    	this.playLevel();
		    }
		, this);

		this.timeIni = this.game.time.totalElapsedSeconds();
	},

	playLevel: function(){
		if (this.game.time.totalElapsedSeconds() - this.timeIni >= GAME_OVER_TIME)
		{
			MONSTERS = 0;
			this.state.start('Main');
		}
	},

	update: function(){
		if (this.game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
		{
			this.playLevel();
		}
	},
}
