Nuke now work (but dirty)

Enemys Spawn now with Button Presses (1,2,3,4,0) [Debug]
Fix ItemShield Add Value
Fix Player IncreaseHealth
Added Player IncreaseShield
This commit is contained in:
JJTCM 2014-11-25 12:35:52 +01:00
parent 00f48ad4a7
commit 0e78d28e72
6 changed files with 71 additions and 11 deletions

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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<Entity> 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);
}
}
}
}

View File

@ -11,6 +11,6 @@ public class ItemShield extends Item {
@Override
public void itemCollected(Player player) {
player.setShieldPoints(player.getShieldPoints() + 5);
player.increaseShieldPoints(5);
}
}

View File

@ -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<Point> points = new ArrayList<Point>();
/**
@ -45,14 +51,14 @@ public final class Level {
new ItemChance();
ArrayList<Point> points = new ArrayList<Point>();
/*ArrayList<Point> points = new ArrayList<Point>();
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);
}
}
/**

View File

@ -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));