This commit is contained in:
Sosch 2014-11-25 14:53:58 +01:00
commit 8048486fa6
10 changed files with 37 additions and 17 deletions

View File

@ -1,10 +1,12 @@
name:Lustiger Levelname name:Lustiger Levelname
backgroundMusic:music/bla.wav backgroundMusic:music/bla.wav
background:FooBackground background:StarBackground
- -
[0-20] [0-4]
spawn:EnemyTwo,2,2 spawn:EnemyOne,1,1
[21-25] [5-10]
spawn:EnemyTwo,2,10
[11-25]
spawn:EnemyThree,2,4 spawn:EnemyThree,2,4
spawn:EnemyTwo,5,6 spawn:EnemyTwo,5,6
[26-30] [26-30]

View File

@ -109,8 +109,7 @@ public abstract class LivingEntity extends CollidableEntity implements Hittable
* The default way the LivingEntity explodes. Override this method for a * The default way the LivingEntity explodes. Override this method for a
* different explosion behaviour. * different explosion behaviour.
*/ */
public void explode() { public abstract void explode();
}
/** /**
* The default way the LivingEntity dies. Override this method for a * The default way the LivingEntity dies. Override this method for a

View File

@ -126,7 +126,6 @@ public class Player extends ShootingEntity implements KeyboardListener {
*/ */
@Override @Override
public void explode() { public void explode() {
super.explode();
SoundSystem.playSound("sounds/abgang.wav"); SoundSystem.playSound("sounds/abgang.wav");
} }

View File

@ -40,7 +40,7 @@ public abstract class Enemy extends ShootingEntity {
if(willShoot == true){ if(willShoot == true){
this.shoot(); this.shoot();
} }
if(this.getX() < 0-getWidth()){ if(this.getX() < 0-this.getWidth()) {
this.remove(); this.remove();
} }
} }

View File

@ -37,7 +37,6 @@ public class EnemyBossMinion extends Enemy{
/** /**
* Custom MultiExplosion for this enemy. * Custom MultiExplosion for this enemy.
*/ */
@Override
public void explode() { public void explode() {
new MultiExplosion(this.getX(), this.getY()); new MultiExplosion(this.getX(), this.getY());
} }
@ -45,12 +44,12 @@ public class EnemyBossMinion extends Enemy{
@Override @Override
public void update() { public void update() {
super.update(); super.update();
this.setPosition(this.getX()-1, this.getY()); this.transpose(-1, 0);
Player player = GameScreen.getPlayer(); Player player = GameScreen.getPlayer();
if(this.getY() < player.getY()){ if(this.getY() < player.getY()){
this.newY += ySpeed; this.newY += ySpeed;
this.setPosition(this.getX(), (int) newY); this.setPosition(this.getX(), (int) newY);
}else if(this.getY() > player.getY()){ } else if(this.getY() > player.getY()) {
this.newY -= ySpeed; this.newY -= ySpeed;
this.setPosition(this.getX(), (int) newY); this.setPosition(this.getX(), (int) newY);
} }

View File

@ -3,6 +3,8 @@ package de.teamteamteam.spacescooter.entity.enemy;
import java.awt.Point; import java.awt.Point;
import java.util.ArrayList; import java.util.ArrayList;
import de.teamteamteam.spacescooter.entity.explosion.ExplosionOne;
public class EnemyFour extends Enemy{ public class EnemyFour extends Enemy{
private ArrayList<Point> points; private ArrayList<Point> points;
@ -63,5 +65,10 @@ public class EnemyFour extends Enemy{
this.remove(); this.remove();
} }
} }
@Override
public void explode() {
new ExplosionOne(this.getX(), this.getY());
}
} }

View File

@ -1,5 +1,7 @@
package de.teamteamteam.spacescooter.entity.enemy; package de.teamteamteam.spacescooter.entity.enemy;
import de.teamteamteam.spacescooter.entity.explosion.ExplosionOne;
public class EnemyOne extends Enemy { public class EnemyOne extends Enemy {
public EnemyOne(int x, int y) { public EnemyOne(int x, int y) {
@ -20,5 +22,10 @@ public class EnemyOne extends Enemy {
public void update() { public void update() {
super.update(); super.update();
} }
@Override
public void explode() {
new ExplosionOne(this.getX(), this.getY());
}
} }

View File

@ -1,5 +1,6 @@
package de.teamteamteam.spacescooter.entity.enemy; package de.teamteamteam.spacescooter.entity.enemy;
import de.teamteamteam.spacescooter.entity.explosion.ExplosionTwo;
import de.teamteamteam.spacescooter.utility.GameConfig; import de.teamteamteam.spacescooter.utility.GameConfig;
import de.teamteamteam.spacescooter.utility.Random; import de.teamteamteam.spacescooter.utility.Random;
@ -28,5 +29,10 @@ public class EnemyTwo extends Enemy{
this.remove(); this.remove();
} }
} }
@Override
public void explode() {
new ExplosionTwo(this.getX(), this.getY());
}
} }

