Add: GameLevelManager, WordManager

This commit is contained in:
2019-01-04 18:32:22 +09:00
parent 1aeff26072
commit bc9610dac4
5 changed files with 118 additions and 43 deletions
+52 -33
View File
@@ -6,38 +6,14 @@ var WordFlyingSaucer = {
sessionStorageManager.setIsNewAppHighestRecord(false);
this.initVariables();
var experienceAppTimer = new ExperienceAppTimer();
experienceAppTimer.setTimeOverListener(
(function() { this.timeOver(); }).bind(this)
);
this.initVariables();
// game stage
this.game.stage.backgroundColor = "#000000"; // '#4d4d4d';
var stars = game.add.group();
for (var i = 0; i < 128; i++) {
var randomY = game.rnd.integerInRange(60, GAME_SCREEN_SIZE.y - 80);
stars.create(game.world.randomX, randomY, 'star');
}
this.flyingsaucers = [];
for(var i = 0; i < 2; i++) {
this.flyingsaucers[i] = new FlyingSaucer(i);
this.flyingsaucers[i].setup(this.wordLevel, this.speedLevel);
this.flyingsaucers[i].setActive(true);
}
// top ui
var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
screenTopUI.makeFullScreenButton();
this.scoreManager = new ScoreManager();
this.scoreBoard = new ScoreBoard();
this.scoreManager.addOnChangeScoreListener(
@@ -55,16 +31,41 @@ var WordFlyingSaucer = {
}).bind(this)
);
var heartManager = new HeartManager();
var heartGauge = new HeartGauge(heartManager);
heartManager.addOnChangeGameOverListener(
this.heartManager = new HeartManager();
this.heartManager.addOnChangeGameOverListener(
(function() { this.gameOver(); }).bind(this)
);
// game stage
this.game.stage.backgroundColor = "#000000"; // '#4d4d4d';
var stars = game.add.group();
for (var i = 0; i < 128; i++) {
var randomY = game.rnd.integerInRange(60, GAME_SCREEN_SIZE.y - 80);
stars.create(game.world.randomX, randomY, 'star');
}
this.flyingsaucers = [];
for(var i = 0; i < 2; i++) {
this.flyingsaucers[i] = new FlyingSaucer(i);
this.flyingsaucers[i].setHeartManager(this.heartManager);
this.flyingsaucers[i].setWordManager(this.wordManager);
this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager);
this.flyingsaucers[i].setActive(true);
this.flyingsaucers[i].startAttack();
}
// top ui
var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
screenTopUI.makeFullScreenButton();
var heartGauge = new HeartGauge(this.heartManager);
heartGauge.start();
// input text
var INPUT_TEXT_Y = 680;
this.inputText = new InputTypeText(game.world.centerX, INPUT_TEXT_Y);
@@ -101,7 +102,9 @@ var WordFlyingSaucer = {
initVariables: function() {
this.wordLevel = 0;
this.wordManager = new WordManager();
this.gameLevelManager = new GameLevelManager();
this.speedLevel = 0;
},
@@ -133,6 +136,22 @@ var WordFlyingSaucer = {
location.href = '../../web/client/result.html';
},
gameOver: function() {
var gameOverText = new GameOverText();
// this.updateResultRecord();
this.stopAndGoResult();
},
stopAndGoResult: function() {
// remove all flyingsaucers
var count = this.flyingsaucers.length;
for(var i = 0; i < count; i++) {
this.flyingsaucers[i].destroy();
}
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
},
checkTypingContents: function(event) {
var count = this.flyingsaucers.length;