Fix: sponing timing of missle

This commit is contained in:
2018-12-06 00:19:04 +09:00
parent 6bdee84625
commit 1c03f9187d
+26 -37
View File
@@ -7,9 +7,9 @@ var Game = {
create: function() { create: function() {
game.physics.enable(this, Phaser.Physics.ARCADE); 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); sessionStorageManager.setIsNewAppHighestRecord(false);
@@ -40,7 +40,7 @@ var Game = {
this.spaceship = new Spaceship(); this.spaceship = new Spaceship();
this.aliens = []; 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, var alien = new Missile(this.spaceship,
(function() { (function() {
this.spaceship.alpha = 0; this.spaceship.alpha = 0;
@@ -82,9 +82,6 @@ var Game = {
location.href = '../../web/client/menu_app.html'; location.href = '../../web/client/menu_app.html';
}, },
initListeners: function() {
},
countDown: function() { countDown: function() {
var style = { font: "bold 200px Arial", fill: "#fff", wordWrap: true, wordWrapWidth: game.world.centerX, align: "center" }; 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); this.countDownText = game.add.text(game.world.centerX, game.world.centerY, "", style);
@@ -117,46 +114,36 @@ var Game = {
startGame: function() { startGame: function() {
this.stopWatch.start(); this.stopWatch.start();
this.ellapsedTime = 0; this.timerCount = 0;
this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND, this.updateTimer, this); this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND, this.updateTimer, this);
}, },
updateTimer: function() { updateTimer: function() {
this.ellapsedTime += 1; var every5sec = this.timerCount % 5;
// console.log(this.ellapsedTime); if(every5sec == 0) {
var waveNo = this.timerCount / 5;
this.sendWave(waveNo);
}
if(this.ellapsedTime == 2) this.timerCount++;
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);
}, },
sendWave: function(waveNo) { sendWave: function(waveNo) {
if(waveNo == 1) { // console.log("*** " + waveNo + " ***");
for(var i = 0; i < 20; i++) if(this.indexMissile >= Game.MAX_MISSILE_COUNT)
this.aliens[i].setActive(true);
return; return;
}
var beginAlienIndex = waveNo * 10; var beginAlienIndex = waveNo * 5;
var endAlienIndex = (waveNo + 1) * 10; var endAlienIndex = (waveNo + 1) * 5;
for(var i = beginAlienIndex; i < endAlienIndex; i++) for(this.indexMissile = beginAlienIndex; this.indexMissile < endAlienIndex; this.indexMissile++) {
this.aliens[i].setActive(true); 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() { 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;