var EHDI = EHDI || Object.create(null);
EHDI.GAME = EHDI.GAME || Object.create(null);
EHDI.GAME.components = EHDI.GAME.components || Object.create(null);
EHDI.GAME.components.Score = function(container) {
this.val = 0;
this.scoreManager = new EHDI.components.ScoreManager(container);
this.scoreManager.setXY(20, 20);
this.timer = new EHDI.components.Timer();
this.timer.position.set(350, 20);
container.addChild(this.timer);
}
EHDI.GAME.components.Score.prototype.startTimer = function(func, time) {
if(!func || !time)
this.timer.start();
else
this.timer = new EHDI.GAME.Timer(func, time);
}
EHDI.GAME.components.Score.prototype.stopTimer = function() {
this.timer.pause();
}
EHDI.GAME.components.Score.prototype.resetTimer = function(func, time) {
this.stopTimer();
this.startTimer(func, time);
}
EHDI.GAME.components.Score.prototype.updateScore = function() {
var toAdd = Math.ceil(this.timer.timeLeft);
this.val += toAdd;
// console.log(this.val)
this.scoreManager.addScore(toAdd);
}
EHDI.GAME.components.Score.prototype.resetScore = function() {
this.scoreManager.addScore(-this.val);
this.val = 0;
}
EHDI.GAME.components.Score.prototype.updateTime = function(time) {
var timeToAdd = time - Math.ceil(this.timer.timeLeft);
// EHDI.GAME.soundManager.playSFX("score_points");
this.timer.addTime(timeToAdd);
}