Package com.prineside.tdi2
Class Map
java.lang.Object
com.prineside.tdi2.Map
- All Implemented Interfaces:
KryoSerializable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final float
static final float
Touchable width of the gatesstatic final int
static final int
static final float
static final float
1 | Road / Spawn / Target / Platform with no building with EWOPstatic final float
WALK_COST_STEP | Modifier (x platform cost)static final float
WALK_COST_STEP ^ 2 | Tower (x platform cost)static final float
WALK_COST_STEP ^ 3 | Any other tilestatic final float
WALK_COST_STEP ^ 4 | Void / barrier -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncpy()
Creates a deep copy of the map with no empty space on the sides.boolean
fitGateToMapPos
(float x, float y, Gate helperGate) Configure the helperGate based on the map's position in pixels.static Map
int
Calculates the seed based on tile types and positions.int
float
getGate
(int x, int y, boolean leftSide) getGateAtPos
(Gate.Pos pos) getGateByMapPos
(float x, float y) Get a gate with a properly set position and side at the specified point.getGatesByType
(Class<T> tClass) Gate[][][]
int
void
getNeighbourTiles
(Array<Tile> toArray, int x, int y) Same as traverseNeighborTiles but fills an arraydouble
int[]
getTargetTile
(boolean exceptionIfNotExists) void
getTeleportGates
(IntMap<Array<TeleportGate>> out) getTile
(int x, int y) getTileAtPos
(Tile.Pos pos) getTileByMapPos
(float mapX, float mapY) getTileByMapPosV
(Vector2 pos) getTileCoordinatesByMapPos
(float mapX, float mapY) static int
getTileIdByPos
(Tile tile) static int
getTileIndex
(float position) getTilesByType
(Class<T> tClass) Tile[][]
int
getWidth()
boolean
void
multiplyPortalsDifficulty
(float mul) static int
positionToCoordinate
(float pos) static int
posToCell
(float v) void
void
void
void
setSize
(int width, int height) Change map's size.void
Change map's tile.void
Should be called in writeObjectStartvoid
traverseNeighborTiles
(int x, int y, Predicate<Tile> predicate) Get tiles neighboring with x,yvoid
void
validate()
Checks the map for a default rules and throws an InvalidMapException if there are problems with the map.void
-
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_11 | Road / Spawn / Target / Platform with no building with EWOP- See Also:
-
WALK_COST_2
public static final float WALK_COST_2WALK_COST_STEP | Modifier (x platform cost)- See Also:
-
WALK_COST_3
public static final float WALK_COST_3WALK_COST_STEP ^ 2 | Tower (x platform cost)- See Also:
-
WALK_COST_4
public static final float WALK_COST_4WALK_COST_STEP ^ 3 | Any other tile- See Also:
-
WALK_COST_MAX
public static final float WALK_COST_MAXWALK_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_WIDTHTouchable width of the gates- See Also:
-
-
Constructor Details
-
Map
public Map(int width, int height) -
Map
- Parameters:
gates
- must be 1 tile higher and wider then the tiles array: [height + 1][width + 1][2]
-
-
Method Details
-
write
- Specified by:
write
in interfaceKryoSerializable
-
read
- Specified by:
read
in interfaceKryoSerializable
-
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
-
getTargetTile
-
traverseNeighborTiles
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
Same as traverseNeighborTiles but fills an array -
getMaxedAbilitiesConfiguration
- Returns:
- ability config based on the Base tile and Boost tiles
-
getTileIdByPos
-
getPrestigeScore
public double getPrestigeScore() -
getTilesByType
-
getGatesByType
-
getTeleportGates
-
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
-
fromJson
-
toJson
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
- Parameters:
leftSide
- left = true, bottom = false. To get the gate at the top / right side of the tile, increase x/y
-
fitGateToMapPos
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
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 pixelsy
- 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
-
getTileAtPos
-
getGateAtPos
-
getTile
- Returns:
- a Tile or null if position is outside of a map or if there's no tile at that position
-
getTilesRaw
-
getGatesRaw
-
getAllTiles
- Returns:
- array of all of the tiles, ordered
-
getAllGates
-
getTileByMapPosV
-
getTileCoordinatesByMapPos
- Returns:
- tile coordinates if mapX and mapY are in valid range, false otherwise. Where a = x, b = y
-
getTileByMapPos
-
setTile
Change map's tile. Incorrect x, y parameters (outside of the map) will throw an exception. -
cpy
-
getTrimBounds
-
getWidth
public int getWidth() -
getHeight
public int getHeight() -
cpyTrimmed
Creates a deep copy of the map with no empty space on the sides. -
getBossWaves
- Returns:
- волны боссов или null
-
posToCell
public static int posToCell(float v) - Parameters:
v
- must be >= -255 (ideally >= 0)
-
getAllowedEnemies
-
getAllowedEnemiesSet
-
getMusicTile
-
validate
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
-