function AlienTimer(aliens) {
	this.aliens = aliens;
	this.activatedAlienIndex = 0;

	var posX = this.aliens[0].x;
	var posY = this.aliens[0].y - AlienTimer.MOVE_UP_AMOUNT_PX;
	this.timerText = game.add.text(posX, posY, "30", AlienTimer.DEFAULT_TEXT_FONT);
	this.timerText.anchor.set(0.5);

	var grd = this.timerText.context.createLinearGradient(0, 0, 0, this.timerText.height);
	grd.addColorStop(0, '#FFD68E');
	grd.addColorStop(1, '#B34C00');
	this.timerText.fill = grd;
	// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
	this.timerText.stroke = '#000';
	this.timerText.strokeThickness = 5;

	this.timerEvent = null;
	this.timeInterval = AlienTimer.DEFAULT_TIME_GAP_SEC;
	this.timeLeft = this.timeInterval;
}

AlienTimer.prototype.start = function() {
	this.enableTimerOn(this.getActivatedAlien());
	// this.getActivatedAlien().setActive(true);
	this.timerText.text = this.timeLeft.toString();
	if(this.timerEvent === null)
		this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND, this.updateTimer, this);
}

AlienTimer.prototype.pause = function() {
}

AlienTimer.prototype.stop = function() {
	if(this.timerEvent)
		this.removeTimer();
	this.timerText.text = "";

	for(var i = 0; i < this.aliens.length; i++)
		this.aliens[i].stop();
}

AlienTimer.prototype.next = function() {
	this.timeLeft = this.timeInterval;
	this.timerText.text = this.timeLeft.toString();

	this.activatedAlienIndex++;
	if(this.activatedAlienIndex >= this.aliens.length) {
		this.timerText.text = "";
		this.removeTimer();
		return null;
	}

	this.enableTimerOn(this.getActivatedAlien());
}

AlienTimer.prototype.getActivatedAlien = function() {
	return this.aliens[this.activatedAlienIndex];
}

AlienTimer.prototype.enableTimerOn = function(alien) {
	alien.setActive(true);
	this.timerText.x = alien.x;
}

AlienTimer.prototype.disableTimerOn = function(alien) {
	alien.setActive(false);
	this.timerText.text = "";
}

AlienTimer.prototype.updateTimer = function() {
	this.timeLeft--;
	if(this.timeLeft == 0) {
		this.timeLeft = this.timeInterval;

		this.getActivatedAlien().goOnstage();
	} else {
		this.timerText.text = this.timeLeft.toString();
	}
}

AlienTimer.prototype.removeTimer = function() {
	game.time.events.remove(this.timerEvent);
	this.timerEvent = null;
}


AlienTimer.DEFAULT_TEXT_FONT		= {
	font: "bold 30px Arial",
	boundsAlignH: "center",		// left, center. right
	boundsAlignV: "middle", 	// top, middle, bottom
	fill: "#fff"
};

AlienTimer.DEFAULT_TIME_GAP_SEC		= 10;
AlienTimer.MOVE_UP_AMOUNT_PX		= 48;