Fix: sponing timing of missle
This commit is contained in:
@@ -7,9 +7,9 @@ var Game = {
|
||||
create: function() {
|
||||
game.physics.enable(this, Phaser.Physics.ARCADE);
|
||||
|
||||
this.game.stage.backgroundColor = "#000000"; // '#4d4d4d';
|
||||
this.indexMissile = 0;
|
||||
|
||||
// this.scoreManager = new ScoreManager();
|
||||
this.game.stage.backgroundColor = "#000000"; // '#4d4d4d';
|
||||
|
||||
sessionStorageManager.setIsNewAppHighestRecord(false);
|
||||
|
||||
@@ -40,7 +40,7 @@ var Game = {
|
||||
this.spaceship = new Spaceship();
|
||||
|
||||
this.aliens = [];
|
||||
for(var i = 0; i < 100; i++) {
|
||||
for(var i = 0; i < Game.MAX_MISSILE_COUNT; i++) {
|
||||
var alien = new Missile(this.spaceship,
|
||||
(function() {
|
||||
this.spaceship.alpha = 0;
|
||||
@@ -82,9 +82,6 @@ var Game = {
|
||||
location.href = '../../web/client/menu_app.html';
|
||||
},
|
||||
|
||||
initListeners: function() {
|
||||
},
|
||||
|
||||
countDown: function() {
|
||||
var style = { font: "bold 200px Arial", fill: "#fff", wordWrap: true, wordWrapWidth: game.world.centerX, align: "center" };
|
||||
this.countDownText = game.add.text(game.world.centerX, game.world.centerY, "", style);
|
||||
@@ -117,46 +114,36 @@ var Game = {
|
||||
|
||||
startGame: function() {
|
||||
this.stopWatch.start();
|
||||
this.ellapsedTime = 0;
|
||||
this.timerCount = 0;
|
||||
this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND, this.updateTimer, this);
|
||||
},
|
||||
|
||||
updateTimer: function() {
|
||||
this.ellapsedTime += 1;
|
||||
// console.log(this.ellapsedTime);
|
||||
var every5sec = this.timerCount % 5;
|
||||
if(every5sec == 0) {
|
||||
var waveNo = this.timerCount / 5;
|
||||
this.sendWave(waveNo);
|
||||
}
|
||||
|
||||
if(this.ellapsedTime == 2)
|
||||
this.sendWave(1);
|
||||
else if(this.ellapsedTime == 4)
|
||||
this.sendWave(2);
|
||||
else if(this.ellapsedTime == 6)
|
||||
this.sendWave(3);
|
||||
else if(this.ellapsedTime == 8)
|
||||
this.sendWave(4);
|
||||
else if(this.ellapsedTime == 10)
|
||||
this.sendWave(5);
|
||||
else if(this.ellapsedTime == 12)
|
||||
this.sendWave(6);
|
||||
else if(this.ellapsedTime == 14)
|
||||
this.sendWave(7);
|
||||
else if(this.ellapsedTime == 16)
|
||||
this.sendWave(8);
|
||||
else if(this.ellapsedTime == 18)
|
||||
this.sendWave(9);
|
||||
this.timerCount++;
|
||||
},
|
||||
|
||||
sendWave: function(waveNo) {
|
||||
if(waveNo == 1) {
|
||||
for(var i = 0; i < 20; i++)
|
||||
this.aliens[i].setActive(true);
|
||||
|
||||
// console.log("*** " + waveNo + " ***");
|
||||
if(this.indexMissile >= Game.MAX_MISSILE_COUNT)
|
||||
return;
|
||||
}
|
||||
|
||||
var beginAlienIndex = waveNo * 10;
|
||||
var endAlienIndex = (waveNo + 1) * 10;
|
||||
for(var i = beginAlienIndex; i < endAlienIndex; i++)
|
||||
this.aliens[i].setActive(true);
|
||||
var beginAlienIndex = waveNo * 5;
|
||||
var endAlienIndex = (waveNo + 1) * 5;
|
||||
for(this.indexMissile = beginAlienIndex; this.indexMissile < endAlienIndex; this.indexMissile++) {
|
||||
if(this.indexMissile > Game.MAX_MISSILE_COUNT) {
|
||||
this.indexMissile = Game.MAX_MISSILE_COUNT;
|
||||
return;
|
||||
}
|
||||
|
||||
this.aliens[this.indexMissile].setActive(true);
|
||||
// console.log(this.indexMissile);
|
||||
}
|
||||
},
|
||||
|
||||
gameOver: function() {
|
||||
@@ -192,4 +179,6 @@ var Game = {
|
||||
|
||||
}
|
||||
|
||||
Game.GAME_OVER_WAIT_TIME_MS = 3000;
|
||||
Game.GAME_OVER_WAIT_TIME_MS = 3000;
|
||||
|
||||
Game.MAX_MISSILE_COUNT = 100;
|
||||
Reference in New Issue
Block a user