|
@@ -1,7 +1,6 @@
|
|
|
package app.mar.utils.game;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
-import android.app.admin.SystemUpdatePolicy;
|
|
|
import android.content.Context;
|
|
|
import android.util.Log;
|
|
|
import android.widget.Toast;
|
|
@@ -21,77 +20,55 @@ import java.text.NumberFormat;
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import app.mar.activities.ARActivity;
|
|
|
-import app.mar.utils.ResourceManager;
|
|
|
import app.mar.utils.SensorsManager;
|
|
|
import app.mar.utils.Settings;
|
|
|
import app.mar.utils.files.JSONAssetsManager;
|
|
|
+import app.mar.utils.game.challenges.Challenge;
|
|
|
+import app.mar.utils.game.challenges.ChallengeReturn;
|
|
|
+import app.mar.utils.game.challenges.Treasure;
|
|
|
|
|
|
/**
|
|
|
* Created by ptitcois on 19/08/16.
|
|
|
*/
|
|
|
public class Game implements Serializable {
|
|
|
private static Game gGame = null;
|
|
|
- protected ArrayList<Area> mAreas = new ArrayList<Area>();
|
|
|
- protected ArrayList<Area> mCurrentStageAreas = new ArrayList<Area>();
|
|
|
+
|
|
|
+ protected String mName;
|
|
|
+
|
|
|
protected ArrayList<Stage> mStages = new ArrayList<Stage>();
|
|
|
- protected int mNStages;
|
|
|
- protected int mCurrentStage=0;
|
|
|
+ protected Stage mCurrentStage=null;
|
|
|
+ protected int mCurrentStageIndex=0;
|
|
|
+
|
|
|
protected Player mPlayer;
|
|
|
- public ResourceManager mResources;
|
|
|
- protected String mName;
|
|
|
protected Settings mSettings = new Settings();
|
|
|
- protected boolean mFinished= false;
|
|
|
- protected boolean mFirstLaunch=true;
|
|
|
-
|
|
|
protected String mMap=null;
|
|
|
|
|
|
+ protected ResourceManager mResources = new ResourceManager();
|
|
|
+ protected ChallengeReturn mLastReturn = null;
|
|
|
+
|
|
|
+
|
|
|
public Game(String name, Activity act)
|
|
|
{
|
|
|
JSONObject root = JSONAssetsManager.load(act, name);
|
|
|
mName=name;
|
|
|
- mResources = new ResourceManager();
|
|
|
mPlayer = new Player(act);
|
|
|
try {
|
|
|
- /* Listes des zones */
|
|
|
- JSONArray areas = root.getJSONArray("areas");
|
|
|
-
|
|
|
- /* Listes des étapes */
|
|
|
- JSONArray stages = root.getJSONArray("stages_list");
|
|
|
-
|
|
|
- /* Nom (uniquement) d'autres ressources utilisés (hors zones) */
|
|
|
- JSONArray others = root.getJSONArray("others");
|
|
|
-
|
|
|
-
|
|
|
- for(int i=0; i<others.length(); i++)
|
|
|
- mResources.addOtherResource(new Resource(others.getString(i), act));
|
|
|
-
|
|
|
- for(int i=0; i<areas.length(); i++)
|
|
|
- mAreas.add(new Area(areas.getJSONObject(i), act));
|
|
|
-
|
|
|
- for(int i=0; i<stages.length(); i++) {
|
|
|
- Stage s = new Stage(stages.getJSONObject(i));
|
|
|
- Resource r = findResource(s.getResourceName());
|
|
|
- Log.e("_______", "Res = "+r+" "+s.getResourceName());
|
|
|
- s.setResource(r);
|
|
|
- mStages.add(s);
|
|
|
- }
|
|
|
- findMaxStage();
|
|
|
- mResources.set( getAllResources(), mNStages);
|
|
|
-
|
|
|
- nextStage();
|
|
|
- } catch (Exception e) {
|
|
|
- System.err.println("_________________ B\n");
|
|
|
+ JSONArray arr = root.getJSONArray("stages");
|
|
|
+ for(int i=0; i<arr.length(); i++)
|
|
|
+ mStages.add(new Stage(this, arr.getJSONObject(i), act));
|
|
|
+ } catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- System.err.println("_________________ C\n");
|
|
|
mMap=root.getString("map");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
- System.err.println("_________________ C\n");
|
|
|
}
|
|
|
|
|
|
+ mCurrentStageIndex=0;
|
|
|
+ if(mStages.size()>0)
|
|
|
+ mCurrentStage=mStages.get(0);
|
|
|
|
|
|
if(!mPlayer.hasMagneticField() || !mPlayer.hasAcceleromter())
|
|
|
{
|
|
@@ -99,151 +76,32 @@ public class Game implements Serializable {
|
|
|
if(!mPlayer.hasMagneticField()) Toast.makeText(act, "Votre dispositif n'a pas de boussole. Le mode RA ne peut fonctionner et a été désactivé", Toast.LENGTH_LONG).show();
|
|
|
else if(!mPlayer.hasAcceleromter()) Toast.makeText(act, "Votre dispositif n'a pas d'accélerometre. Le mode RA ne peut fonctionner et a été désactivé", Toast.LENGTH_LONG).show();
|
|
|
}
|
|
|
-
|
|
|
- System.err.println("___________||||| "+mCurrentStageAreas.size());
|
|
|
}
|
|
|
|
|
|
- public Stage getCurrentStageObj()
|
|
|
+ public Stage getCurrentStage()
|
|
|
{
|
|
|
- return mCurrentStage<=mStages.size()?mStages.get(mCurrentStage-1):null;
|
|
|
+ return mCurrentStage;
|
|
|
}
|
|
|
|
|
|
- public void checkFirstLaunch()
|
|
|
+ public Challenge getCurrentChallenge()
|
|
|
{
|
|
|
- if(mFirstLaunch) {
|
|
|
- mFirstLaunch=false;
|
|
|
- }
|
|
|
+ if(mCurrentStage==null) return null;
|
|
|
+ return mCurrentStage.getCurrentChallenge();
|
|
|
}
|
|
|
|
|
|
- public Stage getStage(int i)
|
|
|
+ public void registerResource(String name, Activity act)
|
|
|
{
|
|
|
- return mStages.get(i);
|
|
|
+ mResources.addResource(name, act);
|
|
|
}
|
|
|
|
|
|
- public Settings getmSettings(){return mSettings;}
|
|
|
+
|
|
|
+ public Settings getSettings(){return mSettings;}
|
|
|
public void setSettings(Settings s){ mSettings=s;}
|
|
|
|
|
|
- public int getNStages() {
|
|
|
- return mNStages;
|
|
|
- }
|
|
|
public String getName() {
|
|
|
return mName;
|
|
|
}
|
|
|
|
|
|
- public int getCurrentStage() {
|
|
|
- return mCurrentStage;
|
|
|
- }
|
|
|
-
|
|
|
- public void findMaxStage()
|
|
|
- {
|
|
|
- mNStages=0;
|
|
|
- for(int i=0; i<mAreas.size(); i++) {
|
|
|
- if (mAreas.get(i).getStage() > mNStages)
|
|
|
- mNStages = mAreas.get(i).getStage();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public boolean nextStage()
|
|
|
- {
|
|
|
- mCurrentStage++;
|
|
|
- Log.e("------------", "Is Finished : "+mCurrentStage+" > "+mNStages+" = "+(mCurrentStage>mNStages));
|
|
|
- if(mCurrentStage>mNStages) return true;
|
|
|
- System.out.println("La");
|
|
|
- loadStageAreasResources();
|
|
|
- mResources.nextStage(mCurrentStage);
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- public void loadStageAreasResources()
|
|
|
- {
|
|
|
- mCurrentStageAreas.clear();
|
|
|
- for(int i=0; i<mAreas.size(); i++)
|
|
|
- {
|
|
|
- if(mAreas.get(i).getStage() == mCurrentStage)
|
|
|
- mCurrentStageAreas.add(mAreas.get(i));
|
|
|
- }
|
|
|
- System.err.println("================================ ICI =======================" + mCurrentStageAreas.size());
|
|
|
- }
|
|
|
-
|
|
|
- public int currentAreasCount()
|
|
|
- {
|
|
|
- return mCurrentStageAreas.size();
|
|
|
- }
|
|
|
-
|
|
|
- public Area getAreaStage(int i)
|
|
|
- {
|
|
|
- return mCurrentStageAreas.get(i);
|
|
|
- }
|
|
|
-
|
|
|
- public void removeArea(String name)
|
|
|
- {
|
|
|
- for(int i=0; i<mCurrentStageAreas.size(); i++)
|
|
|
- if(mCurrentStageAreas.get(i).getName().compareTo(name)==0)
|
|
|
- mCurrentStageAreas.remove(i);
|
|
|
- }
|
|
|
-
|
|
|
- private void removeArea(int index)
|
|
|
- {
|
|
|
- mCurrentStageAreas.remove(index);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Récupere les ressources pouvant être "physiquement" (positionnement et
|
|
|
- * orientation) prise par le joueur.
|
|
|
- * @return true si l'étape est finie, sinon false
|
|
|
- */
|
|
|
- public boolean pickResource()
|
|
|
- {
|
|
|
- mResources.clearPickedUpResources();
|
|
|
- ArrayList<LocatedResources> r = getResourcesNextToPlayer();
|
|
|
-
|
|
|
- // recupere toutes les ressource "proche" (prenables)
|
|
|
- // du joueur
|
|
|
- for(int i=0; i<r.size(); i++) {
|
|
|
- for (int j = 0; j < mCurrentStageAreas.size(); j++) {
|
|
|
- if (r.get(i).getResource(0).getName().compareTo(mCurrentStageAreas.get(j).getResourceNames().get(0)) == 0 &&
|
|
|
- r.get(i).getResource(0).getStage() == mCurrentStage) {
|
|
|
- removeArea(j);
|
|
|
- }
|
|
|
- }
|
|
|
- for(int k=0; k<r.get(i).count(); k++)
|
|
|
- pickResource(r.get(i).getResource(k).getName());
|
|
|
- }
|
|
|
-
|
|
|
- //retourne vrai si l'etape est finie
|
|
|
- return mCurrentStageAreas.size()==0;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Retourne la liste de toutes les ressources acquises par le joueur
|
|
|
- * @return la liste de toutes les ressources acquises par le joueur
|
|
|
- */
|
|
|
- public ArrayList<Resource> getPickedUpResources()
|
|
|
- {
|
|
|
- return mResources.getPickedUpResources();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * Récupere une ressource par son nom, sans besoin de localisation ou d'orientation
|
|
|
- * @param name Le nom de la ressource
|
|
|
- * @return true si l'étape est finie, sinon false
|
|
|
- */
|
|
|
- public boolean pickResource(String name, boolean otherRes)
|
|
|
- {
|
|
|
-
|
|
|
- if(otherRes)
|
|
|
- {
|
|
|
- for (int j = 0; j < mCurrentStageAreas.size(); j++)
|
|
|
- if (name.compareTo(mCurrentStageAreas.get(j).getName())==0) {
|
|
|
- removeArea(j);
|
|
|
- }
|
|
|
- }
|
|
|
- mResources.pickUpResource(name);
|
|
|
-
|
|
|
- return mCurrentStageAreas.size()==0;
|
|
|
- }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -253,55 +111,10 @@ public class Game implements Serializable {
|
|
|
*/
|
|
|
public boolean pickResource(String name)
|
|
|
{
|
|
|
-
|
|
|
- return pickResource(name, true);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Récupere toutes les ressources du jeu
|
|
|
- */
|
|
|
- public void pickAllResoucres()
|
|
|
- {
|
|
|
- mResources.pickAllResoucres();
|
|
|
- mCurrentStage=mNStages;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * La derniere ressource acquise
|
|
|
- * @return La derniere ressource acquise
|
|
|
- */
|
|
|
- public Resource getLatestResource()
|
|
|
- {
|
|
|
- return mResources.getLatestResource();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public String toString()
|
|
|
- {
|
|
|
- String out = "Game : "+super.toString();
|
|
|
- out+="mAreas[]:\n";
|
|
|
- for(int i=0; i<mAreas.size(); i++)
|
|
|
- out+="\tmAres["+i+"] = "+mAreas.get(i).getJson().toString()+"\n";
|
|
|
- out+="\nmResourcesAcquired[] : \n";
|
|
|
- for(int i=0; i<mResources.getResourceAquiered().size(); i++) {
|
|
|
- out+="\tmResourcesAcquired["+i+"][] : \n";
|
|
|
- for (int j = 0; j < mResources.getResourceAquiered().get(i).size(); j++)
|
|
|
- out += "\t\tmResourcesAcquired[" + i + "]["+j+"] = " + mResources.getResourceAquiered().get(i).get(j).getJson().toString() + "\n";
|
|
|
- }
|
|
|
- out+="mNStages :" +mNStages +"\n";
|
|
|
- out+="mCurrentStage" + mCurrentStage +"\n";
|
|
|
- if(mMap!=null) out+="mMap : '"+mMap+"'\n";
|
|
|
- else out+="mMap : null\n";
|
|
|
- return out;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
- public String toString2()
|
|
|
- {
|
|
|
- String out = "Game : "+mResources.getResourceLeft()+" : "+mCurrentStageAreas+";";
|
|
|
- ArrayList<Resource> arr= mResources.getResourceLeft();
|
|
|
|
|
|
- return out+";";
|
|
|
- }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -346,37 +159,6 @@ public class Game implements Serializable {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- * @return Retourne toutes les ressources
|
|
|
- */
|
|
|
- public ArrayList<Resource> getAllResources()
|
|
|
- {
|
|
|
- ArrayList<Resource> tmp = new ArrayList<Resource>();
|
|
|
- for(int i=0; i<mAreas.size(); i++)
|
|
|
- {
|
|
|
- ArrayList<Resource> c = mAreas.get(i).getResource();
|
|
|
- for(int j=0; j<c.size(); j++)
|
|
|
- if(!tmp.contains(c.get(j)))
|
|
|
- tmp.add(c.get(j));
|
|
|
- }
|
|
|
-
|
|
|
- return tmp;
|
|
|
- }
|
|
|
-
|
|
|
- public void pickUpOtherResources()
|
|
|
- {
|
|
|
- ArrayList<Resource> r = mResources.getOtherResource();
|
|
|
- for(int i=0; i<r.size(); i++) {
|
|
|
- pickResource(r.get(i).getName(), false);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public ArrayList<Area> getCurrentStageAreas()
|
|
|
- {
|
|
|
- return mCurrentStageAreas;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* Teste si le jeu est déja sauvé
|
|
@@ -423,15 +205,7 @@ public class Game implements Serializable {
|
|
|
*/
|
|
|
public Resource findResource(String name)
|
|
|
{
|
|
|
- for(int i=0; i<mAreas.size(); i++)
|
|
|
- for(int j=0; j<mAreas.get(i).countResource(); j++)
|
|
|
- if(mAreas.get(i).getResourceNames().get(j).compareTo(name)==0)
|
|
|
- return mAreas.get(i).getResource(j);
|
|
|
- if(mResources !=null)
|
|
|
- for(int i=0; i<mResources.getOtherResource().size(); i++)
|
|
|
- if(mResources.getOtherResource().get(i).getName().compareTo(name)==0)
|
|
|
- return mResources.getOtherResource().get(i);
|
|
|
- return null;
|
|
|
+ return mResources.get(name);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -439,47 +213,16 @@ public class Game implements Serializable {
|
|
|
* @param contecxt Contexte
|
|
|
* @return Vrai en cas de succes, faux pour une erreur
|
|
|
*/
|
|
|
- synchronized public boolean precache3DResource(Activity contecxt)
|
|
|
+ synchronized public void precache3DResource(Activity contecxt)
|
|
|
{
|
|
|
- boolean b =false;
|
|
|
- for(int i=0; i<mAreas.size(); i++)
|
|
|
+ Challenge c = getCurrentChallenge();
|
|
|
+ if(c instanceof Treasure)
|
|
|
{
|
|
|
- if(mAreas.get(i).getStage()==mCurrentStage && mAreas.get(i).isOnArea(mPlayer)) {
|
|
|
- b = true;
|
|
|
- ArrayList<Resource> rs = mResources.getResourceLeftByName(mAreas.get(i).getResourceNames());
|
|
|
- try {
|
|
|
- for (int j = 0; j < rs.size(); j++) {
|
|
|
- if(rs.get(j)!=null) rs.get(j).get3DModel(contecxt);
|
|
|
- }
|
|
|
-
|
|
|
- }catch(Exception e)
|
|
|
- {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
- return b;
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- *
|
|
|
- * Fonction principale de positionnnemnt et orientation:
|
|
|
- * renvoie la liste des zones sur lesquelles le joueur est présent
|
|
|
- * @return la liste des zones sur lesquelles le joueur est présent
|
|
|
- */
|
|
|
- public ArrayList<Area> getAreaNextToPlayer()
|
|
|
- {
|
|
|
- ArrayList<Area> r = new ArrayList<Area>();
|
|
|
- for(int i=0; i<mCurrentStageAreas.size(); i++)
|
|
|
- {
|
|
|
- //probleme de GPS..
|
|
|
- if(mCurrentStageAreas.get(i).isOnArea(mPlayer))
|
|
|
- r.add(mCurrentStageAreas.get(i));
|
|
|
-
|
|
|
- }
|
|
|
- return r;
|
|
|
- }
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -487,81 +230,17 @@ public class Game implements Serializable {
|
|
|
* renvoie la liste des ressources sur lesquelles le joueur est présent
|
|
|
* @return la liste des ressources sur lesquelles le joueur est présent
|
|
|
*/
|
|
|
- public ArrayList<LocatedResources> getResourcesNextToPlayer()
|
|
|
+ public ArrayList<Resource> getResourcesNextToPlayer(Area a)
|
|
|
{
|
|
|
- ArrayList<LocatedResources> r = new ArrayList<LocatedResources>();
|
|
|
-
|
|
|
- for(int i=0; i<mCurrentStageAreas.size(); i++)
|
|
|
- {
|
|
|
- //probleme de GPS..
|
|
|
- boolean b = mCurrentStageAreas.get(i).isOnArea(mPlayer);
|
|
|
-
|
|
|
- if(b)
|
|
|
- {
|
|
|
-
|
|
|
- if(i<mCurrentStageAreas.size() /*&& mCurrentStageAreas.get(i).isOnDirection(mPlayer)*/ &&
|
|
|
- mCurrentStageAreas.get(i).isOnPlace(mPlayer))
|
|
|
- {
|
|
|
- ArrayList<Resource> rs = mResources.getResourceLeftByName(mCurrentStageAreas.get(i).getResourceNames());
|
|
|
- r.add(new LocatedResources(
|
|
|
- rs,
|
|
|
- mCurrentStageAreas.get(i).getPlace(0)
|
|
|
- ));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return r;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * Renvoie dans une chaine la distance entre le joueur et la ressource la plus proche
|
|
|
- * @return La distance en metres
|
|
|
- */
|
|
|
- public String getResourcesNextToPlayerDist()
|
|
|
- {
|
|
|
- double min=1000000000;
|
|
|
- ArrayList<Resource> r = new ArrayList<Resource>();
|
|
|
- for(int i=0; i<mCurrentStageAreas.size(); i++)
|
|
|
- {
|
|
|
- //probleme de GPS..
|
|
|
- if(mCurrentStageAreas.get(i).isOnArea(mPlayer))
|
|
|
- {
|
|
|
- if(mCurrentStageAreas.get(i).getDistanceToNextPlace(mPlayer)<min)
|
|
|
- min=mCurrentStageAreas.get(i).getDistanceToNextPlace(mPlayer);
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- if(min>10000000) return " --.- m";
|
|
|
- NumberFormat formatter = new DecimalFormat("#0.0");
|
|
|
- return formatter.format(min)+" m";
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Renvoie la distance entre le joueur et la ressource la plus proche
|
|
|
- * @return La distance en metres
|
|
|
- */
|
|
|
- public double getResourcesNextToPlayerDistDouble()
|
|
|
- {
|
|
|
- double min=1000000000;
|
|
|
ArrayList<Resource> r = new ArrayList<Resource>();
|
|
|
- for(int i=0; i<mCurrentStageAreas.size(); i++)
|
|
|
- {
|
|
|
- //probleme de GPS..
|
|
|
- if(mCurrentStageAreas.get(i).isOnArea(mPlayer))
|
|
|
- {
|
|
|
- if(mCurrentStageAreas.get(i).getDistanceToNextPlace(mPlayer)<min)
|
|
|
- min=mCurrentStageAreas.get(i).getDistanceToNextPlace(mPlayer);
|
|
|
+ ArrayList<String> rs = a.getResourceNames();
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- if(min>10000000) return -1;
|
|
|
- return min;
|
|
|
+ for(int i=0; i<rs.size(); i++)
|
|
|
+ r.add(findResource(rs.get(i)));
|
|
|
|
|
|
+ return r;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
public Player getPlayer()
|
|
|
{
|
|
|
return mPlayer;
|
|
@@ -580,10 +259,7 @@ public class Game implements Serializable {
|
|
|
mSettings.setARMode(false);
|
|
|
}
|
|
|
|
|
|
- public ArrayList< ArrayList<Resource> > getResourceByStage()
|
|
|
- {
|
|
|
- return mResources.getResourceAquiered();
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
public void restartSensors()
|
|
|
{
|
|
@@ -594,9 +270,7 @@ public class Game implements Serializable {
|
|
|
{
|
|
|
mPlayer.getSensorsManager().stopSensors();
|
|
|
}
|
|
|
- public void printNResource(String str)
|
|
|
- {
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
public static void setGame(Game m)
|
|
@@ -610,36 +284,24 @@ public class Game implements Serializable {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public boolean canSendData() {
|
|
|
- Stage s =getCurrentStageObj();
|
|
|
- if(s==null ) return false;
|
|
|
- if(!s.isTransition()) return false;
|
|
|
- return mResources.getNResourceAquiredByStage()>=s.getNResourceStep() && !isFinished();
|
|
|
- //return mResources.getNResourceLeft()<s.getNResourceStep() && !isFinished();
|
|
|
- }
|
|
|
-
|
|
|
- public boolean isFinished() { return mFinished; }
|
|
|
-
|
|
|
- public void finish() { mFinished=true; }
|
|
|
-
|
|
|
- public int getNResourcesAquired()
|
|
|
- {
|
|
|
- return mResources.getNResourceAquired();
|
|
|
- }
|
|
|
|
|
|
public boolean hasResource(String name)
|
|
|
{
|
|
|
- return mResources.hasResource(name);
|
|
|
+ return mResources.contains(name);
|
|
|
}
|
|
|
|
|
|
+ public ChallengeReturn getReturn() {
|
|
|
+ return mLastReturn;
|
|
|
+ }
|
|
|
|
|
|
- public void printStage()
|
|
|
- {
|
|
|
- Log.e("---------------", "Stage:"+getCurrentStage());
|
|
|
- for(int i=0; i<mResources.getResourceLeft().size(); i++) {
|
|
|
- Log.e("---------------", " '" + mResources.getResourceLeft().get(i).getName() + "'");
|
|
|
-
|
|
|
- }
|
|
|
+ public void setReturn(ChallengeReturn mLastReturn) {
|
|
|
+ this.mLastReturn = mLastReturn;
|
|
|
}
|
|
|
|
|
|
+ public Stage nextStage() {
|
|
|
+ mCurrentStageIndex++;
|
|
|
+ if(mCurrentStageIndex<mStages.size())
|
|
|
+ return mCurrentStage=mStages.get(mCurrentStageIndex);
|
|
|
+ return mCurrentStage=null;
|
|
|
+ }
|
|
|
}
|