Fix: apply ScoreManager

This commit is contained in:
2019-01-04 18:43:41 +09:00
parent bc9610dac4
commit 9d11f4034c
3 changed files with 22 additions and 6 deletions
@@ -46,8 +46,10 @@ function FlyingSaucer(lineIndex) {
FlyingSaucer.prototype.initVariables = function() {
this.isActivated = false;
this.wordLevel = 0;
this.score = 0;
this.speed = FlyingSaucer.DEFAULT_SPEED;
this.scoreManager = null;
this.heartManager = null;
this.wordManager = null;
this.gameLevelManager = null;
@@ -94,6 +96,10 @@ FlyingSaucer.prototype.update = function() {
}
}
FlyingSaucer.prototype.setScoreManager = function(scoreManager) {
this.scoreManager = scoreManager;
}
FlyingSaucer.prototype.setHeartManager = function(heartManager) {
this.heartManager = heartManager;
}
@@ -148,13 +154,10 @@ FlyingSaucer.prototype.moveInitialPos = function() {
FlyingSaucer.prototype.startAttack = function() {
this.moveInitialPos();
console.log(this.wordManager);
console.log(this.gameLevelManager);
var wordLevel = this.gameLevelManager.getWordLevel();
console.log(wordLevel);
var word = this.wordManager.getWord(wordLevel);
console.log(word);
this.setWord(word);
this.score = this.gameLevelManager.getWordScore();
this.setActive(true);
}
@@ -195,17 +198,24 @@ FlyingSaucer.prototype.checkWord = function(inputText) {
if(word == inputText) {
this.setWord("");
this.setActive(false);
this.explode();
this.plusScore();
return;
}
}
FlyingSaucer.prototype.explode = function(inputText) {
this.setActive(false);
this.explodeEmitter.start(true, 1000, null, 100);
this.timerEvent = game.time.events.add(Phaser.Timer.SECOND, this.startAttack, this);
}
FlyingSaucer.prototype.plusScore = function(inputText) {
this.scoreManager.plusScore(this.score);
var scoreText = new ScoreText(this.x, this.y, this.score);
}
FlyingSaucer.prototype.crash = function() {
this.moveInitialPos();
this.heartManager.breakHearts(1);