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);
+3 -1
View File
@@ -15,7 +15,6 @@ var WordFlyingSaucer = {
);
this.scoreManager = new ScoreManager();
this.scoreBoard = new ScoreBoard();
this.scoreManager.addOnChangeScoreListener(
(function(score) {
sessionStorageManager.setRecord(score);
@@ -48,6 +47,7 @@ var WordFlyingSaucer = {
this.flyingsaucers = [];
for(var i = 0; i < 2; i++) {
this.flyingsaucers[i] = new FlyingSaucer(i);
this.flyingsaucers[i].setScoreManager(this.scoreManager);
this.flyingsaucers[i].setHeartManager(this.heartManager);
this.flyingsaucers[i].setWordManager(this.wordManager);
this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager);
@@ -62,6 +62,8 @@ var WordFlyingSaucer = {
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
screenTopUI.makeFullScreenButton();
this.scoreBoard = new ScoreBoard();
var heartGauge = new HeartGauge(this.heartManager);
heartGauge.start();
@@ -5,5 +5,9 @@ GameLevelManager.prototype.getWordLevel = function() {
return 0;
}
GameLevelManager.prototype.getWordScore = function() {
return 10;
}
// GameLevelManager.HEART_MAX_COUNT = 5;