Class Map

java.lang.Object
com.prineside.tdi2.Map
All Implemented Interfaces:
KryoSerializable

public final class Map extends Object implements KryoSerializable
  • Field Details

    • MAX_TECHNICAL_SIZE

      public static final int MAX_TECHNICAL_SIZE
      See Also:
    • MAX_SIZE

      public static final int MAX_SIZE
      See Also:
    • WALK_COST_1

      public static final float WALK_COST_1
      1 | Road / Spawn / Target / Platform with no building with EWOP
      See Also:
    • WALK_COST_2

      public static final float WALK_COST_2
      WALK_COST_STEP | Modifier (x platform cost)
      See Also:
    • WALK_COST_3

      public static final float WALK_COST_3
      WALK_COST_STEP ^ 2 | Tower (x platform cost)
      See Also:
    • WALK_COST_4

      public static final float WALK_COST_4
      WALK_COST_STEP ^ 3 | Any other tile
      See Also:
    • WALK_COST_MAX

      public static final float WALK_COST_MAX
      WALK_COST_STEP ^ 4 | Void / barrier
      See Also:
    • VOID_WALK_COST

      public static final float VOID_WALK_COST
      See Also:
    • BARRIER_WALK_COST

      public static final float BARRIER_WALK_COST
      See Also:
    • GATE_HIT_AREA_WIDTH

      public static final float GATE_HIT_AREA_WIDTH
      Touchable width of the gates
      See Also:
  • Constructor Details

    • Map

      public Map(int width, int height)
    • Map

      public Map(Tile[][] tiles, Gate[][][] gates)
      Parameters:
      gates - must be 1 tile higher and wider then the tiles array: [height + 1][width + 1][2]
  • Method Details

    • write

      public void write(Kryo kryo, Output output)
      Specified by:
      write in interface KryoSerializable
    • read

      public void read(Kryo kryo, Input input)
      Specified by:
      read in interface KryoSerializable
    • positionToCoordinate

      public static int positionToCoordinate(float pos)
      Returns:
      -1 if position is invalid
    • getTileIndex

      public static int getTileIndex(float position)
      Returns:
      -1 if position is invalid
    • getTargetTileOrThrow

      public TargetTile getTargetTileOrThrow()
    • getTargetTile

      public TargetTile getTargetTile(boolean exceptionIfNotExists)
    • traverseNeighborTiles

      public void traverseNeighborTiles(int x, int y, Predicate<Tile> predicate)
      Get tiles neighboring with x,y
      Parameters:
      predicate - is being evaluated for every tile near x,y. If predicate returns false, this method will stop traversing the neighbors
    • getNeighbourTiles

      public void getNeighbourTiles(Array<Tile> toArray, int x, int y)
      Same as traverseNeighborTiles but fills an array
    • getMaxedAbilitiesConfiguration

      public AbilitySelectionOverlay.SelectedAbilitiesConfiguration getMaxedAbilitiesConfiguration()
      Returns:
      ability config based on the Base tile and Boost tiles
    • getTileIdByPos

      public static int getTileIdByPos(Tile tile)
    • getPrestigeScore

      public double getPrestigeScore()
    • getTilesByType

      public <T extends Tile> Array<T> getTilesByType(Class<T> tClass)
    • getGatesByType

      public <T extends Gate> Array<T> getGatesByType(Class<T> tClass)
    • getTeleportGates

      public void getTeleportGates(IntMap<Array<TeleportGate>> out)
    • multiplyPortalsDifficulty

      public void multiplyPortalsDifficulty(float mul)
    • getAverageDifficulty

      public int getAverageDifficulty()
      Returns:
      average difficulty of all portals
    • getDifficultyExpectedPlaytime

      public float getDifficultyExpectedPlaytime()
    • setSize

      public void setSize(int width, int height)
      Change map's size. Reduction removes tiles at the right / top edge of the map. Increasing map's size will preserve positions of tiles and gates. ! All tiles that are about to be removed (if you reduce map's size) should be removed first (setTile() / setGate())
    • getResourcesCount

      public int[] getResourcesCount()
      Returns:
      amount of resources on the map. Last index (ResourceType.values.length). Last index is a sum of round((1f - sourceTile.getResourceDensity()) * tileResourcesCount) for whatever reason.
    • unloadPreview

      public void unloadPreview()
    • regeneratePreview

      public void regeneratePreview()
    • getPreview

      public MapManager.MapPreview getPreview()
    • fromJson

      public static Map fromJson(JsonValue jsonValue)
    • toJson

      public void toJson(Json json)
      Should be called in writeObjectStart
    • generateSeed

      public int generateSeed()
      Calculates the seed based on tile types and positions. Should not be used as a hashCode, because many things are not accounted for.
    • hasTileThatAllowsWalkablePlatforms

      public boolean hasTileThatAllowsWalkablePlatforms()
    • getGate

      @Null public Gate getGate(int x, int y, boolean leftSide)
      Parameters:
      leftSide - left = true, bottom = false. To get the gate at the top / right side of the tile, increase x/y
    • fitGateToMapPos

      public boolean fitGateToMapPos(float x, float y, Gate helperGate)
      Configure the helperGate based on the map's position in pixels. Resulting helperGate will have its position and side set to appear at the point x, y, lust like when you click at that point on map and select a tile.
      Returns:
      true if gate can be placed at the specified position
    • getGateByMapPos

      @Null public Gate getGateByMapPos(float x, float y)
      Get a gate with a properly set position and side at the specified point. Useful for handling click positions.
      Parameters:
      x - X position on a map in pixels
      y - Y position on a map in pixels
      Returns:
      always the same instance of a gate (not to be used, read-only) that you would normally select if you click at that point, or null if there can be no gate at that point.
    • setGate

      public void setGate(int x, int y, boolean leftSide, @Null Gate gate)
    • getTileAtPos

      @Null public Tile getTileAtPos(Tile.Pos pos)
    • getGateAtPos

      @Null public Gate getGateAtPos(Gate.Pos pos)
    • getTile

      @Null public Tile getTile(int x, int y)
      Returns:
      a Tile or null if position is outside of a map or if there's no tile at that position
    • getTilesRaw

      public Tile[][] getTilesRaw()
    • getGatesRaw

      public Gate[][][] getGatesRaw()
    • getAllTiles

      public DelayedRemovalArray<Tile> getAllTiles()
      Returns:
      array of all of the tiles, ordered
    • getAllGates

      public DelayedRemovalArray<Gate> getAllGates()
    • getTileByMapPosV

      public Tile getTileByMapPosV(Vector2 pos)
    • getTileCoordinatesByMapPos

      @Null public IntPair getTileCoordinatesByMapPos(float mapX, float mapY)
      Returns:
      tile coordinates if mapX and mapY are in valid range, false otherwise. Where a = x, b = y
    • getTileByMapPos

      public Tile getTileByMapPos(float mapX, float mapY)
    • setTile

      public void setTile(int x, int y, @Null Tile tile)
      Change map's tile. Incorrect x, y parameters (outside of the map) will throw an exception.
    • cpy

      public Map cpy()
    • getTrimBounds

      public IntRectangle getTrimBounds()
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • cpyTrimmed

      public Map cpyTrimmed()
      Creates a deep copy of the map with no empty space on the sides.
    • getBossWaves

      @Null public WaveBossSupplier getBossWaves()
      Returns:
      волны боссов или null
    • posToCell

      public static int posToCell(float v)
      Parameters:
      v - must be >= -255 (ideally >= 0)
    • getAllowedEnemies

      public Array<EnemyType> getAllowedEnemies()
    • getAllowedEnemiesSet

      public ObjectSet<EnemyType> getAllowedEnemiesSet()
    • getMusicTile

      public XmMusicTrackTile getMusicTile()
    • validate

      public void validate() throws Map.InvalidMapException
      Checks the map for a default rules and throws an InvalidMapException if there are problems with the map. Does not validate pathfinding.
      Throws:
      Map.InvalidMapException