Class Map

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

public final class Map extends Object implements com.esotericsoftware.kryo.KryoSerializable
  • Field Details

  • Constructor Details

    • Map

      public Map(int width, int height)
    • Map

      public Map(Tile[][] tiles, Gate[][][] gates)
      Parameters:
      gates - должен быть на 1 тайл шире и выше: [height + 1][width + 1][Gate.Side.values.length]
  • Method Details

    • write

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

      public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input)
      Specified by:
      read in interface com.esotericsoftware.kryo.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
    • getTargetTile

      public TargetTile getTargetTile()
    • getTargetTile

      public TargetTile getTargetTile(boolean exceptionIfNotExists)
    • traverseNeighborTiles

      public void traverseNeighborTiles(int x, int y, com.badlogic.gdx.utils.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(com.badlogic.gdx.utils.Array<Tile> toArray, int x, int y)
      Same as traverseNeighborTiles but fills an array
    • getMaxedAbilitiesConfiguration

      public AbilitySelectionOverlay.SelectedAbilitiesConfiguration getMaxedAbilitiesConfiguration()
      Returns:
      конфигурацию навыков, которые дает база и GV-тайлы
    • getTileIdByPos

      public static int getTileIdByPos(Tile tile)
    • getPrestigeScore

      public double getPrestigeScore()
    • getTilesByType

      public <T extends Tile> com.badlogic.gdx.utils.Array<T> getTilesByType(Class<T> tClass)
    • getGatesByType

      public <T extends Gate> com.badlogic.gdx.utils.Array<T> getGatesByType(Class<T> tClass)
    • getTeleportGates

      public void getTeleportGates(com.badlogic.gdx.utils.IntMap<com.badlogic.gdx.utils.Array<TeleportGate>> out)
    • multiplyPortalsDifficulty

      public void multiplyPortalsDifficulty(float mul)
    • getAverageDifficulty

      public int getAverageDifficulty()
      Returns:
      среднюю сложность порталов
    • getDifficultyExpectedPlaytime

      public float getDifficultyExpectedPlaytime()
    • setSize

      public void setSize(int width, int height)
      Изменить размер карты Уменьшается удалением тайлов справа / сверху. При увеличении позиции тайлов и гейтов не изменяются. ! Все тайлы, которые будут отброшены (при уменьшении карты) необходимо сначала убрать (setTile() / setGate())
    • getResourcesCount

      public int[] getResourcesCount()
      Returns:
      количество ресурсов на всей карте. Последний индекс (ResourceType.values.length) - сколько относительно "пустых" ресурсов (из-за плотности ресурсов)
    • unloadPreview

      public void unloadPreview()
    • regeneratePreview

      public void regeneratePreview()
    • getPreview

      public MapManager.MapPreview getPreview()
    • fromJson

      public static Map fromJson(com.badlogic.gdx.utils.JsonValue jsonValue)
    • toJson

      public void toJson(com.badlogic.gdx.utils.Json json)
      Вызывать в writeObjectStart
    • generateSeed

      public int generateSeed()
      Считает seed по тайлам карты (их типу и позиции) Лучше не использовать как hashCode, так как не все поля тайлов учитываются
    • hasTileThatAllowsWalkablePlatforms

      public boolean hasTileThatAllowsWalkablePlatforms()
    • getGate

      public Gate getGate(int x, int y, boolean leftSide)
      Получить барьер или null, если его нет.
      Parameters:
      leftSide - сторона тайла. Чтобы получить верхний: y + 1 BOTTOM, чтобы получить правый: y + 1 LEFT
    • fitGateToMapPos

      public boolean fitGateToMapPos(float x, float y, Gate helperGate)
      Returns:
      Gate, если точка на карте, в противном случае null (в этой точке барьер поставить нельзя)
    • getGateByMapPos

      public Gate getGateByMapPos(float x, float y)
      Получить барьер по точке на карте (в основном используется для обработки касаний)
    • setGate

      public void setGate(int x, int y, boolean leftSide, Gate gate)
    • getTile

      @Null public Tile getTile(Tile.Pos pos)
    • getGate

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

      public Tile getTile(int x, int y)
      Returns:
      Tile или null, если тайла нет или позиция за рамками карты
    • getTilesRaw

      public Tile[][] getTilesRaw()
    • getGatesRaw

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

      public com.badlogic.gdx.utils.DelayedRemovalArray<Tile> getAllTiles()
      Returns:
      array of all of the tiles, ordered
    • getAllGates

      public com.badlogic.gdx.utils.DelayedRemovalArray<Gate> getAllGates()
    • getTileByMapPos

      public Tile getTileByMapPos(com.badlogic.gdx.math.Vector2 pos)
    • getTileCoordinatesByMapPos

      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, Tile tile)
      Изменить тайл карты
      Parameters:
      tile - может быть null
    • cpy

      public Map cpy()
    • getTrimBounds

      public IntRectangle getTrimBounds()
    • getWidth

      public int getWidth()
    • getHeight

      public int getHeight()
    • cpyTrimmed

      public Map cpyTrimmed()
      Создает копию карты без пустоты по бокам
    • getBossWaves

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

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

      public com.badlogic.gdx.utils.Array<EnemyType> getAllowedEnemies()
    • getAllowedEnemiesSet

      public com.badlogic.gdx.utils.ObjectSet<EnemyType> getAllowedEnemiesSet()
    • getMusicTile

      public XmMusicTrackTile getMusicTile()
    • validate

      public void validate() throws Map.InvalidMapException
      Проверяет формат карты. НЕ проверяет, есть ли путь от спавна до цели
      Throws:
      Map.InvalidMapException