Package com.csse3200.game.areas.terrain
Class TerrainTile
java.lang.Object
com.csse3200.game.areas.terrain.TerrainTile
- All Implemented Interfaces:
com.badlogic.gdx.maps.tiled.TiledMapTile
Custom terrain tile implementation for tiled map terrain that stores
additional properties we
may want to have in the game, such as audio, walking speed, traversability by
AI, etc.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.badlogic.gdx.maps.tiled.TiledMapTile
com.badlogic.gdx.maps.tiled.TiledMapTile.BlendMode
-
Constructor Summary
ConstructorsConstructorDescriptionTerrainTile
(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion, TerrainTile.TerrainCategory terrainCategory) -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.maps.tiled.TiledMapTile.BlendMode
Returns the blend mode of the terrain tileint
getId()
Returns the id of the terrain tilecom.badlogic.gdx.maps.MapObjects
Not required for game, unimplementedReturns the placeable entity that is on the TerrainTilefloat
Returns the x offset of the terrain tilefloat
Returns the y offset of the terrain tilecom.badlogic.gdx.maps.MapProperties
Not required for game, unimplementedfloat
Returns the speed modifier of the terrain tileReturns the terrain tile's terrain category i.e.com.badlogic.gdx.graphics.g2d.TextureRegion
Returns the texture region of the terrain tileboolean
returns if the tile is occupied by another entity (i.e.boolean
returns if the tile is tillable or notboolean
returns whether a terrainTile is traversable or notvoid
Removes any crop tile which occupies the terrain tile.void
setBlendMode
(com.badlogic.gdx.maps.tiled.TiledMapTile.BlendMode blendMode) Sets the blend mode of the terrain tilevoid
setId
(int id) Sets the id of the terrain tilevoid
setOccupant
(Entity occupant) Sets the placeable entity and sets the tile to be occupied if not nullvoid
labels the terrain tile as being occupied (terrain tile does not store actually entity occupying it)void
setOffsetX
(float offsetX) Sets the x offset of the terrain tilevoid
setOffsetY
(float offsetY) Sets the y offset of the terrain tilevoid
setTerrainCategory
(TerrainTile.TerrainCategory terrainCategory) Sets the terrain category of the terrain tile to the specified terrain categoryvoid
setTextureRegion
(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion) Sets the texture region of the terrain tilevoid
labels the terrain tile as being unoccupied
-
Constructor Details
-
TerrainTile
public TerrainTile(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion, TerrainTile.TerrainCategory terrainCategory)
-
-
Method Details
-
getId
public int getId()Returns the id of the terrain tile- Specified by:
getId
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
setId
public void setId(int id) Sets the id of the terrain tile- Specified by:
setId
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
getBlendMode
public com.badlogic.gdx.maps.tiled.TiledMapTile.BlendMode getBlendMode()Returns the blend mode of the terrain tile- Specified by:
getBlendMode
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
setBlendMode
public void setBlendMode(com.badlogic.gdx.maps.tiled.TiledMapTile.BlendMode blendMode) Sets the blend mode of the terrain tile- Specified by:
setBlendMode
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
getTextureRegion
public com.badlogic.gdx.graphics.g2d.TextureRegion getTextureRegion()Returns the texture region of the terrain tile- Specified by:
getTextureRegion
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
setTextureRegion
public void setTextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion) Sets the texture region of the terrain tile- Specified by:
setTextureRegion
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
getOffsetX
public float getOffsetX()Returns the x offset of the terrain tile- Specified by:
getOffsetX
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
setOffsetX
public void setOffsetX(float offsetX) Sets the x offset of the terrain tile- Specified by:
setOffsetX
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
getOffsetY
public float getOffsetY()Returns the y offset of the terrain tile- Specified by:
getOffsetY
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
setOffsetY
public void setOffsetY(float offsetY) Sets the y offset of the terrain tile- Specified by:
setOffsetY
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
getProperties
public com.badlogic.gdx.maps.MapProperties getProperties()Not required for game, unimplemented- Specified by:
getProperties
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
- Returns:
- null
-
getObjects
public com.badlogic.gdx.maps.MapObjects getObjects()Not required for game, unimplemented- Specified by:
getObjects
in interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
- Returns:
- null
-
getTerrainCategory
Returns the terrain tile's terrain category i.e. GRASS, DIRT etc- Returns:
- TerrainCategory of the tile
-
setTerrainCategory
Sets the terrain category of the terrain tile to the specified terrain category- Parameters:
terrainCategory
- new terrain category for terrain tile
-
isTraversable
public boolean isTraversable()returns whether a terrainTile is traversable or not- Returns:
- True is traversable and False if not
-
isOccupied
public boolean isOccupied()returns if the tile is occupied by another entity (i.e. player or NPC) or not- Returns:
- returns true of the tile is occupied by an entity and false if not
-
setOccupied
public void setOccupied()labels the terrain tile as being occupied (terrain tile does not store actually entity occupying it) -
setUnOccupied
public void setUnOccupied()labels the terrain tile as being unoccupied -
isTillable
public boolean isTillable()returns if the tile is tillable or not- Returns:
- returns true if the tile is tillable and false if not
-
getOccupant
Returns the placeable entity that is on the TerrainTile- Returns:
- the placeable entity
-
setOccupant
Sets the placeable entity and sets the tile to be occupied if not null- Parameters:
occupant
- the entity to be placed on the tile
-
removeOccupant
public void removeOccupant()Removes any crop tile which occupies the terrain tile. Does not return the crop tile. -
getSpeedModifier
public float getSpeedModifier()Returns the speed modifier of the terrain tile- Returns:
- the speed modifier of the terrain tile
-