Fix: apply ScoreManager
This commit is contained in:
@@ -46,8 +46,10 @@ function FlyingSaucer(lineIndex) {
|
|||||||
FlyingSaucer.prototype.initVariables = function() {
|
FlyingSaucer.prototype.initVariables = function() {
|
||||||
this.isActivated = false;
|
this.isActivated = false;
|
||||||
this.wordLevel = 0;
|
this.wordLevel = 0;
|
||||||
|
this.score = 0;
|
||||||
this.speed = FlyingSaucer.DEFAULT_SPEED;
|
this.speed = FlyingSaucer.DEFAULT_SPEED;
|
||||||
|
|
||||||
|
this.scoreManager = null;
|
||||||
this.heartManager = null;
|
this.heartManager = null;
|
||||||
this.wordManager = null;
|
this.wordManager = null;
|
||||||
this.gameLevelManager = 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) {
|
FlyingSaucer.prototype.setHeartManager = function(heartManager) {
|
||||||
this.heartManager = heartManager;
|
this.heartManager = heartManager;
|
||||||
}
|
}
|
||||||
@@ -148,13 +154,10 @@ FlyingSaucer.prototype.moveInitialPos = function() {
|
|||||||
|
|
||||||
FlyingSaucer.prototype.startAttack = function() {
|
FlyingSaucer.prototype.startAttack = function() {
|
||||||
this.moveInitialPos();
|
this.moveInitialPos();
|
||||||
console.log(this.wordManager);
|
|
||||||
console.log(this.gameLevelManager);
|
|
||||||
var wordLevel = this.gameLevelManager.getWordLevel();
|
var wordLevel = this.gameLevelManager.getWordLevel();
|
||||||
console.log(wordLevel);
|
|
||||||
var word = this.wordManager.getWord(wordLevel);
|
var word = this.wordManager.getWord(wordLevel);
|
||||||
console.log(word);
|
|
||||||
this.setWord(word);
|
this.setWord(word);
|
||||||
|
this.score = this.gameLevelManager.getWordScore();
|
||||||
this.setActive(true);
|
this.setActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,17 +198,24 @@ FlyingSaucer.prototype.checkWord = function(inputText) {
|
|||||||
|
|
||||||
if(word == inputText) {
|
if(word == inputText) {
|
||||||
this.setWord("");
|
this.setWord("");
|
||||||
|
this.setActive(false);
|
||||||
|
|
||||||
this.explode();
|
this.explode();
|
||||||
|
this.plusScore();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.explode = function(inputText) {
|
FlyingSaucer.prototype.explode = function(inputText) {
|
||||||
this.setActive(false);
|
|
||||||
this.explodeEmitter.start(true, 1000, null, 100);
|
this.explodeEmitter.start(true, 1000, null, 100);
|
||||||
this.timerEvent = game.time.events.add(Phaser.Timer.SECOND, this.startAttack, this);
|
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() {
|
FlyingSaucer.prototype.crash = function() {
|
||||||
this.moveInitialPos();
|
this.moveInitialPos();
|
||||||
this.heartManager.breakHearts(1);
|
this.heartManager.breakHearts(1);
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ var WordFlyingSaucer = {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.scoreManager = new ScoreManager();
|
this.scoreManager = new ScoreManager();
|
||||||
this.scoreBoard = new ScoreBoard();
|
|
||||||
this.scoreManager.addOnChangeScoreListener(
|
this.scoreManager.addOnChangeScoreListener(
|
||||||
(function(score) {
|
(function(score) {
|
||||||
sessionStorageManager.setRecord(score);
|
sessionStorageManager.setRecord(score);
|
||||||
@@ -48,6 +47,7 @@ var WordFlyingSaucer = {
|
|||||||
this.flyingsaucers = [];
|
this.flyingsaucers = [];
|
||||||
for(var i = 0; i < 2; i++) {
|
for(var i = 0; i < 2; i++) {
|
||||||
this.flyingsaucers[i] = new FlyingSaucer(i);
|
this.flyingsaucers[i] = new FlyingSaucer(i);
|
||||||
|
this.flyingsaucers[i].setScoreManager(this.scoreManager);
|
||||||
this.flyingsaucers[i].setHeartManager(this.heartManager);
|
this.flyingsaucers[i].setHeartManager(this.heartManager);
|
||||||
this.flyingsaucers[i].setWordManager(this.wordManager);
|
this.flyingsaucers[i].setWordManager(this.wordManager);
|
||||||
this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager);
|
this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager);
|
||||||
@@ -62,6 +62,8 @@ var WordFlyingSaucer = {
|
|||||||
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
|
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
|
||||||
screenTopUI.makeFullScreenButton();
|
screenTopUI.makeFullScreenButton();
|
||||||
|
|
||||||
|
this.scoreBoard = new ScoreBoard();
|
||||||
|
|
||||||
var heartGauge = new HeartGauge(this.heartManager);
|
var heartGauge = new HeartGauge(this.heartManager);
|
||||||
heartGauge.start();
|
heartGauge.start();
|
||||||
|
|
||||||
|
|||||||
@@ -5,5 +5,9 @@ GameLevelManager.prototype.getWordLevel = function() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameLevelManager.prototype.getWordScore = function() {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// GameLevelManager.HEART_MAX_COUNT = 5;
|
// GameLevelManager.HEART_MAX_COUNT = 5;
|
||||||
Reference in New Issue
Block a user