Example #1
0
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    Bundle b = this.getIntent().getExtras();
    mode = b.getInt("mode");
    mv = new MapView(this);
    Globals.mv = mv;
    setContentView(Globals.mv);
    switch (mode) {
      case 0:
        break; // Manual
      case 1:
        br = new BasicRobot(Globals.maze);
        driver = new Gambler();
        try {
          driver.setRobot(br);
        } catch (UnsuitableRobotException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        new RobotTask().execute();

        break; // Gambler

      case 2:
        br = new BasicRobot(Globals.maze);
        driver = new CuriousGambler();
        try {
          driver.setRobot(br);
        } catch (UnsuitableRobotException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        new RobotTask().execute();
        break; // Curious Gambler

      case 3:
        br = new BasicRobot(Globals.maze);
        driver = new WallFollower();
        try {
          driver.setRobot(br);
        } catch (UnsuitableRobotException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        new RobotTask().execute();
        break; // Wall Follower
      case 4:
        br = new BasicRobot(Globals.maze);
        driver = new Wizard();
        try {
          driver.setRobot(br);
        } catch (UnsuitableRobotException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        new RobotTask().execute();
        break; // Wizard
    }
  }
 /**
  * Runs the robot driver's drive2Exit() method and moves to the end screen if the robot wins or
  * loses.
  */
 public void runRobotDriver() {
   try {
     userWins = driver.drive2Exit();
     gameOver = true;
   } catch (Exception e) {
     // Go to the end screen if there was a problem.
     Log.v("Maze", "Error in robot driver");
     userWins = false;
     gameOver = true;
   }
 }
 /** Sets up the robot driver for this maze depending on the type selected */
 private void setUpRobotDriver() {
   switch (driverType) {
     case "Wizard":
       driver = new Wizard();
       driver.setDistance(mazedists);
       driver.setRobot(new BasicRobot(this));
       break;
     case "Wall Follower":
       driver = new WallFollower();
       driver.setRobot(new BasicRobot(this));
       break;
     case "Curious Mouse":
       driver = new CuriousMouse();
       driver.setDimensions(mazew, mazeh);
       driver.setRobot(new BasicRobot(this));
       break;
       // The default case is a manual driver.
     default:
       manualDriver = new ManualDriver();
       driver = manualDriver;
       manualDriver.setRobot(new BasicRobot(this));
       break;
   }
 }