Example #1
0
 public void addGoal(Goal goal) {
   goals.add(goal);
   if (goal instanceof KillGoal) {
     killGoal = ((KillGoal) goal);
   } else if (goal instanceof TimeSurviveGoal) {
     timeGoal = (TimeSurviveGoal) goal;
   }
 }
Example #2
0
 public void reset() {
   LinkedListNode walker = goals.getRoot();
   while (walker != null) {
     Goal goal = (Goal) walker.object;
     goal.reset();
     walker = walker.Next;
   }
 }
Example #3
0
  public int checkGoals() {
    LinkedListNode walker = goals.getRoot();
    int status = Goal.ALIVE;
    // go through goal list to check status of each goal

    if (GameInfo.player.isDead()) return status;

    while (walker != null) {
      Goal goal = (Goal) walker.object;
      int thisStatus = goal.checkGoal();

      // give player benefit of doubt
      if (thisStatus == Goal.WIN) return Goal.WIN;
      else if (thisStatus == Goal.LOSE) status = Goal.LOSE;

      walker = walker.Next;
    }
    return status;
  }