|
|
|
|
@@ -11,8 +11,10 @@ import main.entities.LivingEntity;
|
|
|
|
|
|
|
|
|
|
public class Player extends LivingEntity {
|
|
|
|
|
|
|
|
|
|
private static SheetLoader loader = new SheetLoader("/res/images/player_sprite_sheet.png", 64, 32, new int[] { 5, 8, 7, 6, 2, 5, 4, 7 });
|
|
|
|
|
private static SheetLoader loader = new SheetLoader("/res/images/player_sprite_sheet.png", 64, 32,
|
|
|
|
|
new int[] { 5, 8, 7, 6, 2, 5, 4, 7 });
|
|
|
|
|
private boolean onlyAttackOnceTrigger;
|
|
|
|
|
private float range = 1.2f; // die reichweite der Attacke
|
|
|
|
|
|
|
|
|
|
public Player() {
|
|
|
|
|
super(loader.getFigur(0), "idle");
|
|
|
|
|
@@ -46,8 +48,8 @@ public class Player extends LivingEntity {
|
|
|
|
|
if (!((actionFigur.aktuellesVerhalten().equals("strike"))
|
|
|
|
|
&& actionFigur.aktuelleFigur().aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
|
|
|
|
// Bei diser soll man sich nicht bewegen können aber weiter rutschen
|
|
|
|
|
if (!((actionFigur.aktuellesVerhalten().equals("swipe"))
|
|
|
|
|
&& actionFigur.aktuelleFigur().aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
|
|
|
|
if (!((actionFigur.aktuellesVerhalten().equals("swipe")) && actionFigur.aktuelleFigur()
|
|
|
|
|
.aktuellesBild() < actionFigur.aktuelleFigur().animation().length - 1)) {
|
|
|
|
|
|
|
|
|
|
// wasd movement
|
|
|
|
|
if (Main.instance.tasteGedrueckt(Taste.A)) {
|
|
|
|
|
@@ -95,18 +97,21 @@ public class Player extends LivingEntity {
|
|
|
|
|
// auf Kollisionen prüfen
|
|
|
|
|
checkTileCollisions(Main.instance.getWorld().getCurrentMap());
|
|
|
|
|
|
|
|
|
|
if (!onlyAttackOnceTrigger && actionFigur.aktuellesVerhalten().equals("swipe") && actionFigur.aktuelleFigur().aktuellesBild() == 1) {
|
|
|
|
|
if (!onlyAttackOnceTrigger && actionFigur.aktuellesVerhalten().equals("swipe")
|
|
|
|
|
&& actionFigur.aktuelleFigur().aktuellesBild() == 1) {
|
|
|
|
|
onlyAttackOnceTrigger = true;
|
|
|
|
|
ArrayList<Entity> entities = Main.instance.getWorld().getCurrentMap().getEntities();
|
|
|
|
|
for (Entity e : entities) {
|
|
|
|
|
if (e instanceof LivingEntity && e != this && e.dist(this) <= 1f) {
|
|
|
|
|
if (e instanceof LivingEntity && e != this && e.dist(this) <= range) {
|
|
|
|
|
LivingEntity le = (LivingEntity) e;
|
|
|
|
|
Vektor toE = vectorToEntity(le);
|
|
|
|
|
toE = toE.normiert();
|
|
|
|
|
if ((toE.x > 0 && !side) || (toE.x <= 0 && side)) {
|
|
|
|
|
le.setVelX(le.getVelX() + toE.x * 0.1f);
|
|
|
|
|
le.setVelY(le.getVelY() + toE.y * 0.1f);
|
|
|
|
|
le.takeDamage(0.1f, this);
|
|
|
|
|
if (le.getHP() > 0) {
|
|
|
|
|
Vektor toE = vectorToEntity(le);
|
|
|
|
|
toE = toE.normiert();
|
|
|
|
|
if ((toE.x > 0 && !side) || (toE.x <= 0 && side)) {
|
|
|
|
|
le.setVelX(le.getVelX() + toE.x * 0.1f);
|
|
|
|
|
le.setVelY(le.getVelY() + toE.y * 0.1f);
|
|
|
|
|
le.takeDamage(0.1f, this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|