master
Jonathan Hager 6 years ago
parent 17a0d39fd0
commit 0ea5229e99

@ -13,7 +13,6 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.maps.MapLayers;
import com.badlogic.gdx.maps.MapObject;
import com.badlogic.gdx.maps.MapObjects;
import com.badlogic.gdx.maps.objects.RectangleMapObject;
import com.badlogic.gdx.math.Intersector;
@ -24,11 +23,7 @@ import com.dungeoncrawler.model.DungeonGenerator;
import com.dungeoncrawler.model.entities.*;
import com.dungeoncrawler.model.Entity;
import com.badlogic.gdx.utils.Timer;
import com.dungeoncrawler.model.Item;
import com.dungeoncrawler.model.ItemContainer;
import com.dungeoncrawler.model.items.Key;
import com.dungeoncrawler.model.items.Potion;
import com.dungeoncrawler.model.items.Amulet;
import java.util.ArrayList;
public class Controller extends ApplicationAdapter implements InputProcessor{
@ -125,10 +120,15 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
boolean delete = false;
if(Intersector.overlaps(tempObject.getBoundingRectangle(), playerSprite)){
overlaps = true;
if(d.getCurrentEntities()[i].getId() == 2){
d.getCurrentEntities()[i].attack(d.getPlayer());
delete = true;
d.getCurrentEntities()[i].attack(d.getPlayer());
}
else{
}
}
else{
for(RectangleMapObject rectangleObject : mapObjects.getByType(RectangleMapObject.class)){
@ -155,7 +155,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
}
}
if(overlaps){
d.getCurrentEntities()[i].setxPos(x);
d.getCurrentEntities()[i].setyPos(y);
@ -175,7 +175,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
}
}
if(delete && d.getCurrentEntities()[i].getId() == 2){
if(delete && d.getCurrentEntities()[i].getId() == 2 || d.getCurrentEntities()[i].getToDelete()){
d.getCurrentEntities()[i] = null;
m.updateEntitySprite(d.getCurrentEntities());
@ -353,6 +353,10 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
d.setCurrentEntities(d.getCurrentRoom().getEnemies());
}
public void attack(Entity attacker, Entity[] e){
}
public ArrayList<ItemContainer> playerPickUp(){
ArrayList<ItemContainer> tempItems = d.getCurrentRoom().getItems();

@ -17,6 +17,7 @@ public abstract class Entity {
protected int id;
protected int direction;
protected Inventory inv;
protected boolean toDelete;
@ -27,6 +28,7 @@ public abstract class Entity {
this.movementX = 0;
this.movementY = 0;
this.direction = 2;
this.toDelete = false;
}
public void attack(Entity e){
@ -149,4 +151,8 @@ public abstract class Entity {
this.direction = direction;
}
public boolean getToDelete(){
return this.toDelete;
}
}

@ -12,6 +12,7 @@ public class Arrow extends Entity{
float xStart;
float yStart;
int direction;
int lifetime;
public Arrow(float xPos, float yPos, int lvl, int direction){
super(xPos, yPos, lvl);
@ -20,7 +21,7 @@ public class Arrow extends Entity{
this.direction = direction;
this.dmg = 3*lvl;
this.id = 2;
this.lifetime = 0;
}
public float getxStart(){
@ -32,9 +33,15 @@ public class Arrow extends Entity{
@Override
public Entity move(int xPosPlayer, int yPosPlayer) {
lifetime++;
xPos += movementX;
yPos += movementY;
if(this.lifetime > 50){
this.toDelete = true;
}
return null;
}
}

@ -253,11 +253,6 @@ public class GameScreen {
mapItem.getSprite().draw(batch);
}
// Player wird gedrawt
for(Sprite sprite : player.getSprites()){
sprite.draw(batch);
}
//controls.draw(batch);
//DRAW'T JEDES ENTITY - prueft vorher ob vorhanden
for(int i = 0; i < e.length; i++){
@ -317,6 +312,11 @@ public class GameScreen {
}
}
// Player wird gedrawt
for(Sprite sprite : player.getSprites()){
sprite.draw(batch);
}
/*
for(int i = 0; i < arrowSprites.length; i++){
if(arrowSprites[i] != null){
@ -448,38 +448,6 @@ public class GameScreen {
return e;
}
/*
public void moveItem(int i){
if(i == 0){
if(InventoryItemSprites[i] != null){
for(int n = 2; n < InventoryItemSprites.length ; n++){
if(InventoryItemSprites[n] == null){
InventoryItemTextures[n] = InventoryItemTextures[i];
InventoryItemSprites[n] = InventoryItemSprites[i];
}
}
}
}
}
*/
/*
public ItemContainer playerPickUp(ItemContainer[] items, Player p){
for(int i = 0; i < items.length; i++){
if(items[i] != null){
if(Intersector.overlaps(player.getBoundingRectangle(), itemSprite[i].getBoundingRectangle())){
player.pickUp(items[i].getItem());
items[i] = null;
}
}
}
return items;
}
*/
public void cleanUp(){
music.dispose();
}

Loading…
Cancel
Save