diff --git a/src/de/teamteamteam/spacescooter/entity/LivingEntity.java b/src/de/teamteamteam/spacescooter/entity/LivingEntity.java index b800063..2b76b7f 100644 --- a/src/de/teamteamteam/spacescooter/entity/LivingEntity.java +++ b/src/de/teamteamteam/spacescooter/entity/LivingEntity.java @@ -81,7 +81,16 @@ public abstract class LivingEntity extends CollidableEntity implements Hittable if (this.isAlive() == false) return; // TODO: shield and health logic - this.healthPoints -= damage; + if (this.shieldPoints > 0) { + if (this.shieldPoints < damage) { + this.healthPoints = (damage - this.shieldPoints); + this.shieldPoints = 0; + } else { + this.shieldPoints -= damage; + } + } else { + this.healthPoints -= damage; + } if (this.isAlive() == false) { // Set the correct values for gui indicators this.healthPoints = 0; diff --git a/src/de/teamteamteam/spacescooter/entity/Player.java b/src/de/teamteamteam/spacescooter/entity/Player.java index 0f2d88f..c8e1912 100644 --- a/src/de/teamteamteam/spacescooter/entity/Player.java +++ b/src/de/teamteamteam/spacescooter/entity/Player.java @@ -184,10 +184,21 @@ public class Player extends ShootingEntity implements KeyboardListener { * method for increasing the HealthPoints with the Heal-Item */ public void increaseHealthPoints(int inc) { - if (this.getHealthPoints() <= 85) { - this.setHealthPoints(getHealthPercent() + inc); + if (this.getHealthPoints() <= (StaticValue.HealthPoints - 15)) { + this.setHealthPoints(getHealthPoints() + inc); } else { - this.setHealthPoints(100); + this.setHealthPoints(StaticValue.HealthPoints); + } + } + + /** + * method for increasing the ShieldPoints with the Shield-Item + */ + public void increaseShieldPoints(int inc) { + if (this.getShieldPoints() <= (StaticValue.ShieldPoints - 5)) { + this.setShieldPoints(getShieldPoints() + inc); + } else { + this.setShieldPoints(StaticValue.ShieldPoints); } } diff --git a/src/de/teamteamteam/spacescooter/entity/item/ItemNuke.java b/src/de/teamteamteam/spacescooter/entity/item/ItemNuke.java index 5aaf7a6..4baa2ce 100644 --- a/src/de/teamteamteam/spacescooter/entity/item/ItemNuke.java +++ b/src/de/teamteamteam/spacescooter/entity/item/ItemNuke.java @@ -1,9 +1,17 @@ package de.teamteamteam.spacescooter.entity.item; +import de.teamteamteam.spacescooter.datastructure.ConcurrentIterator; +import de.teamteamteam.spacescooter.entity.Entity; +import de.teamteamteam.spacescooter.entity.LivingEntity; import de.teamteamteam.spacescooter.entity.Player; +import de.teamteamteam.spacescooter.entity.enemy.Enemy; +import de.teamteamteam.spacescooter.screen.Screen; public class ItemNuke extends Item { + + private ConcurrentIterator entityIterator; + public ItemNuke(int x, int y) { super(x, y); this.setImage("images/items/itemNuke.png"); @@ -12,6 +20,13 @@ public class ItemNuke extends Item { @Override public void itemCollected(Player player) { System.out.println("Gotta Nuke 'em All!"); + this.entityIterator = Screen.currentScreen.createEntityIterator(); + entityIterator.reset(); + while (entityIterator.hasNext()) { + Entity entity = entityIterator.next(); + if(entity instanceof Enemy) { + ((LivingEntity) entity).takeDamage(20); + } + } } - } diff --git a/src/de/teamteamteam/spacescooter/entity/item/ItemShield.java b/src/de/teamteamteam/spacescooter/entity/item/ItemShield.java index 56769a5..6a0386f 100644 --- a/src/de/teamteamteam/spacescooter/entity/item/ItemShield.java +++ b/src/de/teamteamteam/spacescooter/entity/item/ItemShield.java @@ -11,6 +11,6 @@ public class ItemShield extends Item { @Override public void itemCollected(Player player) { - player.setShieldPoints(player.getShieldPoints() + 5); + player.increaseShieldPoints(5); } } diff --git a/src/de/teamteamteam/spacescooter/level/Level.java b/src/de/teamteamteam/spacescooter/level/Level.java index 9370d5d..d632f76 100644 --- a/src/de/teamteamteam/spacescooter/level/Level.java +++ b/src/de/teamteamteam/spacescooter/level/Level.java @@ -1,13 +1,17 @@ package de.teamteamteam.spacescooter.level; import java.awt.Point; +import java.awt.event.KeyEvent; import java.util.ArrayList; import de.teamteamteam.spacescooter.background.StarBackground; +import de.teamteamteam.spacescooter.control.Keyboard; import de.teamteamteam.spacescooter.entity.Player; import de.teamteamteam.spacescooter.entity.enemy.EnemyBoss; import de.teamteamteam.spacescooter.entity.enemy.EnemyFour; +import de.teamteamteam.spacescooter.entity.enemy.EnemyOne; import de.teamteamteam.spacescooter.entity.enemy.EnemyThree; +import de.teamteamteam.spacescooter.entity.enemy.EnemyTwo; import de.teamteamteam.spacescooter.entity.item.ItemChance; import de.teamteamteam.spacescooter.screen.GameScreen; import de.teamteamteam.spacescooter.utility.Loader; @@ -25,6 +29,8 @@ public final class Level { * Internal LevelConfig containing all the details about how this Level will manage GamePlay. */ private LevelConfig config; + + ArrayList points = new ArrayList(); /** @@ -45,14 +51,14 @@ public final class Level { new ItemChance(); - ArrayList points = new ArrayList(); + /*ArrayList points = new ArrayList(); points.add(new Point(300,300)); points.add(new Point(600,100)); points.add(new Point(0,500)); - new EnemyFour(800, 400, points); + new EnemyFour(800, 400, points);*/ - new EnemyThree(450, 100); - new EnemyBoss(200, 300); + //new EnemyThree(450, 100); + //new EnemyBoss(200, 300); } /** @@ -63,7 +69,25 @@ public final class Level { * is neccessary to torture the player. */ public void handleUpdateTick() { - + //Debug Spawn Enemy on Press + if (Keyboard.isKeyDown(KeyEvent.VK_1)) { + new EnemyOne(400,400); + } + if (Keyboard.isKeyDown(KeyEvent.VK_2)) { + new EnemyTwo(400,400); + } + if (Keyboard.isKeyDown(KeyEvent.VK_3)) { + new EnemyThree(400,400); + } + if (Keyboard.isKeyDown(KeyEvent.VK_4)) { + points.add(new Point(300,300)); + points.add(new Point(600,100)); + points.add(new Point(0,500)); + new EnemyFour(400,400,points); + } + if (Keyboard.isKeyDown(KeyEvent.VK_0)) { + new EnemyBoss(400,400); + } } /** diff --git a/src/de/teamteamteam/spacescooter/screen/GameScreen.java b/src/de/teamteamteam/spacescooter/screen/GameScreen.java index e4325ab..c894658 100644 --- a/src/de/teamteamteam/spacescooter/screen/GameScreen.java +++ b/src/de/teamteamteam/spacescooter/screen/GameScreen.java @@ -76,6 +76,7 @@ public class GameScreen extends Screen { if (Keyboard.isKeyDown(KeyEvent.VK_ESCAPE)) { this.setOverlay(new GamePausedScreen(this)); } + //Go to GameOverScreen if the game is actually over. if (this.level.isGameOver()) { this.parent.setOverlay(new GameOverScreen(this.parent));