@Override
 public void execute() {
   if (!Variables.isDefined(SCORE_VARIABLE)) {
     Variables.setValue(SCORE_VARIABLE, 0);
   }
   int deltaScore = Integer.parseInt(params.get("value"));
   int resultingScore = addToScore(deltaScore);
   if (resultingScore == 0) {
     GeoQuestApp.showMessage(ctx.getText(R.string.scoreZero));
   } else if (deltaScore > 0) {
     // GeoQuestApp.playAudio(ResourceManager.POSITIVE_SOUND, false);
     GeoQuestApp.showMessage(ctx.getText(R.string.scoreIncreasedBy) + " " + deltaScore);
   } else if (deltaScore < 0) {
     // GeoQuestApp.playAudio(ResourceManager.NEGATIVE_SOUND, false);
     GeoQuestApp.showMessage(ctx.getText(R.string.scoreDecreasedBy) + " " + (-deltaScore));
   }
 }
Ejemplo n.º 2
0
  /** starts the basic AR view */
  private void startARViewBasic() {

    // Create the basic intent
    if (wikitudeIntent == null) wikitudeIntent = prepareIntent();

    // And launch the intent
    try {
      GeoQuestApp.showMessage(getText(R.string.startingARView));
      wikitudeIntent.startIntent(this);
    } catch (ActivityNotFoundException e) {
      AbstractWikitudeARIntent.handleWikitudeNotFound(this);
    }
  }
public class Score extends Action {

  static final String SCORE_VARIABLE = "score";

  private Context ctx = GeoQuestApp.getContext();

  @Override
  protected boolean checkInitialization() {
    boolean initOK = true;
    initOK &= params.containsKey("value");
    return initOK;
  }

  @Override
  public void execute() {
    if (!Variables.isDefined(SCORE_VARIABLE)) {
      Variables.setValue(SCORE_VARIABLE, 0);
    }
    int deltaScore = Integer.parseInt(params.get("value"));
    int resultingScore = addToScore(deltaScore);
    if (resultingScore == 0) {
      GeoQuestApp.showMessage(ctx.getText(R.string.scoreZero));
    } else if (deltaScore > 0) {
      // GeoQuestApp.playAudio(ResourceManager.POSITIVE_SOUND, false);
      GeoQuestApp.showMessage(ctx.getText(R.string.scoreIncreasedBy) + " " + deltaScore);
    } else if (deltaScore < 0) {
      // GeoQuestApp.playAudio(ResourceManager.NEGATIVE_SOUND, false);
      GeoQuestApp.showMessage(ctx.getText(R.string.scoreDecreasedBy) + " " + (-deltaScore));
    }
  }

  private int addToScore(int score) {
    int resultScore = (Integer) Variables.getValue(SCORE_VARIABLE) + score;
    if (resultScore < 0) resultScore = 0;
    Variables.setValue(SCORE_VARIABLE, resultScore);
    return resultScore;
  }
}
Ejemplo n.º 4
0
 /**
  * called by the android framework when the activity gets active. Registers the myLocationOverlay
  * listeners.
  */
 @Override
 protected void onDestroy() {
   if (myLocationManager != null) myLocationManager.removeUpdates(locationListener);
   GeoQuestApp.getInstance().setGoogleMap(null);
   super.onDestroy();
 }
Ejemplo n.º 5
0
  /**
   * Called when the activity is first created. Setups google mapView, the map overlays and the
   * listeners
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(this.getClass().getName(), "creating activity");
    super.onCreate(savedInstanceState);

    // get extras
    Bundle extras = getIntent().getExtras();
    String id = extras.getString("missionID");
    mission = Mission.get(id);
    mission.setStatus(Globals.STATUS_RUNNING);

    setContentView(R.layout.main);

    // Setup Google MapView
    myMapView = (MapView) findViewById(R.id.mapview);
    myMapView.setBuiltInZoomControls(false);
    myMapView.displayZoomControls(false);

    String mapKind = mission.xmlMissionNode.attributeValue("mapkind");
    if (mapKind == null || mapKind.equals("map")) myMapView.setSatellite(false);
    else myMapView.setSatellite(true);

    myMapCtrl = myMapView.getController();

    myMapCtrl.setZoom(18);
    String zoomLevel = mission.xmlMissionNode.attributeValue("zoomlevel");
    if (zoomLevel != null) {
      int zoomLevelInt = Integer.parseInt(zoomLevel);
      if (zoomLevelInt > 0 && zoomLevelInt < 24) myMapCtrl.setZoom(zoomLevelInt);
    }

    // Setup Zoom Controls:
    Button zoomIn = (Button) findViewById(R.id.zoom_in);
    zoomIn.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            myMapCtrl.zoomIn();
          }
        });

    Button zoomOut = (Button) findViewById(R.id.zoom_out);
    zoomOut.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            myMapCtrl.zoomOut();
          }
        });

    // Initialize location stuff:
    locationListener =
        new GeoQuestLocationListener(this) {
          public void onRelevantLocationChanged(Location location) {
            super.onRelevantLocationChanged(location);
            GeoPoint point = location2GP(location);
            myMapCtrl.animateTo(point);

            // calculate distance to hotspots
            for (Iterator<HotspotOld> i = hotspots.listIterator(); i.hasNext(); ) {
              HotspotOld hotspot = i.next(); // TODO: throws a
              // ConcurrentModificationException
              // sometimes (hm)
              hotspot.inRange(location);
            }
          }
        };

    try {
      long timeStepMockMode = Long.parseLong(getText(R.string.map_mockGPSTimeInterval).toString());
      locationSource =
          new LocationSource(getApplicationContext(), locationListener, handler, timeStepMockMode);
      locationSource.setMode(LocationSource.REAL_MODE);
    } catch (Exception e) {
      e.printStackTrace();
    }

    // startMissionsList
    startMissionPanel = (LinearLayout) findViewById(R.id.startMissionPanel);

    // Players Location Overlay
    myLocationOverlay = new MyLocationOverlay(this, myMapView);
    myLocationOverlay.enableCompass(); // doesn't work in the emulator?
    myLocationOverlay.enableMyLocation();
    myMapView.getOverlays().add(myLocationOverlay);

    GeoQuestApp.getInstance().setGoogleMap(myMapView);

    // Show loading screen to Parse the Game XML File
    // indirectly calls onCreateDialog() and initializes hotspots
    showDialog(READXML_DIALOG);

    mission.applyOnStartRules();
  }