first quest added -> You have to get Information by talking to certain npcs - Interaction objects can go without extra Sprite now by naming the Texture of the InteractionObject '-' inside Tiled
parent
a8f453a2f4
commit
4dbc1407c0
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* What is this Quest?
|
||||||
|
*
|
||||||
|
* This quest is simply about talking. For tesing purposes this Quest only safes one certain Npc.
|
||||||
|
* As soon as you are talking to him this quest is counting as finished
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class InformationQuest extends Quest{
|
||||||
|
|
||||||
|
int[] informationNpcId;
|
||||||
|
int[] informationNpcMapId;
|
||||||
|
boolean[] talked;
|
||||||
|
|
||||||
|
int questId;
|
||||||
|
|
||||||
|
boolean rightOrderRequired;
|
||||||
|
|
||||||
|
InformationQuest(int questId, String questText/*, Quest[] followingQuest*/, int[] informationNpcId, int[] informationNpcMapId, boolean rightOrderRequired){
|
||||||
|
|
||||||
|
this.questId = questId;
|
||||||
|
|
||||||
|
this.informationNpcId = informationNpcId;
|
||||||
|
this.informationNpcMapId = informationNpcMapId;
|
||||||
|
|
||||||
|
talked = new boolean[informationNpcId.length];
|
||||||
|
for(int i = 0; i < informationNpcId.length; i++){
|
||||||
|
talked[i] = false;
|
||||||
|
}
|
||||||
|
this.rightOrderRequired = rightOrderRequired;
|
||||||
|
|
||||||
|
this.questText = questText;
|
||||||
|
|
||||||
|
/* TODO: More quest inside on Quest-string
|
||||||
|
|
||||||
|
if(followingQuest.length > 1){
|
||||||
|
Quest[] nextQuests = new Quest[followingQuest.length-1];
|
||||||
|
for(int i = 1; i < followingQuest.length; i++){
|
||||||
|
nextQuests[i-1] = followingQuest[i];
|
||||||
|
}
|
||||||
|
this.followingQuest = new InformationQuest();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void updateQuest(Array<Actor> actors) {
|
||||||
|
if(!finished){
|
||||||
|
if(rightOrderRequired){
|
||||||
|
int nextToTalk = 0;
|
||||||
|
for(int i = 0; i < talked.length; i++){
|
||||||
|
if(!talked[i]){
|
||||||
|
nextToTalk = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(Actor a : actors){
|
||||||
|
if(a instanceof MovingNpc){
|
||||||
|
if(((MovingNpc)a).id == informationNpcId[nextToTalk] && ((MovingNpc)a).mapId == informationNpcMapId[nextToTalk]){
|
||||||
|
if(((MovingNpc)a).currentlyTalking){
|
||||||
|
talked[nextToTalk] = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for(Actor a : actors){
|
||||||
|
if(a instanceof MovingNpc){
|
||||||
|
for(int i = 0; i < informationNpcId.length; i++){
|
||||||
|
if(((MovingNpc)a).id == informationNpcId[i] && ((MovingNpc)a).mapId == informationNpcMapId[i]){
|
||||||
|
if(((MovingNpc)a).currentlyTalking){
|
||||||
|
talked[i] = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean finished = true;
|
||||||
|
for(int i = 0; i < talked.length; i++){
|
||||||
|
if(!talked[i]){
|
||||||
|
finished = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.finished = finished;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void print(){
|
||||||
|
for(int i = 0; i < informationNpcId.length; i++){
|
||||||
|
System.out.print(informationNpcId[i] + " ");
|
||||||
|
System.out.print(informationNpcMapId[i] + " ");
|
||||||
|
System.out.print(talked[i] + " ");
|
||||||
|
System.out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean finished() {
|
||||||
|
return finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author janeh
|
||||||
|
*/
|
||||||
|
public abstract class Quest {
|
||||||
|
|
||||||
|
String questText;
|
||||||
|
boolean finished;
|
||||||
|
Quest followingQuest;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
abstract void updateQuest(Array<Actor> actors);
|
||||||
|
abstract boolean finished();
|
||||||
|
}
|
||||||
Loading…
Reference in new issue