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.BlendModeReturns the blend mode of the terrain tileintgetId()Returns the id of the terrain tilecom.badlogic.gdx.maps.MapObjectsNot required for game, unimplementedReturns the placeable entity that is on the TerrainTilefloatReturns the x offset of the terrain tilefloatReturns the y offset of the terrain tilecom.badlogic.gdx.maps.MapPropertiesNot required for game, unimplementedfloatReturns the speed modifier of the terrain tileReturns the terrain tile's terrain category i.e.com.badlogic.gdx.graphics.g2d.TextureRegionReturns the texture region of the terrain tilebooleanreturns if the tile is occupied by another entity (i.e.booleanreturns if the tile is tillable or notbooleanreturns whether a terrainTile is traversable or notvoidRemoves any crop tile which occupies the terrain tile.voidsetBlendMode(com.badlogic.gdx.maps.tiled.TiledMapTile.BlendMode blendMode) Sets the blend mode of the terrain tilevoidsetId(int id) Sets the id of the terrain tilevoidsetOccupant(Entity occupant) Sets the placeable entity and sets the tile to be occupied if not nullvoidlabels the terrain tile as being occupied (terrain tile does not store actually entity occupying it)voidsetOffsetX(float offsetX) Sets the x offset of the terrain tilevoidsetOffsetY(float offsetY) Sets the y offset of the terrain tilevoidsetTerrainCategory(TerrainTile.TerrainCategory terrainCategory) Sets the terrain category of the terrain tile to the specified terrain categoryvoidsetTextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion) Sets the texture region of the terrain tilevoidlabels 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:
getIdin interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
setId
public void setId(int id) Sets the id of the terrain tile- Specified by:
setIdin 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:
getBlendModein 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:
setBlendModein 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:
getTextureRegionin 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:
setTextureRegionin interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
getOffsetX
public float getOffsetX()Returns the x offset of the terrain tile- Specified by:
getOffsetXin interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
setOffsetX
public void setOffsetX(float offsetX) Sets the x offset of the terrain tile- Specified by:
setOffsetXin interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
getOffsetY
public float getOffsetY()Returns the y offset of the terrain tile- Specified by:
getOffsetYin interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
setOffsetY
public void setOffsetY(float offsetY) Sets the y offset of the terrain tile- Specified by:
setOffsetYin interfacecom.badlogic.gdx.maps.tiled.TiledMapTile
-
getProperties
public com.badlogic.gdx.maps.MapProperties getProperties()Not required for game, unimplemented- Specified by:
getPropertiesin interfacecom.badlogic.gdx.maps.tiled.TiledMapTile- Returns:
- null
-
getObjects
public com.badlogic.gdx.maps.MapObjects getObjects()Not required for game, unimplemented- Specified by:
getObjectsin 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
-