コード例 #1
0
ファイル: GameActivity.java プロジェクト: TronGame/CWA115
  /**
   * Called when the start/stop wall button is pressed or when the proximity sensor detects
   * something
   */
  public void createWall() {
    if (!isAlive) return;

    // Is the player currently creating a wall
    if (!creatingWall) {
      // Start creating a wall
      creatingWall = true; // The player is now creating a wall
      // Create the wall object
      Wall wall =
          new Wall(
              "W" + GameSettings.generateUniqueId(),
              GameSettings.getPlayerId(),
              GameSettings.getWallColor(),
              context);
      wallId = wall.getId(); // Store the wall id
      map.addMapItem(wall); // Add the wall to the map

      // Tell the other devices that a new wall has been created
      gameUpdateHandler.sendCreateWall(
          GameSettings.getPlayerId(), wallId, new ArrayList<LatLng>(), GameSettings.getWallColor());

      // Show the "creating wall" notification
      showNotification(getString(R.string.wall_on_notification), Toast.LENGTH_SHORT);
    }
    // The wall is never turned off
    // else {
    //     // Stop creating the wall
    //     creatingWall = false;                       // The player is no longer creating a wall
    //     wallId = null;                              // Forget about the current wall
    //
    //     // Show the "stopped creating wall" notification
    //     showNotification(getString(R.string.wall_off_notification), Toast.LENGTH_SHORT);
    // }
  }