Exemplo n.º 1
0
 /**
  * Finds valid start position for the Unit
  *
  * @param f Used field
  * @return Valid position
  */
 public static Vector2D findStartPos(Field f) {
   Point start = new Point(rand.nextInt(f.getTilesX()), rand.nextInt(f.getTilesY()));
   Tile[][] tiles = f.getTiles();
   while (tiles[start.x][start.y].getValue() == 1)
     start = new Point(rand.nextInt(f.getTilesX()), rand.nextInt(f.getTilesY()));
   return f.getWorldPos(start);
 }
Exemplo n.º 2
0
  /**
   * Generates randomly spread towers on a map
   *
   * @param f Used field
   * @param n Number of towers
   * @param g Used game
   * @return List of towers
   */
  public static ArrayList<Entity> randomTowers(Field f, int n, Core g, ArrayList<Team> teams) {
    ArrayList<Entity> list = new ArrayList<Entity>();
    Tile[][] tiles = f.getTiles();
    for (int i = 0; i < n; i++) {
      Point tower = new Point(rand.nextInt(f.getTilesX()), rand.nextInt(f.getTilesY()));
      while (tiles[tower.x][tower.y].getValue() == 1)
        tower = new Point(rand.nextInt(f.getTilesX()), rand.nextInt(f.getTilesY()));

      int team = rand.nextInt(teams.size());
      list.add(new Tower(f.getWorldPos(tower), teams.get(team)));
    }
    return list;
  }
Exemplo n.º 3
0
 /**
  * Creates random circles on a map. Currently the only map generation algorithm.
  *
  * @param f Used field
  * @param n Number of circles
  * @param maxr Maximal radius of circles
  */
 public static void randomCircles(Field f, int n, double maxr) {
   for (int i = 0; i < n; i++) {
     f.createCircle(
         new Vector2D(rand.nextDouble() * f.getTilesX(), rand.nextDouble() * f.getTilesY()),
         rand.nextDouble() * maxr);
   }
 }