From 1c03f9187decef2dcaa609b0ad5c25a654364997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Thu, 6 Dec 2018 00:19:04 +0900 Subject: [PATCH] Fix: sponing timing of missle --- src/game/mouse/dodge/game.js | 63 +++++++++++++++--------------------- 1 file changed, 26 insertions(+), 37 deletions(-) diff --git a/src/game/mouse/dodge/game.js b/src/game/mouse/dodge/game.js index 0f76659..428f99d 100644 --- a/src/game/mouse/dodge/game.js +++ b/src/game/mouse/dodge/game.js @@ -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; \ No newline at end of file +Game.GAME_OVER_WAIT_TIME_MS = 3000; + +Game.MAX_MISSILE_COUNT = 100; \ No newline at end of file