From c810d9d966c8ab319320282ad4833453cdc95b1e Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Tue, 9 Dec 2014 11:15:48 +0100 Subject: [PATCH] Bugfix: Level does not care after the last interval ended. --- .../spacescooter/level/Level.java | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/de/teamteamteam/spacescooter/level/Level.java b/src/de/teamteamteam/spacescooter/level/Level.java index 0509123..9c67e9b 100644 --- a/src/de/teamteamteam/spacescooter/level/Level.java +++ b/src/de/teamteamteam/spacescooter/level/Level.java @@ -84,37 +84,40 @@ public final class Level { public void handleUpdateTick() { //Check whether the current interval is configured int currentIntervalIndex = this.config.getIntervalIndexByCurrentTime(this.levelClock); - if(currentIntervalIndex == -1) return; //Nothing to do - //Fetch the current interval - int[] currentInterval = this.config.intervalList.get(currentIntervalIndex); - int relativeTimeWithinCurrentInterval = this.levelClock - currentInterval[0]; - int intervalLength = currentInterval[1] - currentInterval[0]; - /* - * @see - * Get all the spawnrules for the current interval. - * - 0: Interval this rule belongs to - * - 1: EntityNumber - This helps to find out what Entity to actually spawn. - * - 2: Amount - The amount of Entities to spawn at a time. - * - 3: SpawnRate - The rate at which the Entities are supposed to be spawned. - * - 4: SpawnPosition - percentage of GameConfig.windowHeight - Where the Enemy shall spawn. - */ - for(int[] spawnRule : this.config.spawnRuleList) { - //Skip spawn rules that are not in the current spawn interval. - if(spawnRule[0] != currentIntervalIndex) continue; - //Divide the current interval by spawnrate - int intervalModulus = intervalLength / spawnRule[3]; - //Check whether the spawn rate strikes right now. - if(relativeTimeWithinCurrentInterval % Math.max(1,intervalModulus) == 0) { - //If the rule matches the current time, spawn the configured Entity in the configured amount: - for(int i=0; i + * Get all the spawnrules for the current interval. + * - 0: Interval this rule belongs to + * - 1: EntityNumber - This helps to find out what Entity to actually spawn. + * - 2: Amount - The amount of Entities to spawn at a time. + * - 3: SpawnRate - The rate at which the Entities are supposed to be spawned. + * - 4: SpawnPosition - percentage of GameConfig.windowHeight - Where the Enemy shall spawn. + */ + for(int[] spawnRule : this.config.spawnRuleList) { + //Skip spawn rules that are not in the current spawn interval. + if(spawnRule[0] != currentIntervalIndex) continue; + //Divide the current interval by spawnrate + int intervalModulus = intervalLength / spawnRule[3]; + //Check whether the spawn rate strikes right now. + if(relativeTimeWithinCurrentInterval % Math.max(1,intervalModulus) == 0) { + //If the rule matches the current time, spawn the configured Entity in the configured amount: + for(int i=0; i