Exemplo n.º 1
0
 @Override
 protected Void doInBackground(Integer... params) {
   try {
     Log.v("drive", "2exit");
     if (driver.drive2Exit() == false) {
       Toast.makeText(StatePlay.this, "Fuel Empty", Toast.LENGTH_SHORT).show();
       Intent i = new Intent(StatePlay.this, AMazeActivity.class);
       startActivity(i);
     }
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return (null);
 }
Exemplo n.º 2
0
    @Override
    protected void onDraw(Canvas canvas) {
      if (Globals.maze.state == 4) {
        Log.v("stateFinished", "activity");
        Intent i = new Intent(StatePlay.this, StateFinish.class);
        startActivity(i);
      } else {
        Globals.gw.setCanvas(canvas);
        Globals.gw.setColor(Color.DKGRAY);
        canvas.drawRect(0, 200, 400, 400, Globals.gw.paint);

        if (Globals.maze.firstpersondrawer == null) {
        } else {
          Globals.maze.start();
        }
      }
    }
Exemplo n.º 3
0
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    super.onKeyDown(keyCode, event);
    if (mode == 0) {
      switch (keyCode) {
          /** navigation key commands * */
        case KeyEvent.KEYCODE_DPAD_UP:
          Globals.maze.walk(1);
          Globals.mv.invalidate();
          Log.v("walkstage", "complete");
          return true;
        case KeyEvent.KEYCODE_DPAD_DOWN:
          // Globals.gw.ArrayInit();
          Globals.maze.walk(-1);
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
          // Globals.gw.ArrayInit();
          Globals.maze.rotate(-1);
          mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_DPAD_LEFT:
          // Globals.gw.ArrayInit();
          Log.v("keypadleft", "down");
          Globals.maze.rotate(1);
          Log.v("rotate", "finished");
          Globals.mv.invalidate();
          return true;

          /** Map view key commands * */
        case KeyEvent.KEYCODE_M:
          Log.v("mapkey", "pressed");
          Globals.maze.map_mode = !Globals.maze.map_mode;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_Z:
          Globals.maze.showMaze = !Globals.maze.showMaze;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_S:
          Globals.maze.showSolution = !Globals.maze.showSolution;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_PLUS:
          Log.v("keycode", "plus");
          if (Globals.maze.showMaze) {
            Globals.maze.mapdrawer.incrementMapScale();
            Log.v("inside", "plus keycode");
            Globals.mv.invalidate();
          }
          return true;
        case KeyEvent.KEYCODE_MINUS:
          if (Globals.maze.showMaze) {
            Globals.maze.mapdrawer.decrementMapScale();
            Globals.mv.invalidate();
          }
          return true;

        case KeyEvent.KEYCODE_BACK:
          Toast.makeText(this, "Back to Start", Toast.LENGTH_SHORT).show();
          Intent i = new Intent(StatePlay.this, AMazeActivity.class);
          startActivity(i);
          return true;
      }

    } else {
      /** this is in a non-manual mode * */
      switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
          Toast.makeText(this, "Back to Start", Toast.LENGTH_SHORT).show();
          Intent i = new Intent(StatePlay.this, AMazeActivity.class);
          startActivity(i);
          return true;
        case KeyEvent.KEYCODE_M:
          Log.v("mapkey", "pressed");
          Globals.maze.map_mode = !Globals.maze.map_mode;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_Z:
          Globals.maze.showMaze = !Globals.maze.showMaze;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_S:
          Globals.maze.showSolution = !Globals.maze.showSolution;
          Globals.mv.invalidate();
          return true;
        case KeyEvent.KEYCODE_PLUS:
          Log.v("keycode", "plus");
          if (Globals.maze.showMaze) {
            Globals.maze.mapdrawer.incrementMapScale();
            Log.v("inside", "plus keycode");
            Globals.mv.invalidate();
          } //
          return true;
        case KeyEvent.KEYCODE_MINUS:
          if (Globals.maze.showMaze) {
            Globals.maze.mapdrawer.decrementMapScale();
            Globals.mv.invalidate();
          }
          return true;
      }
    }

    return false;
  }