From d2e28477f0fa0cbacbb80b11fb80ce22ef4255f4 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Tue, 25 Nov 2014 11:46:23 +0100 Subject: [PATCH] Add spawn-Rules to LevelConfigParser feature set. --- res/levels/test.level | 5 +++-- src/de/teamteamteam/spacescooter/level/Level.java | 8 +------- .../spacescooter/level/LevelConfigParser.java | 9 +++++++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/res/levels/test.level b/res/levels/test.level index f26251c..2931038 100644 --- a/res/levels/test.level +++ b/res/levels/test.level @@ -1,10 +1,11 @@ name:Lustiger Levelname backgroundMusic:music/bla.wav background:FooBackground -bossEnemy:TheBigOne - [0-2025] spawn:GegnerOne,2,6 [2026-2168] spawn:GegnerOne,2,4 -spawn:GegnerTwo,5,6 \ No newline at end of file +spawn:GegnerTwo,5,6 +[2169-2170] +spawn:BossGegner,1,1 \ No newline at end of file diff --git a/src/de/teamteamteam/spacescooter/level/Level.java b/src/de/teamteamteam/spacescooter/level/Level.java index aae901e..9370d5d 100644 --- a/src/de/teamteamteam/spacescooter/level/Level.java +++ b/src/de/teamteamteam/spacescooter/level/Level.java @@ -9,10 +9,6 @@ import de.teamteamteam.spacescooter.entity.enemy.EnemyBoss; import de.teamteamteam.spacescooter.entity.enemy.EnemyFour; import de.teamteamteam.spacescooter.entity.enemy.EnemyThree; import de.teamteamteam.spacescooter.entity.item.ItemChance; -import de.teamteamteam.spacescooter.gui.HealthBar; -import de.teamteamteam.spacescooter.gui.InterfaceBar; -import de.teamteamteam.spacescooter.gui.ScoreBar; -import de.teamteamteam.spacescooter.gui.ShieldBar; import de.teamteamteam.spacescooter.screen.GameScreen; import de.teamteamteam.spacescooter.utility.Loader; @@ -44,6 +40,7 @@ public final class Level { * Initialize the level based on the LevelConfig attributes. */ public void doBuildUp() { + new StarBackground(0, 50); GameScreen.setPlayer(new Player(200, 300)); @@ -53,9 +50,6 @@ public final class Level { points.add(new Point(600,100)); points.add(new Point(0,500)); new EnemyFour(800, 400, points); - - new StarBackground(0, 50); - new EnemyThree(450, 100); new EnemyBoss(200, 300); diff --git a/src/de/teamteamteam/spacescooter/level/LevelConfigParser.java b/src/de/teamteamteam/spacescooter/level/LevelConfigParser.java index e25508b..507b15b 100644 --- a/src/de/teamteamteam/spacescooter/level/LevelConfigParser.java +++ b/src/de/teamteamteam/spacescooter/level/LevelConfigParser.java @@ -80,8 +80,13 @@ public class LevelConfigParser { this.currentIntervalEnd = Integer.parseInt(intervalBorder[1]); this.levelConfig.addIntervalToList(this.currentIntervalStart, this.currentIntervalEnd); } else { - String[] entitySpawnRule = line.split(",", 3); - this.levelConfig.addEntitySpawnRule(this.currentIntervalStart, this.currentIntervalEnd, entitySpawnRule[0], Integer.parseInt(entitySpawnRule[1]), Integer.parseInt(entitySpawnRule[2])); + String[] rule = line.split(":", 2); + if(rule[0].equals("spawn")) { + String[] entitySpawnRule = rule[1].split(",", 3); + this.levelConfig.addEntitySpawnRule(this.currentIntervalStart, this.currentIntervalEnd, entitySpawnRule[0], Integer.parseInt(entitySpawnRule[1]), Integer.parseInt(entitySpawnRule[2])); + } else { + System.err.println("Unknown rule type: '"+rule[0]+"' : '"+line+"'"); + } } break; default: