|
|
|
|
@ -18,7 +18,9 @@ import com.badlogic.gdx.maps.MapObjects;
|
|
|
|
|
import com.badlogic.gdx.maps.objects.RectangleMapObject;
|
|
|
|
|
import com.badlogic.gdx.math.Intersector;
|
|
|
|
|
import com.badlogic.gdx.math.Rectangle;
|
|
|
|
|
import com.badlogic.gdx.math.Vector2;
|
|
|
|
|
import com.badlogic.gdx.utils.Array;
|
|
|
|
|
import com.badlogic.gdx.utils.viewport.FitViewport;
|
|
|
|
|
import com.badlogic.gdx.utils.viewport.StretchViewport;
|
|
|
|
|
import com.badlogic.gdx.utils.viewport.Viewport;
|
|
|
|
|
import com.dungeoncrawler.view.*;
|
|
|
|
|
@ -36,6 +38,8 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
float GAME_WORLD_WIDTH;
|
|
|
|
|
float GAME_WORLD_HEIGHT;
|
|
|
|
|
|
|
|
|
|
boolean shotFrame = false;
|
|
|
|
|
|
|
|
|
|
final boolean TOUCH = true;
|
|
|
|
|
|
|
|
|
|
// CAMERA
|
|
|
|
|
@ -95,7 +99,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
viewport = null;
|
|
|
|
|
camera = new OrthographicCamera();
|
|
|
|
|
camera.update();
|
|
|
|
|
viewport = new StretchViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport = new FitViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
viewport.apply();
|
|
|
|
|
camera.position.set(GAME_WORLD_WIDTH / 2, GAME_WORLD_HEIGHT / 2, 0);
|
|
|
|
|
@ -154,6 +158,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
|
|
if(gs != null){
|
|
|
|
|
shotFrame = false;
|
|
|
|
|
if(gs.player.getAttackState() == 2){
|
|
|
|
|
playerAttack(d.getCurrentEntities(), d.getPlayer(), d.getPlayer().getDirection());
|
|
|
|
|
}
|
|
|
|
|
@ -344,7 +349,6 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
public void render(){
|
|
|
|
|
Gdx.gl.glClearColor(0, 0, 0, 1);
|
|
|
|
|
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
|
|
|
|
|
|
|
|
|
if(end){
|
|
|
|
|
if(es == null){
|
|
|
|
|
isPaused = true;
|
|
|
|
|
@ -356,7 +360,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
viewport = null;
|
|
|
|
|
camera = new OrthographicCamera();
|
|
|
|
|
camera.update();
|
|
|
|
|
viewport = new StretchViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport = new FitViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
viewport.apply();
|
|
|
|
|
camera.position.set(GAME_WORLD_WIDTH / 2, GAME_WORLD_HEIGHT / 2, 0);
|
|
|
|
|
@ -969,7 +973,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
viewport = null;
|
|
|
|
|
camera = new OrthographicCamera();
|
|
|
|
|
camera.update();
|
|
|
|
|
viewport = new StretchViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport = new FitViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
viewport.apply();
|
|
|
|
|
camera.position.set(GAME_WORLD_WIDTH / 2 - 170, GAME_WORLD_HEIGHT / 2 + 20, 0);
|
|
|
|
|
@ -990,7 +994,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
viewport = null;
|
|
|
|
|
camera = new OrthographicCamera();
|
|
|
|
|
camera.update();
|
|
|
|
|
viewport = new StretchViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport = new FitViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
viewport.apply();
|
|
|
|
|
camera.position.set(GAME_WORLD_WIDTH / 2 - 170, GAME_WORLD_HEIGHT / 2 + 20, 0);
|
|
|
|
|
@ -1008,7 +1012,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
viewport = null;
|
|
|
|
|
camera = new OrthographicCamera();
|
|
|
|
|
camera.update();
|
|
|
|
|
viewport = new StretchViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport = new FitViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
viewport.apply();
|
|
|
|
|
camera.position.set(GAME_WORLD_WIDTH / 2, GAME_WORLD_HEIGHT / 2, 0);
|
|
|
|
|
@ -1074,7 +1078,9 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
|
|
|
|
|
if(gs != null){
|
|
|
|
|
if(!d.getPlayer().isToDelete()) {
|
|
|
|
|
ArrayList<Integer> clicked = gs.click(screenX,screenY);
|
|
|
|
|
ArrayList<Integer> clicked = gs.click(screenX,screenY, viewport);
|
|
|
|
|
d.getPlayer().setMovementX(0);
|
|
|
|
|
d.getPlayer().setMovementY(0);
|
|
|
|
|
for (Integer i : clicked) {
|
|
|
|
|
switch (i) { // -1: nix, 0: left, 1: up, 2: right, 3: down, 4: attackLeft, 5: attackUp, 6: attackRight, 7: attackDown, 8: pickUp
|
|
|
|
|
case 0:
|
|
|
|
|
@ -1096,6 +1102,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
case 4:
|
|
|
|
|
if(TOUCH)
|
|
|
|
|
if (!gs.getIsLoading() && !d.getPlayer().isToDelete()) {
|
|
|
|
|
shotFrame = true;
|
|
|
|
|
Entity lol = d.getPlayer().shoot((int) d.getPlayer().getxPos() - 1, (int) d.getPlayer().getyPos());
|
|
|
|
|
|
|
|
|
|
for (int k = 5; k < d.getCurrentEntities().length; k++) {
|
|
|
|
|
@ -1112,6 +1119,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
case 5:
|
|
|
|
|
if(TOUCH)
|
|
|
|
|
if (!gs.getIsLoading() && !d.getPlayer().isToDelete()) {
|
|
|
|
|
shotFrame = true;
|
|
|
|
|
Entity lol = d.getPlayer().shoot((int) d.getPlayer().getxPos(), (int) d.getPlayer().getyPos() + 1);
|
|
|
|
|
|
|
|
|
|
for (int k = 5; k < d.getCurrentEntities().length; k++) {
|
|
|
|
|
@ -1127,6 +1135,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
case 6:
|
|
|
|
|
if(TOUCH)
|
|
|
|
|
if (!gs.getIsLoading() && !d.getPlayer().isToDelete()) {
|
|
|
|
|
shotFrame = true;
|
|
|
|
|
Entity lol = d.getPlayer().shoot((int) d.getPlayer().getxPos() + 1, (int) d.getPlayer().getyPos());
|
|
|
|
|
|
|
|
|
|
for (int k = 5; k < d.getCurrentEntities().length; k++) {
|
|
|
|
|
@ -1142,6 +1151,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
case 7:
|
|
|
|
|
if(TOUCH)
|
|
|
|
|
if (!gs.getIsLoading() && !d.getPlayer().isToDelete()) {
|
|
|
|
|
shotFrame = true;
|
|
|
|
|
Entity lol = d.getPlayer().shoot((int) d.getPlayer().getxPos(), (int) d.getPlayer().getyPos() - 1);
|
|
|
|
|
|
|
|
|
|
for (int k = 5; k < d.getCurrentEntities().length; k++) {
|
|
|
|
|
@ -1254,13 +1264,13 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
return es.click(x, y);
|
|
|
|
|
}
|
|
|
|
|
if(ps != null){
|
|
|
|
|
return ps.click(x,y);
|
|
|
|
|
return ps.click(x,y, viewport);
|
|
|
|
|
}
|
|
|
|
|
if(mm != null && !mm.getHidden()){
|
|
|
|
|
return mm.click(x, y);
|
|
|
|
|
return mm.click(x, y, viewport);
|
|
|
|
|
}
|
|
|
|
|
if(ss != null){
|
|
|
|
|
return ss.click(x, y);
|
|
|
|
|
return ss.click(x, y, viewport);
|
|
|
|
|
}
|
|
|
|
|
if(cs != null){
|
|
|
|
|
return cs.click(x, y);
|
|
|
|
|
@ -1272,19 +1282,25 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
@Override
|
|
|
|
|
public boolean touchUp(int screenX, int screenY, int i2, int i3) {
|
|
|
|
|
if(gs != null){
|
|
|
|
|
ArrayList<Integer> e = gs.click(screenX,screenY);
|
|
|
|
|
if(e.contains(0)){
|
|
|
|
|
ArrayList<Integer> e = gs.click(screenX,screenY, viewport);
|
|
|
|
|
Vector2 mov = new Vector2(d.getPlayer().getMovementX(), d.getPlayer().getMovementY());
|
|
|
|
|
if(e.contains(0) && !shotFrame){
|
|
|
|
|
d.getPlayer().setMovementX(0);
|
|
|
|
|
}
|
|
|
|
|
if(e.contains(1)){
|
|
|
|
|
if(e.contains(1) && !shotFrame){
|
|
|
|
|
d.getPlayer().setMovementY(0);
|
|
|
|
|
}
|
|
|
|
|
if(e.contains(2)){
|
|
|
|
|
if(e.contains(2) && !shotFrame){
|
|
|
|
|
d.getPlayer().setMovementX(0);
|
|
|
|
|
}
|
|
|
|
|
if(e.contains(3)){
|
|
|
|
|
if(e.contains(3) && !shotFrame){
|
|
|
|
|
d.getPlayer().setMovementY(0);
|
|
|
|
|
}
|
|
|
|
|
if(shotFrame){
|
|
|
|
|
d.getPlayer().setMovementX(mov.x);
|
|
|
|
|
d.getPlayer().setMovementY(mov.y);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
for (Integer i : gs.click(screenX,screenY)) {
|
|
|
|
|
switch (i) { // -1: nix, 0: left, 1: up, 2: right, 3: down, 4: attackLeft, 5: attackUp, 6: attackRight, 7: attackDown
|
|
|
|
|
case 0:
|
|
|
|
|
@ -1359,6 +1375,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
@ -1368,13 +1385,13 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
|
|
|
|
|
if(gs != null && TOUCH){
|
|
|
|
|
if(!d.getPlayer().isToDelete()) {
|
|
|
|
|
if(!gs.click(screenX,screenY).contains(0) && !gs.click(screenX,screenY).contains(2)) {
|
|
|
|
|
if(!gs.click(screenX,screenY, viewport).contains(0) && !gs.click(screenX,screenY, viewport).contains(2)) {
|
|
|
|
|
d.getPlayer().setMovementX(0);
|
|
|
|
|
}
|
|
|
|
|
if(!gs.click(screenX,screenY).contains(1) && !gs.click(screenX,screenY).contains(3)) {
|
|
|
|
|
if(!gs.click(screenX,screenY, viewport).contains(1) && !gs.click(screenX,screenY, viewport).contains(3)) {
|
|
|
|
|
d.getPlayer().setMovementY(0);
|
|
|
|
|
}
|
|
|
|
|
for (Integer i : gs.click(screenX,screenY)) {
|
|
|
|
|
for (Integer i : gs.click(screenX,screenY, viewport)) {
|
|
|
|
|
switch (i) { // -1: nix, 0: left, 1: up, 2: right, 3: down, 4: attackLeft, 5: attackUp, 6: attackRight, 7: attackDown
|
|
|
|
|
case 0:
|
|
|
|
|
d.getPlayer().setMovementX(-d.getPlayer().getMovementSpeed());
|
|
|
|
|
@ -1481,7 +1498,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
viewport = null;
|
|
|
|
|
camera = new OrthographicCamera();
|
|
|
|
|
camera.update();
|
|
|
|
|
viewport = new StretchViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport = new FitViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
viewport.apply();
|
|
|
|
|
camera.position.set(GAME_WORLD_WIDTH / 2, GAME_WORLD_HEIGHT / 2, 0);
|
|
|
|
|
@ -1495,7 +1512,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor{
|
|
|
|
|
viewport = null;
|
|
|
|
|
camera = new OrthographicCamera();
|
|
|
|
|
camera.update();
|
|
|
|
|
viewport = new StretchViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport = new FitViewport(GAME_WORLD_WIDTH, GAME_WORLD_HEIGHT, camera);
|
|
|
|
|
viewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
|
|
|
|
viewport.apply();
|
|
|
|
|
camera.position.set(GAME_WORLD_WIDTH / 2 - 170, GAME_WORLD_HEIGHT / 2 + 20, 0);
|
|
|
|
|
|