Merge branch 'jonathan2'

asöldkfja
master
Jonathan Hager 6 years ago
commit 35ffa07e9b

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.9 MiB

@ -117,8 +117,15 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
public void run() {
if(gs != null){
if(gs.player.getAttackState() == 2){
/*if(d.getPlayer().isToDelete() && checkDie){
if(gs.player.getDie() == 0){
gs.player.setDie(1);
}
else if(gs.player.getDie() == 2){
// Ist Tot
}
}
else*/ if(gs.player.getAttackState() == 2){
playerAttack(d.getCurrentEntities(), d.getPlayer(), d.getPlayer().getDirection());
}
@ -136,7 +143,9 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
int y = (int) temp.getyPos();
boolean attacks = d.getCurrentEntities()[i].move((int) d.getPlayer().getxPos(), (int) d.getPlayer().getyPos());
if(d.getPlayer().isToDelete()){
attacks = false;
}
// Attacke wird gestartet, wenn noch keine laueft
if(attacks && gs.entitySprites[i].getAttackState() == 0){
gs.entitySprites[i].startAttack();
@ -156,7 +165,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
d.getCurrentEntities()[i].attack(d.getPlayer());
}
else{
if(d.getCurrentEntities()[i].getType() == 0){
if(d.getCurrentEntities()[i].getType() == 0 && !d.getPlayer().isToDelete()){
switch(gs.entitySprites[i].getAttackState()){
case 0:
gs.entitySprites[i].startAttack();
@ -437,8 +446,16 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
}
if(d.getPlayer().getHp() <= 0 && checkDie){
gs.stop();
create(); //TODO
//gs.stop();
//create(); //TODO
d.getPlayer().setHp(1);
if(gs.player.getDie() == 0){
gs.player.setDie(1);
d.getPlayer().setToDelete(true);
}
else if(gs.player.getDie() == 2){
// Ist Tot
}
}
d.getPlayer().updateDirection();
@ -610,7 +627,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.A){
if(mm != null){
}
if(gs != null){
if(gs != null && !d.getPlayer().isToDelete()){
d.getPlayer().setMovementX(-3f);
}
}
@ -618,7 +635,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.D){
if(mm != null){
}
if(gs != null){
if(gs != null && !d.getPlayer().isToDelete()){
d.getPlayer().setMovementX(+3f);
}
}
@ -626,7 +643,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.S){
if(mm != null){
}
if(gs != null){
if(gs != null && !d.getPlayer().isToDelete()){
d.getPlayer().setMovementY(-3f);
}
}
@ -634,14 +651,14 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.W){
if(mm != null){
}
if(gs != null){
if(gs != null && !d.getPlayer().isToDelete()){
d.getPlayer().setMovementY(3f);
}
}
if(keycode == Input.Keys.SPACE){
if(mm != null){}
if(gs != null && gs.getIsLoading() == false){
if(gs != null && gs.getIsLoading() == false && !d.getPlayer().isToDelete()){
d.setCurrentEntities(playerAttack(d.getCurrentEntities(), d.getPlayer(), 0));
}
}
@ -650,7 +667,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.F){
if(mm != null){}
if(gs != null && gs.getIsLoading() == false){
if(gs != null && gs.getIsLoading() == false && !d.getPlayer().isToDelete()){
if(!d.getPlayer().inventoryFull()){
ArrayList<ItemContainer> garbage = playerPickUp();
@ -663,7 +680,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.R){
if(mm != null){}
if(gs != null && gs.getIsLoading() == false){
if(gs != null && gs.getIsLoading() == false && !d.getPlayer().isToDelete()){
d.getPlayer().getInv().equipItem();
d.getPlayer().updateItems();
}
@ -672,7 +689,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.Q){
if(gs != null && gs.getIsLoading() == false){
if(gs != null && gs.getIsLoading() == false && !d.getPlayer().isToDelete()){
if(d.getPlayer().getInv().getItem(d.getPlayer().getInv().getSelected()) != null){
d.getCurrentRoom().spawnItem((int)d.getPlayer().getxPos(), (int)d.getPlayer().getyPos(), d.getPlayer().getInv().getItem(d.getPlayer().getInv().getSelected()));
gs.getM().getMaps()[level][roomPosX][roomPosY].addItem(48, 48,(int)d.getPlayer().getxPos(), (int)d.getPlayer().getyPos(), d.getPlayer().getInv().getItem(d.getPlayer().getInv().getSelected()));
@ -683,7 +700,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
}
if(keycode == Input.Keys.E){
if(gs != null && gs.getIsLoading() == false){
if(gs != null && gs.getIsLoading() == false && !d.getPlayer().isToDelete()){
d.getPlayer().useItem(d.getPlayer().getInv().getSelected());
}
}
@ -699,7 +716,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.LEFT){
if(mm != null){}
if(gs != null && gs.getIsLoading() == false){
if(gs != null && gs.getIsLoading() == false && !d.getPlayer().isToDelete()){
Entity lol = d.getPlayer().shoot((int) d.getPlayer().getxPos() - 1, (int) d.getPlayer().getyPos());
for(int k = 5; k < d.getCurrentEntities().length; k++){
@ -715,7 +732,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(keycode == Input.Keys.UP){
if(mm != null){}
if(gs != null && gs.getIsLoading() == false){
if(gs != null && gs.getIsLoading() == false && !d.getPlayer().isToDelete()){
Entity lol = d.getPlayer().shoot((int) d.getPlayer().getxPos(), (int) d.getPlayer().getyPos() + 1);
for(int k = 5; k < d.getCurrentEntities().length; k++){
@ -730,7 +747,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
}
if(keycode == Input.Keys.RIGHT){
if(mm != null){}
if(gs != null && gs.getIsLoading() == false){
if(gs != null && gs.getIsLoading() == false && !d.getPlayer().isToDelete()){
Entity lol = d.getPlayer().shoot((int) d.getPlayer().getxPos() + 1, (int) d.getPlayer().getyPos());
for(int k = 5; k < d.getCurrentEntities().length; k++){
@ -745,7 +762,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
}
if(keycode == Input.Keys.DOWN){
if(mm != null){}
if(gs != null && gs.getIsLoading() == false){
if(gs != null && gs.getIsLoading() == false && !d.getPlayer().isToDelete()){
Entity lol = d.getPlayer().shoot((int) d.getPlayer().getxPos(), (int) d.getPlayer().getyPos() - 1);
for(int k = 5; k < d.getCurrentEntities().length; k++){

@ -34,6 +34,7 @@ public abstract class Entity {
public boolean attack(Entity e){
if(e.getHp() - this.dmg <= 0){
e.setHp(0);
e.toDelete = true;
return true;
}
else{

@ -80,12 +80,12 @@ public class Earthwizard extends Entity{
@Override
public Entity shoot(int xPosPlayer, int yPosPlayer){
Projectile a = null;
Spell a = null;
if(!isToDelete()){
double alpha = StaticMath.calculateAngle((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer);
a = new Projectile(this.xPos + 32, this.yPos + 32, this.lvl,(int) this.dmg, 9, true);
a = new Spell(this.xPos + 32, this.yPos + 32, this.lvl,(int) this.dmg, 9, true);
int tempX = (int) (6 * Math.cos(alpha));
int tempY = (int) (6 * Math.sin(alpha));

@ -80,12 +80,12 @@ public class Firewizard extends Entity{
@Override
public Entity shoot(int xPosPlayer, int yPosPlayer){
Projectile a = null;
Spell a = null;
if(!isToDelete()){
double alpha = StaticMath.calculateAngle((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer);
a = new Projectile(this.xPos + 32, this.yPos + 32, this.lvl,(int) this.dmg, 7, true);
a = new Spell(this.xPos + 32, this.yPos + 32, this.lvl,(int) this.dmg, 7, true);
int tempX = (int) (6 * Math.cos(alpha));
int tempY = (int) (6 * Math.sin(alpha));

@ -0,0 +1,56 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.dungeoncrawler.model.entities;
import com.dungeoncrawler.StaticMath;
import com.dungeoncrawler.model.Entity;
public class Spell extends Entity{
float xStart;
float yStart;
int direction;
int lifetime;
public Spell(float xPos, float yPos, int lvl, int dmg, int id, boolean targetsPlayer){
super(xPos, yPos, lvl);
xStart = xPos;
yStart = yPos;
this.dmg = dmg;
this.id = id;
type = 2;
this.lifetime = 0;
this.targetsPlayer = targetsPlayer;
}
public float getxStart(){
return xStart;
}
public float getyStart(){
return yStart;
}
@Override
public boolean move(int xPosPlayer, int yPosPlayer) {
lifetime++;
double alpha = StaticMath.calculateAngle((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer);
movementX = (int) (5 * Math.cos(alpha));
movementY = (int) (5 * Math.sin(alpha));
xPos += movementX;
yPos += movementY;
updateDirection();
if(this.lifetime > 50){
this.setToDelete(true);
}
return false;
}
}

@ -80,12 +80,12 @@ public class Wizard extends Entity{
@Override
public Entity shoot(int xPosPlayer, int yPosPlayer){
Projectile a = null;
Spell a = null;
if(!isToDelete()){
double alpha = StaticMath.calculateAngle((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer);
a = new Projectile(this.xPos + 32, this.yPos + 32, this.lvl,(int) this.dmg, 4, true);
a = new Spell(this.xPos + 32, this.yPos + 32, this.lvl,(int) this.dmg, 4, true);
int tempX = (int) (6 * Math.cos(alpha));
int tempY = (int) (6 * Math.sin(alpha));

Loading…
Cancel
Save