Class TerrainTile

java.lang.Object
com.csse3200.game.areas.terrain.TerrainTile
All Implemented Interfaces:
com.badlogic.gdx.maps.tiled.TiledMapTile

public class TerrainTile extends Object implements 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 Classes
    Modifier and Type
    Class
    Description
    static enum 
     

    Nested classes/interfaces inherited from interface com.badlogic.gdx.maps.tiled.TiledMapTile

    com.badlogic.gdx.maps.tiled.TiledMapTile.BlendMode
  • Constructor Summary

    Constructors
    Constructor
    Description
    TerrainTile(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion, TerrainTile.TerrainCategory terrainCategory)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.badlogic.gdx.maps.tiled.TiledMapTile.BlendMode
    Returns the blend mode of the terrain tile
    int
    Returns the id of the terrain tile
    com.badlogic.gdx.maps.MapObjects
    Not required for game, unimplemented
    Returns the placeable entity that is on the TerrainTile
    float
    Returns the x offset of the terrain tile
    float
    Returns the y offset of the terrain tile
    com.badlogic.gdx.maps.MapProperties
    Not required for game, unimplemented
    float
    Returns the speed modifier of the terrain tile
    Returns the terrain tile's terrain category i.e.
    com.badlogic.gdx.graphics.g2d.TextureRegion
    Returns the texture region of the terrain tile
    boolean
    returns if the tile is occupied by another entity (i.e.
    boolean
    returns if the tile is tillable or not
    boolean
    returns whether a terrainTile is traversable or not
    void
    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 tile
    void
    setId(int id)
    Sets the id of the terrain tile
    void
    setOccupant(Entity occupant)
    Sets the placeable entity and sets the tile to be occupied if not null
    void
    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 tile
    void
    setOffsetY(float offsetY)
    Sets the y offset of the terrain tile
    void
    Sets the terrain category of the terrain tile to the specified terrain category
    void
    setTextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion textureRegion)
    Sets the texture region of the terrain tile
    void
    labels the terrain tile as being unoccupied

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 interface com.badlogic.gdx.maps.tiled.TiledMapTile
    • setId

      public void setId(int id)
      Sets the id of the terrain tile
      Specified by:
      setId in interface com.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 interface com.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 interface com.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 interface com.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 interface com.badlogic.gdx.maps.tiled.TiledMapTile
    • getOffsetX

      public float getOffsetX()
      Returns the x offset of the terrain tile
      Specified by:
      getOffsetX in interface com.badlogic.gdx.maps.tiled.TiledMapTile
    • setOffsetX

      public void setOffsetX(float offsetX)
      Sets the x offset of the terrain tile
      Specified by:
      setOffsetX in interface com.badlogic.gdx.maps.tiled.TiledMapTile
    • getOffsetY

      public float getOffsetY()
      Returns the y offset of the terrain tile
      Specified by:
      getOffsetY in interface com.badlogic.gdx.maps.tiled.TiledMapTile
    • setOffsetY

      public void setOffsetY(float offsetY)
      Sets the y offset of the terrain tile
      Specified by:
      setOffsetY in interface com.badlogic.gdx.maps.tiled.TiledMapTile
    • getProperties

      public com.badlogic.gdx.maps.MapProperties getProperties()
      Not required for game, unimplemented
      Specified by:
      getProperties in interface com.badlogic.gdx.maps.tiled.TiledMapTile
      Returns:
      null
    • getObjects

      public com.badlogic.gdx.maps.MapObjects getObjects()
      Not required for game, unimplemented
      Specified by:
      getObjects in interface com.badlogic.gdx.maps.tiled.TiledMapTile
      Returns:
      null
    • getTerrainCategory

      public TerrainTile.TerrainCategory getTerrainCategory()
      Returns the terrain tile's terrain category i.e. GRASS, DIRT etc
      Returns:
      TerrainCategory of the tile
    • setTerrainCategory

      public void setTerrainCategory(TerrainTile.TerrainCategory terrainCategory)
      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

      public Entity getOccupant()
      Returns the placeable entity that is on the TerrainTile
      Returns:
      the placeable entity
    • setOccupant

      public void setOccupant(Entity occupant)
      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