Android Open Source - ARGiE Game State






From Project

Back to project page ARGiE.

License

The source code is released under:

MIT License

If you think the Android project ARGiE listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package headrick.brandon.gamedata;
/*from w  ww .  j  a  v  a  2  s .  c  om*/
import java.util.LinkedList;

import com.google.android.gms.maps.model.LatLng;

import headrick.brandon.models.QuestNode;

/**
 * Singleton class that holds the state of the game and provides access to 
 * the quest information
 */
public class GameState {
    public static char questAlphaLabel = Constants.INITIAL_ALPHA_LABEL_VAL;   //temporarily just for debugging; remove later.
    public static int questNumLabel = Constants.INITIAL_NUM_LABEL_VAL;        //temporarily just for debugging; remove later.

  private static GameState instance = null;
    //the active quest is whatever is the most relevant quest at any point in time; this might
    //be the current quest the user is trying to solve while playing or the current quest that is
    //being edited.
    private static QuestNode activeQuest;
  private static LinkedList<QuestNode> questNodes  = new LinkedList<QuestNode>();
  
  private GameState(){
    //restrict instantiation
  }
  
  /**
   * returns the singleton object (instance) for the GameState class
   * @return the GameState singleton object
   */
  public static GameState getInstance(){
    if(instance == null){
      instance = new GameState();
    }
    return instance;
  }
  
  /**
   * creates and appends a QuestNode object to the end of the QuestNode LinkedList
   * @param title the title of the quest object
   * @param point the location of the quest object to be used on a map
   * @param script the text used to prompt the user when they arrive at a quest location
   * @param answer the required text response when a user is locked from proceeding from one quest to another
   */
  public void addQuest(String title, LatLng point, String script, String answer, double radialThreshold){
    questNodes.add(new QuestNode(title, point, script, answer, radialThreshold));
  }
  
  public void addQuest(QuestNode newQuest) {
    // TODO Auto-generated method stub
    questNodes.add(newQuest);
  }
  
  public QuestNode getRoot(){
    return questNodes.getFirst();
  }
  
  public QuestNode getTail(){
    return questNodes.getLast();
  }
  
  public LinkedList<QuestNode> getQuestNodes(){
    return questNodes;
  }
  
  public boolean isEmpty(){
    return questNodes.size() == 0;
  }
  
  public void removeAllQuests(){
    questNodes.clear();
  }

    public void setActiveQuest(QuestNode questNode){
        activeQuest = questNode;
    }

    public QuestNode getActiveQuest(){
        return activeQuest;
    }
  
}




Java Source Code List

android.UnusedStub.java
headrick.brandon.activities.AboutScreenActivity.java
headrick.brandon.activities.CreateGameActivity.java
headrick.brandon.activities.EditQuestActivity.java
headrick.brandon.activities.GameChooserActivity.java
headrick.brandon.activities.GameOptionsActivity.java
headrick.brandon.activities.RunGameActivity.java
headrick.brandon.activities.SettingsActivity.java
headrick.brandon.activities.SplashActivity.java
headrick.brandon.activities.TitleScreenActivity.java
headrick.brandon.gamedata.Constants.java
headrick.brandon.gamedata.GameSettingsState.java
headrick.brandon.gamedata.GameState.java
headrick.brandon.models.BaseGame.java
headrick.brandon.models.QuestNode.java
headrick.brandon.models.WaypointGame.java
headrick.brandon.utilities.DBReadWrite.java
headrick.brandon.utilities.DBTest.java
headrick.brandon.utilities.DatabaseHandler.java
headrick.brandon.utilities.MapHelper.java