diff --git a/src/game/typing/word_flyingsaucer/flyingsaucer.js b/src/game/typing/word_flyingsaucer/flyingsaucer.js index 080a1fd..8d28644 100644 --- a/src/game/typing/word_flyingsaucer/flyingsaucer.js +++ b/src/game/typing/word_flyingsaucer/flyingsaucer.js @@ -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); diff --git a/src/game/typing/word_flyingsaucer/game.js b/src/game/typing/word_flyingsaucer/game.js index 1b5388b..91e1231 100644 --- a/src/game/typing/word_flyingsaucer/game.js +++ b/src/game/typing/word_flyingsaucer/game.js @@ -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(); diff --git a/src/game/typing/word_flyingsaucer/game_level_manager.js b/src/game/typing/word_flyingsaucer/game_level_manager.js index bfe79d6..8b48e7a 100644 --- a/src/game/typing/word_flyingsaucer/game_level_manager.js +++ b/src/game/typing/word_flyingsaucer/game_level_manager.js @@ -5,5 +5,9 @@ GameLevelManager.prototype.getWordLevel = function() { return 0; } +GameLevelManager.prototype.getWordScore = function() { + return 10; +} + // GameLevelManager.HEART_MAX_COUNT = 5; \ No newline at end of file