Potions logic added (Inventory)

master
GammelJan 6 years ago
parent 120560fa87
commit 5cc40a7f5b

@ -297,6 +297,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
gs.render(batch, d.getPlayer(), d.getCurrentEntities(), tileX, tileY, level, roomPosX, roomPosY);
hc.updateHud(batch, d.getPlayer());
d.getPlayer().updateItems();
}
}
@ -311,7 +312,6 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
MapLayers layers = gs.getM().getMaps()[level][roomPosX][roomPosY].getMap().getLayers();
MapObjects objects = layers.get(0).getObjects();
MapObjects door = layers.get(3).getObjects();
//System.out.println(objects.getCount());
updatePlayer(objects, door);
}
@ -330,13 +330,11 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
d.getPlayer().setxPos(x);
System.out.println("Es laedt, es laedt, ich will nicht, dass es laedt, wenn es laedt, muss man immer so lange warten!!!!!");
}
}
for(RectangleMapObject rectangleObject : door.getByType(RectangleMapObject.class)){
Rectangle tempDoor = rectangleObject.getRectangle();
System.out.println("Door array");
if(Intersector.overlaps(gs.getPlayer().getCollisionSprite(), tempDoor) && !d.getPlayer().checkKey()){
d.getPlayer().setxPos(x);
@ -354,7 +352,6 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
d.getPlayer().setyPos(y);
System.out.println("Es laedt, es laedt, ich will nicht, dass es laedt, wenn es laedt, muss man immer so lange warten!!!!!");
}
}
@ -371,8 +368,6 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
public void updateRoom(int tempX, int tempY){
//System.out.println(roomX + " " + roomY);
//System.out.println("pos Player tiles: " + tileX + " " + tileY);
// Temp variablen werden wieder auf ihre Plätze geschrieben
@ -427,7 +422,6 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
if(roomPosX == d.getCurrentLevel().getExit()[0] && roomPosY == d.getCurrentLevel().getExit()[1]){
if(level < 6){
System.out.println("Nächstes Level, here we go");
d.getPlayer().deleteKey();
@ -596,6 +590,13 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
}
}
}
if(keycode == Input.Keys.Q){
if(gs != null && gs.getIsLoading() == false){
d.getPlayer().useItem(d.getPlayer().getInv().getSelected());
}
}
if(keycode == Input.Keys.ESCAPE){
if(gs != null && gs.getIsLoading() == false && isPaused == false){
stop();

@ -240,15 +240,14 @@ public class DungeonGenerator {
if(tempItem == null){
System.out.println("Es gibt Probleme, schau mal beim Raumgenerator nach. Es sind sogar sehr problematische Probleme mit den Items");
}
ItemContainer tempContainer;
if(tempItem != null){
ItemContainer tempContainer;
tempContainer = new ItemContainer(xPos, yPos, tempItem);
tempRoom.getItems().add(tempContainer);
}
else{
tempContainer = null;
}
tempRoom.getItems().add(tempContainer);
}
// Entities werden generiert

@ -55,6 +55,12 @@ public class Inventory {
}
}
public void setItem(int x, Item i){
items[x] = i;
}
public boolean checkKey(){
for(int i = 0; i < items.length; i++){
if(items[i] != null){

@ -10,10 +10,10 @@ public class Archer extends Entity{
public Archer(float xPos, float yPos, int lvl) {
super(xPos, yPos, lvl);
this.maxhp = 5*lvl;
this.maxhp = 75*lvl;
this.hp = this.maxhp;
this.direction = 1;
this.dmg = 3*lvl;
this.dmg = 25*lvl;
this.id = 0;
this.type = 1;
counter = 0;
@ -37,7 +37,6 @@ public class Archer extends Entity{
movementX = (int) (3 * Math.cos(alpha));
movementY = (int) (3 * Math.sin(alpha));
System.out.println(distance);
if(distance < 124){
movementX *= -1;
movementY *= -1;
@ -72,7 +71,7 @@ public class Archer extends Entity{
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, 2, true);
a = new Projectile(this.xPos + 32, this.yPos + 32, this.lvl,(int) this.dmg, 2, true);
int tempX = (int) (6 * Math.cos(alpha));
int tempY = (int) (6 * Math.sin(alpha));

@ -21,11 +21,11 @@ public class Player extends Entity {
public Player() {
super(200, 200, 1);
this.maxhp = 20 * lvl;
this.maxhp = 100 * lvl;
this.hp = this.maxhp;
this.standartMaxHp = 5 * lvl;
this.dmg = 3*lvl;
this.dmg = 50*lvl;
this.standartDmg = dmg;
id = -1;
type = -1;
@ -52,6 +52,23 @@ public class Player extends Entity {
//this.maxhp = this.standartMaxHp;
}
}
public void useItem(int x){
if(inv.getItem(x) != null){
switch(inv.getItem(x).getId()){
case 0:
// nix lol weil key
break;
case 1:
this.hp = hp + inv.getItem(x).getHeal();
break;
case 2:
// nix lol weil amulet
break;
}
inv.setItem(x, null);
}
}
public boolean move(int x, int y){
return false;
@ -64,7 +81,7 @@ public class Player extends Entity {
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, 5, false);
a = new Projectile(this.xPos + 32, this.yPos + 32, this.lvl,(int) this.dmg, 5, false);
int tempMovementX = (int) (8 * Math.cos(alpha));
int tempMovementY = (int) (8 * Math.sin(alpha));

@ -14,11 +14,11 @@ public class Projectile extends Entity{
int direction;
int lifetime;
public Projectile(float xPos, float yPos, int lvl, int id, boolean targetsPlayer){
public Projectile(float xPos, float yPos, int lvl, int dmg, int id, boolean targetsPlayer){
super(xPos, yPos, lvl);
xStart = xPos;
yStart = yPos;
this.dmg = 3*lvl;
this.dmg = dmg;
this.id = id;
type = 2;
this.lifetime = 0;

@ -8,10 +8,10 @@ public class Swordsman extends Entity {
public Swordsman(float xPos, float yPos, int lvl) {
super(xPos, yPos, lvl);
this.maxhp = 5*lvl;
this.maxhp = 100*lvl;
this.hp = this.maxhp;
this.direction = 1;
this.dmg = 3*lvl;
this.dmg = 35*lvl;
this.id = 1;
this.type = 0;

@ -19,10 +19,10 @@ public class Wizard extends Entity{
public Wizard(float xPos, float yPos, int lvl) {
super(xPos, yPos, lvl);
this.maxhp = 5*lvl;
this.maxhp = 80*lvl;
this.hp = this.maxhp;
this.direction = 1;
this.dmg = 3*lvl;
this.dmg = 30*lvl;
this.id = 3;
this.type = 1;
counter = 0;
@ -45,7 +45,6 @@ public class Wizard extends Entity{
movementX = (int) (3 * Math.cos(alpha));
movementY = (int) (3 * Math.sin(alpha));
System.out.println(distance);
if(distance < 124){
movementX *= -1;
movementY *= -1;
@ -80,7 +79,7 @@ public class Wizard extends Entity{
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, 4, true);
a = new Projectile(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));

@ -16,6 +16,7 @@ public class Potion extends Item {
public Potion(int lvl) {
super(lvl);
this.heal = lvl * 3;
this.dmg = 0;
this.id = 1;
}

@ -188,10 +188,7 @@ public class GameScreen {
objects = getM().getMaps()[level][roomPosX][roomPosY].getObjects();
mapItems = getM().getMaps()[level][roomPosX][roomPosY].getMapItems();
if(tm == null){
System.out.println("Dein scheiß geht net");
}
else{
if(tm != null){
tmr = new OrthogonalTiledMapRenderer(tm);
}

@ -89,8 +89,6 @@ public class MainMenuScreen{
music.setVolume(volume);
music.play();
System.out.println(startButtonSprite.getWidth());
System.out.println(startButtonSprite.getHeight());
}

Loading…
Cancel
Save