View File

@ -41,7 +41,6 @@ public final class Level {
public Level(String levelConfig) { public Level(String levelConfig) {
this.levelClock = 0; this.levelClock = 0;
this.config = Loader.getLevelConfigByFilename(levelConfig); this.config = Loader.getLevelConfigByFilename(levelConfig);
System.out.println(this.config);
} }
@ -49,7 +48,7 @@ public final class Level {
* Initialize the level based on the LevelConfig attributes. * Initialize the level based on the LevelConfig attributes.
*/ */
public void doBuildUp() { public void doBuildUp() {
new StarBackground(0, 50); this.spawnEntityByAvailableName(Entity.availableNames.valueOf(this.config.background), 0, 50);
GameScreen.setPlayer(new Player(200, 300)); GameScreen.setPlayer(new Player(200, 300));
} }
@ -74,8 +73,6 @@ public final class Level {
if (Keyboard.isKeyDown(KeyEvent.VK_0)) { if (Keyboard.isKeyDown(KeyEvent.VK_0)) {
new EnemyBoss(400,400); new EnemyBoss(400,400);
} }
//Increase levelClock
this.levelClock++;
//Check whether the current interval is configured //Check whether the current interval is configured
int currentIntervalIndex = this.config.getIntervalIndexByCurrentTime(this.levelClock); int currentIntervalIndex = this.config.getIntervalIndexByCurrentTime(this.levelClock);
if(currentIntervalIndex == -1) return; //Nothing to do if(currentIntervalIndex == -1) return; //Nothing to do
@ -105,6 +102,8 @@ public final class Level {
} }
} }
} }
//Increase levelClock
this.levelClock++;
} }
/** /**
@ -122,6 +121,9 @@ public final class Level {
*/ */
private void spawnEntityByAvailableName(Entity.availableNames entity, int x, int y) { private void spawnEntityByAvailableName(Entity.availableNames entity, int x, int y) {
switch(entity) { switch(entity) {
case StarBackground:
new StarBackground(x, y);
break;
case EnemyOne: case EnemyOne:
new EnemyOne(x, y); new EnemyOne(x, y);
break; break;

View File

@ -93,7 +93,7 @@ public class LevelConfig {
*/ */
public int getIntervalIndexByCurrentTime(int time) { public int getIntervalIndexByCurrentTime(int time) {
for(int[] interval : this.intervalList) { for(int[] interval : this.intervalList) {
if(interval[0] <= time && interval[1] >= time) { if(time >= interval[0] && time < interval[1]) {
return this.intervalList.indexOf(interval); return this.intervalList.indexOf(interval);
} }
} }
@ -104,7 +104,6 @@ public class LevelConfig {
* Add a given EntitySpawnRule to the ruleList. * Add a given EntitySpawnRule to the ruleList.
*/ */
public void addEntitySpawnRule(int intervalStart, int intervalEnd, String entityName, int amount, int spawnRate) { public void addEntitySpawnRule(int intervalStart, int intervalEnd, String entityName, int amount, int spawnRate) {
System.out.println("Adding rule for " + intervalStart + " to " + intervalEnd + ": " + entityName + ", " + amount + ", " + spawnRate);
int intervalIndex = this.getIntervalIndexByBorders(intervalStart, intervalEnd); int intervalIndex = this.getIntervalIndexByBorders(intervalStart, intervalEnd);
if(intervalIndex == -1) { if(intervalIndex == -1) {
System.err.println("No Interval for rule found!"); System.err.println("No Interval for rule found!");