Add: AlienTimer
This commit is contained in:
@@ -6,15 +6,23 @@ class Game {
|
||||
create() {
|
||||
this.game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
this.initListeners();
|
||||
|
||||
// top
|
||||
let backButton = new BackButton( () => {
|
||||
location.href = '../../web/client/menu_app.html';
|
||||
});
|
||||
|
||||
let scoreBoard = new ScoreBoard();
|
||||
scoreManager.addOnChangeScoreListener( score => {
|
||||
scoreBoard.printScore(NumberUtil.numberWithCommas(score));
|
||||
});
|
||||
scoreManager.addOnChangeHighScoreListener( highScore => {
|
||||
screenBottom.printBottomLeftText("최고 기록 : " + NumberUtil.numberWithCommas(highScore));
|
||||
});
|
||||
|
||||
let heartGauge = new HeartGauge(heartManager);
|
||||
heartManager.addOnChangeGameOverListener(
|
||||
() => { this.gameOver(); }
|
||||
);
|
||||
heartGauge.start();
|
||||
|
||||
let fullscreenButton = new FullscreenButton(this.game);
|
||||
@@ -27,17 +35,20 @@ class Game {
|
||||
|
||||
|
||||
// contents
|
||||
this.activatedAlienIndex = 0;
|
||||
// this.activatedAlienIndex = 0;
|
||||
this.aliens = [];
|
||||
for(let i = 0; i < 10; i++) {
|
||||
let alien = new Alien(150 + 80 * i, 150,
|
||||
() => { this.activateNextAlien(); }, // onGoOnstage
|
||||
this.onAlienFired, this.onAlienEscaped);
|
||||
this.onAlienFired, this.onAlienEscaped
|
||||
);
|
||||
alien.goWaitingRoom();
|
||||
alien.setActive(false);
|
||||
this.aliens.push(alien);
|
||||
}
|
||||
|
||||
this.alienTimer = new AlienTimer(this.aliens);
|
||||
|
||||
|
||||
// bottom
|
||||
let screenBottom = new ScreenBottom(game);
|
||||
@@ -54,18 +65,6 @@ class Game {
|
||||
}
|
||||
|
||||
initListeners() {
|
||||
scoreManager.addOnChangeScoreListener( score => {
|
||||
console.log("onChangeScore : " + score);
|
||||
scoreBoard.printScore(NumberUtil.numberWithCommas(score));
|
||||
});
|
||||
scoreManager.addOnChangeHighScoreListener( highScore => {
|
||||
console.log("onChangeHighScore : " + highScore);
|
||||
screenBottom.printBottomLeftText("최고 기록 : " + NumberUtil.numberWithCommas(highScore));
|
||||
});
|
||||
|
||||
heartManager.addOnChangeGameOverListener(
|
||||
() => { this.gameOver(); }
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -101,19 +100,21 @@ class Game {
|
||||
|
||||
startGame() {
|
||||
// activate first alien
|
||||
this.activateNextAlien();
|
||||
this.alienTimer.start();
|
||||
// this.activateNextAlien();
|
||||
}
|
||||
|
||||
gameOver() {
|
||||
console.log("gameOver");
|
||||
this.alienTimer.stop();
|
||||
}
|
||||
|
||||
activateNextAlien() {
|
||||
if(this.activatedAlienIndex === this.aliens.length)
|
||||
return;
|
||||
this.alienTimer.next();
|
||||
// if(this.activatedAlienIndex === this.aliens.length)
|
||||
// return;
|
||||
|
||||
this.aliens[this.activatedAlienIndex].setActive(true);
|
||||
this.activatedAlienIndex++;
|
||||
// this.aliens[this.activatedAlienIndex].setActive(true);
|
||||
// this.activatedAlienIndex++;
|
||||
}
|
||||
|
||||
onAlienFired(sprite) {
|
||||
|
||||
Reference in New Issue
Block a user