コード例 #1
0
  /** Initializes the internal tilemap. */
  private void init() {
    int numXTiles = engine.pfTilesX();
    int numYTiles = engine.pfTilesY();
    tileMap = new JGPoint[numXTiles][numYTiles];

    for (int i = 0; i < numXTiles; i++) {
      for (int j = 0; j < numYTiles; j++) {
        tileMap[i][j] = new JGPoint(i, j);
      }
    }
  }
コード例 #2
0
  @Override
  public int getCostToMove(JGPoint source) {
    // If no cost map specified, return a default value
    if (costMap == null) {
      return DEFAULT_COST;
    }

    // If no cost specified for a given tile, return a default value
    if (!costMap.containsKey(engine.getTileCid(source.x, source.y))) {
      return DEFAULT_COST;
    }

    return costMap.get(engine.getTileCid(source.x, source.y));
  }
コード例 #3
0
  /**
   * Check if the given tile index is blocked from allowing movement.
   *
   * @param tile Tile to be checked if it is blocked
   * @return Whether the tile is blocked
   */
  private boolean isTileBlocked(JGPoint tile) {
    // If no blocked list, return false
    if (blockedCIDs == null) {
      return false;
    }

    return blockedCIDs.contains(engine.getTileCid(tile.x, tile.y));
  }
コード例 #4
0
 @Override
 public int getNumYTiles() {
   return engine.pfTilesY();
 }
コード例 #5
0
 @Override
 public int getNumXTiles() {
   return engine.pfTilesX();
 }