master
GammelJan 6 years ago
parent 8a6a5dd61f
commit fae068d741

@ -89,7 +89,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
roomAmount = d.getLevel()[0].getRooms().length;
level = 0;
level = 6;
roomPosX = roomAmount / 2;
roomPosY = roomAmount / 2;
@ -251,6 +251,8 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
}
}
}
gs.updateDamageContainer();
}
}
}
@ -300,9 +302,11 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
// Render methode zum rendern der einzelnen Sprites wird aufgerufen
if(gs != null){
gs.render(batch, d.getPlayer(), d.getCurrentEntities(), tileX, tileY, level, roomPosX, roomPosY);
hc.updateHud(batch, d.getPlayer());
d.getPlayer().updateItems();
}
}
}
@ -512,21 +516,16 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
for(int i = 0; i < e.length ; i++){
if(entitySprites[i] != null && e[i] != null){
if(Intersector.overlaps(entitySprites[i].getCollisionSprite(), collision)){
if(e[i].getHp() - p.getDmg() <= 0){
e[i].setHp(0);
e[i].setToDelete(true);
System.out.println("TOTTOTTOT");
}
else{
System.out.println(e[i].getHp());
System.out.println("-");
System.out.println(p.getDmg());
System.out.println("=");
System.out.println(e[i].getHp() - p.getDmg());
e[i].setHp(e[i].getHp() - p.getDmg());
if(entitySprites[i].getDie() == 0){
if(e[i].getHp() - p.getDmg() <= 0){
e[i].setHp(0);
gs.createDmgFont((int) p.getDmg(),(int)e[i].getxPos() + 10,(int) e[i].getyPos() + 20);
e[i].setToDelete(true);
}
else{
e[i].setHp(e[i].getHp() - p.getDmg());
gs.createDmgFont((int) p.getDmg(),(int)e[i].getxPos() + 10,(int) e[i].getyPos() + 20);
}
}
}
}

@ -6,6 +6,9 @@ import com.dungeoncrawler.model.Entity;
public class Archer extends Entity{
int counter;
final int minRange;
final int maxRange;
final int attackSpeed;
public Archer(float xPos, float yPos, int lvl) {
super(xPos, yPos, lvl);
@ -16,6 +19,9 @@ public class Archer extends Entity{
this.dmg = 7*lvl;
this.id = 0;
this.type = 1;
minRange = 164;
maxRange = 184;
attackSpeed = 60;
counter = 0;
// TODO: Sinnvolle Werte finden
@ -30,18 +36,18 @@ public class Archer extends Entity{
double alpha = StaticMath.calculateAngle((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer);
int distance = (int) StaticMath.calculateDistance((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer, alpha);
if(distance >= 104 && distance <= 184 && counter % 40 == 0){
if(distance >= minRange && distance <= maxRange && counter % attackSpeed == 0){
return true;
}
else{
movementX = (int) (3 * Math.cos(alpha));
movementY = (int) (3 * Math.sin(alpha));
if(distance < 124){
if(distance < minRange){
movementX *= -1;
movementY *= -1;
}
else if(distance >= 124 && distance <= 164){
else if(distance >= minRange && distance <= maxRange){
movementX = 0;
movementY = 0;
}

@ -15,6 +15,9 @@ import com.dungeoncrawler.model.Entity;
public class Firewizard extends Entity{
int counter;
final int minRange;
final int maxRange;
final int attackSpeed;
public Firewizard(float xPos, float yPos, int lvl) {
super(xPos, yPos, lvl);
@ -25,6 +28,9 @@ public class Firewizard extends Entity{
this.dmg = 12*lvl;
this.id = 6;
this.type = 1;
minRange = 104;
maxRange = 124;
attackSpeed = 60;
counter = 0;
// TODO: Sinnvolle Werte finden
@ -38,18 +44,18 @@ public class Firewizard extends Entity{
double alpha = StaticMath.calculateAngle((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer);
int distance = (int) StaticMath.calculateDistance((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer, alpha);
if(distance >= 104 && distance <= 184 && counter % 40 == 0){
if(distance >= minRange && distance <= maxRange && counter % attackSpeed == 0){
return true;
}
else{
movementX = (int) (3 * Math.cos(alpha));
movementY = (int) (3 * Math.sin(alpha));
if(distance < 124){
if(distance < minRange){
movementX *= -1;
movementY *= -1;
}
else if(distance >= 124 && distance <= 164){
else if(distance >= minRange && distance <= maxRange){
movementX = 0;
movementY = 0;
}

@ -15,6 +15,9 @@ import com.dungeoncrawler.model.Entity;
public class Wizard extends Entity{
int counter;
final int minRange;
final int maxRange;
final int attackSpeed;
public Wizard(float xPos, float yPos, int lvl) {
super(xPos, yPos, lvl);
@ -25,6 +28,9 @@ public class Wizard extends Entity{
this.dmg = 10*lvl;
this.id = 3;
this.type = 1;
minRange = 144;
maxRange = 164;
attackSpeed = 60; // higher = slower
counter = 0;
// TODO: Sinnvolle Werte finden
@ -38,18 +44,18 @@ public class Wizard extends Entity{
double alpha = StaticMath.calculateAngle((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer);
int distance = (int) StaticMath.calculateDistance((int) this.xPos, (int) this.yPos, xPosPlayer, yPosPlayer, alpha);
if(distance >= 104 && distance <= 184 && counter % 40 == 0){
if(distance >= minRange && distance <= maxRange && counter % attackSpeed == 0){
return true;
}
else{
movementX = (int) (3 * Math.cos(alpha));
movementY = (int) (3 * Math.sin(alpha));
if(distance < 124){
if(distance < 144){
movementX *= -1;
movementY *= -1;
}
else if(distance >= 124 && distance <= 164){
else if(distance >= minRange && distance <= maxRange){
movementX = 0;
movementY = 0;
}

@ -0,0 +1,96 @@
/*
* 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.view;
/**
*
* @author Jan
*/
public class DamageFontContainer {
private int value;
private int currentX;
private int currentY;
private int lifetime;
private int currentLifetime;
public DamageFontContainer(int value, int startX, int startY){
this.value = value;
this.currentX = startX;
this.currentY = startY;
this.lifetime = 60;
this.currentLifetime = 0;
}
/**
* @return the value
*/
public int getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(int value) {
this.value = value;
}
/**
* @return the currentX
*/
public int getCurrentX() {
return currentX;
}
/**
* @param currentX the currentX to set
*/
public void setCurrentX(int currentX) {
this.currentX = currentX;
}
/**
* @return the currentY
*/
public int getCurrentY() {
return currentY;
}
/**
* @param currentY the currentY to set
*/
public void setCurrentY(int currentY) {
this.currentY = currentY;
}
/**
* @return the lifetime
*/
public int getLifetime() {
return lifetime;
}
/**
* @param lifetime the lifetime to set
*/
public void setLifetime(int lifetime) {
this.lifetime = lifetime;
}
/**
* @return the lifelength
*/
public int getCurrentLifetime() {
return currentLifetime;
}
/**
* @param currentLifetime the lifelength to set
*/
public void setCurrentLifetime(int currentLifetime) {
this.currentLifetime = currentLifetime;
}
}

@ -33,6 +33,7 @@ public class EndScreen {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
backButton.draw(batch);
batch.end();
}
@ -42,8 +43,8 @@ public class EndScreen {
if(Intersector.overlaps(r, backButton.getBoundingRectangle())){
return 11; //NEUSTART
}
return -1;
return 11;
//return -1;
}
}

@ -5,6 +5,7 @@ import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
@ -30,6 +31,10 @@ public class GameScreen {
public EntitySprite[] entitySprites;
Entity[] entities;
//DMG visualization
BitmapFont font;
DamageFontContainer[] dmgContainer;
//MAP
private Map m;
TiledMapRenderer tmr;
@ -112,6 +117,10 @@ public class GameScreen {
break;
}
//DMG visualization
font = new BitmapFont();
font.setColor(1, 0, 0, 1);
dmgContainer = new DamageFontContainer[10];
player = new EntitySprite(playerTexture, 64, 64);
@ -283,6 +292,13 @@ public class GameScreen {
roomChangeSprite.draw(batch);
}
for(int x = 0; x < dmgContainer.length; x++){
if(dmgContainer[x] != null){
String text = ""+dmgContainer[x].getValue();
font.draw(batch, text, dmgContainer[x].getCurrentX(), dmgContainer[x].getCurrentY());
}
}
batch.end();
}
@ -366,7 +382,19 @@ public class GameScreen {
entitySprites[i] = null;
}
public void updateDamageContainer(){
for(int x = 0; x < dmgContainer.length; x++){
if(dmgContainer[x] != null){
if(dmgContainer[x].getCurrentLifetime() >= dmgContainer[x].getLifetime()){
dmgContainer[x] = null;
}
else{
dmgContainer[x].setCurrentLifetime(dmgContainer[x].getCurrentLifetime() + 1);
dmgContainer[x].setCurrentY(dmgContainer[x].getCurrentY() + 1);
}
}
}
}
public void cleanUp(){
music.dispose();
@ -402,5 +430,14 @@ public class GameScreen {
animations.start();
animatePlayer.start();
}
public void createDmgFont(int value, int startX, int startY){
for(int i = 0; i < dmgContainer.length; i++){
if(dmgContainer[i]== null){
dmgContainer[i] = new DamageFontContainer(value, startX, startY);
i = dmgContainer.length + 1;
}
}
}
}

Loading…
Cancel
Save