Quest window added

master
GammelJAN 5 years ago
parent f0ceece9aa
commit 5e9ca9c063

@ -19,15 +19,17 @@ import com.badlogic.gdx.utils.Array;
*/ */
public class InformationQuest extends Quest{ public class InformationQuest extends Quest{
int[] informationNpcId; private int[] informationNpcId;
int[] informationNpcMapId; private int[] informationNpcMapId;
boolean[] talked; private boolean[] talked;
int questId; private int questId;
boolean rightOrderRequired;
public InformationQuest(int questId, String questText, int[] informationNpcId, int[] informationNpcMapId, boolean rightOrderRequired){ private boolean rightOrderRequired;
public InformationQuest(int questId, String questText, int[] informationNpcId, int[] informationNpcMapId, boolean rightOrderRequired, String name){
this.questId = questId; this.questId = questId;
@ -40,14 +42,15 @@ public class InformationQuest extends Quest{
} }
this.rightOrderRequired = rightOrderRequired; this.rightOrderRequired = rightOrderRequired;
this.questText = questText; setQuestName(name);
setQuestText(questText);
} }
public void talk(MovingNpc a){ public void talk(MovingNpc a){
for(int i = 0; i < talked.length; i++){ for(int i = 0; i < getTalked().length; i++){
if(informationNpcId[i] == a.id && informationNpcMapId[i] == a.mapId){ if(getInformationNpcId()[i] == a.id && getInformationNpcMapId()[i] == a.mapId){
talked[i] = true; getTalked()[i] = true;
break; break;
} }
} }
@ -55,23 +58,23 @@ public class InformationQuest extends Quest{
public boolean hasSpecialDialogue(int NpcId, int mapId){ public boolean hasSpecialDialogue(int NpcId, int mapId){
if(!finished){ if(!isFinished()){
if(!rightOrderRequired){ if(!isRightOrderRequired()){
for(int i = 0; i < talked.length; i++){ for(int i = 0; i < getTalked().length; i++){
if(informationNpcId[i] == NpcId && informationNpcMapId[i] == mapId && !talked[i]){ if(getInformationNpcId()[i] == NpcId && getInformationNpcMapId()[i] == mapId && !getTalked()[i]){
return true; return true;
} }
} }
} }
else{ else{
int nextToTalk = 0; int nextToTalk = 0;
for(int i = 0; i < talked.length; i++){ for(int i = 0; i < getTalked().length; i++){
if(!talked[i]){ if(!getTalked()[i]){
nextToTalk = i; nextToTalk = i;
break; break;
} }
} }
if(informationNpcId[nextToTalk] == NpcId && informationNpcMapId[nextToTalk] == mapId){ if(getInformationNpcId()[nextToTalk] == NpcId && getInformationNpcMapId()[nextToTalk] == mapId){
return true; return true;
} }
} }
@ -81,34 +84,107 @@ public class InformationQuest extends Quest{
} }
public String getDialoguePath(int NpcId, int mapId){ public String getDialoguePath(int NpcId, int mapId){
return "quests/informationQuests/"+questId+"/dialogues/map"+mapId+"/npc"+NpcId+"/dialogue.txt"; return "quests/informationQuests/"+getQuestId()+"/dialogues/map"+mapId+"/npc"+NpcId+"/dialogue.txt";
} }
@Override @Override
public void updateQuest() { public void updateQuest() {
if(!finished){ if(!isFinished()){
finished = true; setFinished(true);
for(int i = 0; i < talked.length; i++){ for(int i = 0; i < getTalked().length; i++){
if(!talked[i]){ if(!getTalked()[i]){
finished = false; setFinished(false);
break; break;
} }
} }
} }
} }
@Override
public void print(){ public void print(){
for(int i = 0; i < informationNpcId.length; i++){ for(int i = 0; i < getInformationNpcId().length; i++){
System.out.print(informationNpcId[i] + " "); System.out.print(getInformationNpcId()[i] + " ");
System.out.print(informationNpcMapId[i] + " "); System.out.print(getInformationNpcMapId()[i] + " ");
System.out.print(talked[i] + " "); System.out.print(getTalked()[i] + " ");
System.out.println(); System.out.println();
} }
} }
@Override @Override
public boolean finished() { public boolean finished() {
return finished; return isFinished();
}
/**
* @return the informationNpcId
*/
public int[] getInformationNpcId() {
return informationNpcId;
}
/**
* @param informationNpcId the informationNpcId to set
*/
public void setInformationNpcId(int[] informationNpcId) {
this.informationNpcId = informationNpcId;
}
/**
* @return the informationNpcMapId
*/
public int[] getInformationNpcMapId() {
return informationNpcMapId;
}
/**
* @param informationNpcMapId the informationNpcMapId to set
*/
public void setInformationNpcMapId(int[] informationNpcMapId) {
this.informationNpcMapId = informationNpcMapId;
}
/**
* @return the talked
*/
public boolean[] getTalked() {
return talked;
}
/**
* @param talked the talked to set
*/
public void setTalked(boolean[] talked) {
this.talked = talked;
}
/**
* @return the questId
*/
public int getQuestId() {
return questId;
}
/**
* @param questId the questId to set
*/
public void setQuestId(int questId) {
this.questId = questId;
} }
/**
* @return the rightOrderRequired
*/
public boolean isRightOrderRequired() {
return rightOrderRequired;
}
/**
* @param rightOrderRequired the rightOrderRequired to set
*/
public void setRightOrderRequired(boolean rightOrderRequired) {
this.rightOrderRequired = rightOrderRequired;
}
} }

@ -51,20 +51,20 @@ import com.badlogic.gdx.utils.viewport.FitViewport;
public class MapContainer { public class MapContainer {
Stage stage; private Stage stage;
OrthographicCamera camera; private OrthographicCamera camera;
TmxMapLoader maploader; private TmxMapLoader maploader;
TiledMap map; private TiledMap map;
OrthogonalTiledMapRenderer renderer; private OrthogonalTiledMapRenderer renderer;
Door[] doors; private Door[] doors;
public Door collidingDoor; private Door collidingDoor;
FightScreen fs; private FightScreen fs;
TransitionScreen t; private TransitionScreen t;
final int[] layersBelowPlayer = {0, 1, 2}; private int[] layersBelowPlayer = {0, 1, 2};
final int[] layersAbovePlayer = {3, 4}; private int[] layersAbovePlayer = {3, 4};
// TODO: Value which shows from which door the player is coming? // TODO: Value which shows from which door the player is coming?
public MapContainer(float CAMERA_WIDTH, float CAMERA_HEIGHT, Player p, String mapString, int inDoor, int mapId) { public MapContainer(float CAMERA_WIDTH, float CAMERA_HEIGHT, Player p, String mapString, int inDoor, int mapId) {
@ -72,7 +72,7 @@ public class MapContainer {
camera = new OrthographicCamera(); camera = new OrthographicCamera();
camera.setToOrtho(false, CAMERA_WIDTH, CAMERA_HEIGHT); camera.setToOrtho(false, CAMERA_WIDTH, CAMERA_HEIGHT);
camera.update(); camera.update();
stage = new Stage(new FitViewport(CAMERA_WIDTH, CAMERA_HEIGHT, camera)); stage = new Stage(new FitViewport(CAMERA_WIDTH, CAMERA_HEIGHT, getCamera()));
Gdx.input.setInputProcessor(stage); Gdx.input.setInputProcessor(stage);
//TRANSITION SCREEN //TRANSITION SCREEN
@ -83,7 +83,7 @@ public class MapContainer {
//CREATION OF TILEDMAP //CREATION OF TILEDMAP
maploader = new TmxMapLoader(); maploader = new TmxMapLoader();
map = maploader.load(mapString); map = maploader.load(mapString);
renderer = new OrthogonalTiledMapRenderer(map); renderer = new OrthogonalTiledMapRenderer(getMap());
renderer.setView((OrthographicCamera)stage.getCamera()); renderer.setView((OrthographicCamera)stage.getCamera());
stage.getCamera().update(); stage.getCamera().update();
@ -176,7 +176,7 @@ public class MapContainer {
// CREATING MAP COLLISION OBJECTS // CREATING MAP COLLISION OBJECTS
ArrayList<Rectangle> mapRectsTemp = new ArrayList<>(); ArrayList<Rectangle> mapRectsTemp = new ArrayList<>();
for(Actor a : stage.getActors()){ for(Actor a : getStage().getActors()){
if(a instanceof MapCollisionObject){ if(a instanceof MapCollisionObject){
mapRectsTemp.add(((MapCollisionObject)a).getR()); mapRectsTemp.add(((MapCollisionObject)a).getR());
} }
@ -191,7 +191,7 @@ public class MapContainer {
ArrayList<FightObject> tempObjects = new ArrayList<>(); ArrayList<FightObject> tempObjects = new ArrayList<>();
tempObjects.add(new FightPlayer(getPlayer().getX(),getPlayer().getY(), getPlayer().getPlayerSprite(), getPlayer().getStats(), 0)); tempObjects.add(new FightPlayer(getPlayer().getX(),getPlayer().getY(), getPlayer().getPlayerSprite(), getPlayer().getStats(), 0));
for(Actor a : stage.getActors()) { for(Actor a : getStage().getActors()) {
if(a instanceof Hostile) { if(a instanceof Hostile) {
if(((Hostile) a).getMovementState() > 0) { if(((Hostile) a).getMovementState() > 0) {
((Hostile) a).setMovementState(2); ((Hostile) a).setMovementState(2);
@ -206,47 +206,47 @@ public class MapContainer {
fightObjects[i] = tempObjects.get(i); fightObjects[i] = tempObjects.get(i);
} }
fs = new FightScreen(stage.getBatch(), fightObjects, rects, getPlayer().getX()+32, getPlayer().getY()+32); setFs(new FightScreen(getStage().getBatch(), fightObjects, rects, getPlayer().getX()+32, getPlayer().getY()+32));
} }
else if(Main.gamestate == 2){ else if(Main.gamestate == 2){
Main.gamestate = 0; Main.gamestate = 0;
fs.nuke(); getFs().nuke();
fs.setState(3); getFs().setState(3);
} }
} }
renderer.setView((OrthographicCamera)stage.getCamera()); getRenderer().setView((OrthographicCamera)getStage().getCamera());
renderer.render(layersBelowPlayer); getRenderer().render(getLayersBelowPlayer());
if(Main.gamestate == 0 || Main.gamestate == 1) { if(Main.gamestate == 0 || Main.gamestate == 1) {
Actor[] old = stage.getActors().toArray(); Actor[] old = getStage().getActors().toArray();
stage.clear(); getStage().clear();
for(Actor a : sort(old)){ for(Actor a : sort(old)){
stage.addActor(a); getStage().addActor(a);
} }
for(Actor a : stage.getActors()) { for(Actor a : getStage().getActors()) {
if(a instanceof Player) { if(a instanceof Player) {
Rectangle rect = ((Player) a).getCollisionRect(); Rectangle rect = ((Player) a).getCollisionRect();
for(Door d : doors) { for(Door d : getDoors()) {
if(Intersector.overlaps(rect, d.rect)) { if(Intersector.overlaps(rect, d.rect)) {
collidingDoor = d; setCollidingDoor(d);
break; break;
} }
} }
} }
} }
stage.act(f); getStage().act(f);
stage.draw(); getStage().draw();
} }
if(Main.gamestate == 2){ if(Main.gamestate == 2){
if(fs == null) { if(getFs() == null) {
// CREATING MAP COLLISION OBJECTS // CREATING MAP COLLISION OBJECTS
ArrayList<Rectangle> mapRectsTemp = new ArrayList<>(); ArrayList<Rectangle> mapRectsTemp = new ArrayList<>();
for(Actor a : stage.getActors()){ for(Actor a : getStage().getActors()){
if(a instanceof MapCollisionObject){ if(a instanceof MapCollisionObject){
mapRectsTemp.add(((MapCollisionObject)a).getR()); mapRectsTemp.add(((MapCollisionObject)a).getR());
} }
@ -261,7 +261,7 @@ public class MapContainer {
ArrayList<FightObject> tempObjects = new ArrayList<>(); ArrayList<FightObject> tempObjects = new ArrayList<>();
tempObjects.add(new FightPlayer(getPlayer().getX(),getPlayer().getY(), getPlayer().getPlayerSprite(), getPlayer().getStats(), 0)); tempObjects.add(new FightPlayer(getPlayer().getX(),getPlayer().getY(), getPlayer().getPlayerSprite(), getPlayer().getStats(), 0));
for(Actor a : stage.getActors()) { for(Actor a : getStage().getActors()) {
if(a instanceof Hostile) { if(a instanceof Hostile) {
Enemy e = new Enemy(a.getX(), a.getY(), ((Hostile) a).getSprite(), ((Hostile) a).getStats(), ((Hostile) a).getId(), ((Hostile) a).isIsMelee()); Enemy e = new Enemy(a.getX(), a.getY(), ((Hostile) a).getSprite(), ((Hostile) a).getStats(), ((Hostile) a).getId(), ((Hostile) a).isIsMelee());
tempObjects.add(e); tempObjects.add(e);
@ -273,11 +273,11 @@ public class MapContainer {
fightObjects[i] = tempObjects.get(i); fightObjects[i] = tempObjects.get(i);
} }
fs = new FightScreen(stage.getBatch(), fightObjects, rects, getPlayer().getX()+32, getPlayer().getY()+32); setFs(new FightScreen(getStage().getBatch(), fightObjects, rects, getPlayer().getX()+32, getPlayer().getY()+32));
} }
if(fs.getState() == 3){ if(getFs().getState() == 3){
for(FightObject object : fs.getObjects()){ for(FightObject object : getFs().getObjects()){
if(object instanceof FightPlayer){ if(object instanceof FightPlayer){
getPlayer().setX(object.getX()); getPlayer().setX(object.getX());
@ -286,15 +286,15 @@ public class MapContainer {
} }
else{ else{
for(int i = stage.getActors().size-1; i >= 0; i--){ for(int i = getStage().getActors().size-1; i >= 0; i--){
if(stage.getActors().get(i) instanceof Hostile){ if(getStage().getActors().get(i) instanceof Hostile){
if(((Hostile)stage.getActors().get(i)).getId() == object.getId()){ if(((Hostile)getStage().getActors().get(i)).getId() == object.getId()){
if(object.getStats().getHp() <= 0){ if(object.getStats().getHp() <= 0){
stage.getActors().removeIndex(i); getStage().getActors().removeIndex(i);
} }
else{ else{
stage.getActors().get(i).setPosition(object.getX(), object.getY()); getStage().getActors().get(i).setPosition(object.getX(), object.getY());
((Hostile)stage.getActors().get(i)).setStats(object.getStats()); ((Hostile)getStage().getActors().get(i)).setStats(object.getStats());
} }
} }
} }
@ -303,28 +303,28 @@ public class MapContainer {
} }
} }
fs = null; setFs(null);
Main.gamestate = 0; Main.gamestate = 0;
} }
else{ else{
fs.act(f); getFs().act(f);
fs.draw(); getFs().draw();
} }
} }
renderer.render(layersAbovePlayer); getRenderer().render(getLayersAbovePlayer());
for(Actor a : stage.getActors()){ for(Actor a : getStage().getActors()){
if(a instanceof Textbox){ if(a instanceof Textbox){
stage.getBatch().begin(); getStage().getBatch().begin();
a.draw(stage.getBatch(), f); a.draw(getStage().getBatch(), f);
stage.getBatch().end(); getStage().getBatch().end();
} }
} }
if(Main.gamestate == 1) { if(Main.gamestate == 1) {
Textbox t = null; Textbox t = null;
for(Actor a : stage.getActors()){ for(Actor a : getStage().getActors()){
if(a instanceof Textbox){ if(a instanceof Textbox){
t = (Textbox)a; t = (Textbox)a;
if(t.getState() == 3){ if(t.getState() == 3){
@ -337,27 +337,27 @@ public class MapContainer {
} }
// center camera // center camera
for(Actor a : stage.getActors()){ for(Actor a : getStage().getActors()){
if(a instanceof Player){ if(a instanceof Player){
stage.getCamera().position.set((a.getX()+a.getWidth()/2), (a.getY()+a.getHeight()/2), 0); getStage().getCamera().position.set((a.getX()+a.getWidth()/2), (a.getY()+a.getHeight()/2), 0);
stage.getCamera().update(); getStage().getCamera().update();
break; break;
} }
} }
if(t != null){ if(getT() != null){
t.draw(stage.getBatch(), stage.getCamera().position.x, stage.getCamera().position.y, stage.getCamera().combined); getT().draw(getStage().getBatch(), getStage().getCamera().position.x, getStage().getCamera().position.y, getStage().getCamera().combined);
if(t.opacity == 0){ if(getT().opacity == 0){
t = null; setT(null);
} }
} }
} }
public void resize(int width, int height){ public void resize(int width, int height){
stage.getViewport().update(width, height, false); getStage().getViewport().update(width, height, false);
} }
public Player getPlayer(){ public Player getPlayer(){
for(Actor a : stage.getActors()){ for(Actor a : getStage().getActors()){
if(a instanceof Player){ if(a instanceof Player){
return (Player)a; return (Player)a;
} }
@ -380,6 +380,162 @@ public class MapContainer {
return unsorted; return unsorted;
} }
/**
* @return the stage
*/
public Stage getStage() {
return stage;
}
/**
* @param stage the stage to set
*/
public void setStage(Stage stage) {
this.stage = stage;
}
/**
* @return the camera
*/
public OrthographicCamera getCamera() {
return camera;
}
/**
* @param camera the camera to set
*/
public void setCamera(OrthographicCamera camera) {
this.camera = camera;
}
/**
* @return the maploader
*/
public TmxMapLoader getMaploader() {
return maploader;
}
/**
* @param maploader the maploader to set
*/
public void setMaploader(TmxMapLoader maploader) {
this.maploader = maploader;
}
/**
* @return the map
*/
public TiledMap getMap() {
return map;
}
/**
* @param map the map to set
*/
public void setMap(TiledMap map) {
this.map = map;
}
/**
* @return the renderer
*/
public OrthogonalTiledMapRenderer getRenderer() {
return renderer;
}
/**
* @param renderer the renderer to set
*/
public void setRenderer(OrthogonalTiledMapRenderer renderer) {
this.renderer = renderer;
}
/**
* @return the doors
*/
public Door[] getDoors() {
return doors;
}
/**
* @param doors the doors to set
*/
public void setDoors(Door[] doors) {
this.doors = doors;
}
/**
* @return the collidingDoor
*/
public Door getCollidingDoor() {
return collidingDoor;
}
/**
* @param collidingDoor the collidingDoor to set
*/
public void setCollidingDoor(Door collidingDoor) {
this.collidingDoor = collidingDoor;
}
/**
* @return the fs
*/
public FightScreen getFs() {
return fs;
}
/**
* @param fs the fs to set
*/
public void setFs(FightScreen fs) {
this.fs = fs;
}
/**
* @return the t
*/
public TransitionScreen getT() {
return t;
}
/**
* @param t the t to set
*/
public void setT(TransitionScreen t) {
this.t = t;
}
/**
* @return the layersBelowPlayer
*/
public int[] getLayersBelowPlayer() {
return layersBelowPlayer;
}
/**
* @param layersBelowPlayer the layersBelowPlayer to set
*/
public void setLayersBelowPlayer(int[] layersBelowPlayer) {
this.layersBelowPlayer = layersBelowPlayer;
}
/**
* @return the layersAbovePlayer
*/
public int[] getLayersAbovePlayer() {
return layersAbovePlayer;
}
/**
* @param layersAbovePlayer the layersAbovePlayer to set
*/
public void setLayersAbovePlayer(int[] layersAbovePlayer) {
this.layersAbovePlayer = layersAbovePlayer;
}
} }

@ -14,13 +14,72 @@ import com.badlogic.gdx.utils.Array;
*/ */
public abstract class Quest { public abstract class Quest {
String questText; private String questName;
boolean finished; private String questText;
Quest followingQuest; private boolean finished;
private Quest followingQuest;
abstract public void updateQuest(); abstract public void updateQuest();
public abstract boolean finished(); public abstract boolean finished();
public abstract void print(); public abstract void print();
/**
* @return the questName
*/
public String getQuestName() {
return questName;
}
/**
* @param questName the questName to set
*/
public void setQuestName(String questName) {
this.questName = questName;
}
/**
* @return the questText
*/
public String getQuestText() {
return questText;
}
/**
* @param questText the questText to set
*/
public void setQuestText(String questText) {
this.questText = questText;
}
/**
* @return the finished
*/
public boolean isFinished() {
return finished;
}
/**
* @param finished the finished to set
*/
public void setFinished(boolean finished) {
this.finished = finished;
}
/**
* @return the followingQuest
*/
public Quest getFollowingQuest() {
return followingQuest;
}
/**
* @param followingQuest the followingQuest to set
*/
public void setFollowingQuest(Quest followingQuest) {
this.followingQuest = followingQuest;
}
} }

@ -0,0 +1,101 @@
/*
* 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.trs.main.view;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Rectangle;
import com.trs.main.InformationQuest;
import com.trs.main.Main;
import com.trs.main.Quest;
/**
*
* @author janeh
*/
public class QuestWindow {
BitmapFont font;
ShapeRenderer renderer;
boolean visible;
int selectedQuest;
public QuestWindow(){
renderer = new ShapeRenderer();
visible = true;
selectedQuest = 0;
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fontData/font.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 21;
font = generator.generateFont(parameter);
generator.dispose();
font.setColor(Color.WHITE);
}
public void draw(Quest[] quests, Batch batch, float playerX, float playerY){
if(Main.gamestate == 2) visible = false;
else visible = true;
if(Gdx.input.isKeyJustPressed(Input.Keys.RIGHT)){
if(selectedQuest < quests.length-1){
selectedQuest++;
}
}
if(Gdx.input.isKeyJustPressed(Input.Keys.LEFT)){
if(selectedQuest > 0){
selectedQuest--;
}
}
if(visible){
float boxX = playerX + Main.CAMERA_WIDTH/2 - 150;
float boxY = playerY + Main.CAMERA_HEIGHT/2 - 250;
float boxWidth = 140;
float boxHeight = 240;
renderer.setProjectionMatrix(batch.getProjectionMatrix());
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
renderer.begin(ShapeRenderer.ShapeType.Filled);
renderer.setColor(0.1f, 0.1f, 0.1f, 0.5f);
renderer.rect(boxX, boxY, boxWidth, boxHeight);
renderer.end();
batch.begin();
font.draw(batch, quests[selectedQuest].getQuestName(), boxX + 10, boxY + boxHeight - getTextHeight("A") - 10);
if(quests[selectedQuest] instanceof InformationQuest){
InformationQuest quest = (InformationQuest)quests[selectedQuest];
font.getData().setScale(0.8f);
for(int i = 0; i < quest.getInformationNpcId().length; i++){
font.draw(batch, "MAP: " + quest.getInformationNpcMapId()[i] + " NPC: "
+ quest.getInformationNpcId()[i], boxX + 10, boxY + boxHeight - getTextHeight("A") - 10 - ((i+1) * (getTextHeight("A") + 10)));
}
font.getData().setScale(1f);
}
batch.end();
Gdx.gl.glDisable(GL20.GL_BLEND);
}
}
public float getTextWidth(String text){
GlyphLayout glyphLayout = new GlyphLayout();
glyphLayout.setText(font,text);
return glyphLayout.width;
}
public float getTextHeight(String text){
GlyphLayout glyphLayout = new GlyphLayout();
glyphLayout.setText(font,text);
return glyphLayout.height;
}
}

@ -6,8 +6,11 @@
package com.trs.main.view.screens; package com.trs.main.view.screens;
import com.badlogic.gdx.Game; import com.badlogic.gdx.Game;
import com.badlogic.gdx.math.Rectangle;
import com.trs.main.Main; import com.trs.main.Main;
import com.trs.main.MapContainer; import com.trs.main.MapContainer;
import com.trs.main.Quest;
import com.trs.main.view.QuestWindow;
import com.trs.main.worldobjects.Player; import com.trs.main.worldobjects.Player;
/** /**
@ -17,10 +20,12 @@ import com.trs.main.worldobjects.Player;
public class GameScreen extends AbstractScreen{ public class GameScreen extends AbstractScreen{
MapContainer map; MapContainer map;
QuestWindow qw;
public GameScreen(Game game, float CAMERA_WIDTH, float CAMERA_HEIGHT) { public GameScreen(Game game, float CAMERA_WIDTH, float CAMERA_HEIGHT) {
super(game, CAMERA_WIDTH, CAMERA_HEIGHT); super(game, CAMERA_WIDTH, CAMERA_HEIGHT);
map = new MapContainer(CAMERA_WIDTH, CAMERA_HEIGHT, new Player(200, 200), "tiledmapData/maps/map1.tmx", 2, 1); map = new MapContainer(CAMERA_WIDTH, CAMERA_HEIGHT, new Player(200, 200), "tiledmapData/maps/map1.tmx", 2, 1);
qw = new QuestWindow();
} }
public void loadNewMap(int map, int doorId){ public void loadNewMap(int map, int doorId){
@ -36,9 +41,13 @@ public class GameScreen extends AbstractScreen{
@Override @Override
public void render(float f) { public void render(float f) {
map.render(f); map.render(f);
Quest[] rects = new Quest[map.getPlayer().getQuests().size()];
if(map.collidingDoor != null) { for(int i = 0; i< map.getPlayer().getQuests().size(); i++){
loadNewMap(map.collidingDoor.destinationMap, map.collidingDoor.destinationDoor); rects[i] = map.getPlayer().getQuests().get(i);
}
qw.draw(rects, map.getStage().getBatch(), map.getPlayer().getX()+32, map.getPlayer().getY()+32);
if(map.getCollidingDoor() != null) {
loadNewMap(map.getCollidingDoor().destinationMap, map.getCollidingDoor().destinationDoor);
} }
} }

@ -59,8 +59,8 @@ public class Player extends Actor{
//TEST QUESTS //TEST QUESTS
int[] n = {1, 1}; int[] n = {1, 1};
int[] m = {1, 0}; int[] m = {1, 0};
quests.add(new InformationQuest(0, "Sprich mit Folgenden NPCs: (Id, mapId, schonGereded?) !Reihenfolge wichtig!", m, n, true)); quests.add(new InformationQuest(0, "Sprich mit Folgenden NPCs: (Id, mapId, schonGereded?) !Reihenfolge wichtig!", m, n, true, "gute Quest"));
quests.add(new InformationQuest(1, "jajajaj nicenicenice", m, n, false)); quests.add(new InformationQuest(1, "jajajaj nicenicenice", m, n, false, "jojo"));
} }
@Override @Override

Loading…
Cancel
Save