Add: GameLevelManager, WordManager
This commit is contained in:
@@ -39,15 +39,19 @@ function FlyingSaucer(lineIndex) {
|
||||
this.wordText = game.add.text(0, 0, "text", style);
|
||||
this.wordText.anchor.set(0.5);
|
||||
|
||||
this.startAttack();
|
||||
|
||||
// this.setActive(true);
|
||||
this.setActive(true);
|
||||
}
|
||||
|
||||
|
||||
FlyingSaucer.prototype.initVariables = function() {
|
||||
this.isActivated = false;
|
||||
this.wordLevel = 0;
|
||||
this.speed = FlyingSaucer.DEFAULT_SPEED;
|
||||
|
||||
this.heartManager = null;
|
||||
this.wordManager = null;
|
||||
this.gameLevelManager = null;
|
||||
|
||||
this.timerEvent = null;
|
||||
}
|
||||
|
||||
@@ -84,24 +88,32 @@ FlyingSaucer.prototype.update = function() {
|
||||
this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y;
|
||||
|
||||
if(this.y > GAME_SCREEN_SIZE.y - 200)
|
||||
this.moveInitialPos();
|
||||
this.crash();
|
||||
} else {
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
|
||||
FlyingSaucer.prototype.setup = function(wordLevel, speedLevel) {
|
||||
this.wordLevel = wordLevel;
|
||||
this.speedLevel = speedLevel;
|
||||
FlyingSaucer.prototype.setHeartManager = function(heartManager) {
|
||||
this.heartManager = heartManager;
|
||||
}
|
||||
|
||||
FlyingSaucer.prototype.setWordManager = function(wordManager) {
|
||||
this.wordManager = wordManager;
|
||||
}
|
||||
|
||||
FlyingSaucer.prototype.setGameLevelManager = function(gameLevelManager) {
|
||||
this.gameLevelManager = gameLevelManager;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FlyingSaucer.prototype.setWord = function(wordText) {
|
||||
this.wordText.text = wordText;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
FlyingSaucer.prototype.stop = function() {
|
||||
this.body.velocity.setTo(0, 0);
|
||||
}
|
||||
@@ -136,7 +148,13 @@ FlyingSaucer.prototype.moveInitialPos = function() {
|
||||
|
||||
FlyingSaucer.prototype.startAttack = function() {
|
||||
this.moveInitialPos();
|
||||
this.setWord("text");
|
||||
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.setActive(true);
|
||||
}
|
||||
|
||||
@@ -188,6 +206,15 @@ FlyingSaucer.prototype.explode = function(inputText) {
|
||||
this.timerEvent = game.time.events.add(Phaser.Timer.SECOND, this.startAttack, this);
|
||||
}
|
||||
|
||||
FlyingSaucer.prototype.crash = function() {
|
||||
this.moveInitialPos();
|
||||
this.heartManager.breakHearts(1);
|
||||
}
|
||||
|
||||
FlyingSaucer.prototype.destroy = function() {
|
||||
this.setActive(false);
|
||||
this.setWord("");
|
||||
}
|
||||
|
||||
|
||||
FlyingSaucer.loadResource = function() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
function GameLevelManager() {
|
||||
}
|
||||
|
||||
GameLevelManager.prototype.getWordLevel = function() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// GameLevelManager.HEART_MAX_COUNT = 5;
|
||||
@@ -0,0 +1,18 @@
|
||||
function WordManager() {
|
||||
this.wordList = [];
|
||||
|
||||
this.wordList[0] = "hello";
|
||||
this.wordList[1] = "world";
|
||||
|
||||
this.wordIndex = 0;
|
||||
}
|
||||
|
||||
WordManager.prototype.getWord = function(wordLevel) {
|
||||
this.wordIndex = 1 - this.wordIndex;
|
||||
return this.wordList[this.wordIndex];
|
||||
}
|
||||
|
||||
WordManager.prototype.removeWord = function(wordLevel, word) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user