|
|
|
@ -11,16 +11,19 @@ import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer
|
|
|
|
|
import com.badlogic.gdx.math.Rectangle
|
|
|
|
|
import com.badlogic.gdx.math.Vector2
|
|
|
|
|
import com.badlogic.gdx.utils.Array
|
|
|
|
|
import com.badlogic.gdx.scenes.scene2d.ui.Image
|
|
|
|
|
import com.last.commit.Collidable
|
|
|
|
|
import com.last.commit.Player
|
|
|
|
|
import com.last.commit.Wall
|
|
|
|
|
import com.last.commit.audio.GameSoundEffect
|
|
|
|
|
import com.last.commit.inventory.InventoryItemTextureLoader
|
|
|
|
|
import Position
|
|
|
|
|
import GameState
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TimeMap(fileName: String, val state: GameState) {
|
|
|
|
|
private val CELL_SIZE = 64
|
|
|
|
|
val textureLoader = InventoryItemTextureLoader("sprites/genericItems_spritesheet_colored")
|
|
|
|
|
|
|
|
|
|
private val walls = Array<Wall>()
|
|
|
|
|
private val doors = Array<Door>()
|
|
|
|
@ -46,6 +49,7 @@ class TimeMap(fileName: String, val state: GameState) {
|
|
|
|
|
loadDimensions()
|
|
|
|
|
loadWalls()
|
|
|
|
|
loadCollectibles()
|
|
|
|
|
this.textureLoader.parse()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun teleport(player: Player) {
|
|
|
|
@ -91,7 +95,12 @@ class TimeMap(fileName: String, val state: GameState) {
|
|
|
|
|
val prop = map.properties
|
|
|
|
|
this.gridWidth = prop.get("width", Int::class.java)
|
|
|
|
|
this.gridHeight = prop.get("height", Int::class.java)
|
|
|
|
|
this.description = prop.get("description", String::class.java)
|
|
|
|
|
|
|
|
|
|
if (prop.containsKey("description")) {
|
|
|
|
|
this.description = prop.get("description", String::class.java)
|
|
|
|
|
} else {
|
|
|
|
|
this.description = "Unknown time"
|
|
|
|
|
}
|
|
|
|
|
this.state.mapDescription = this.description
|
|
|
|
|
this.width = gridWidth * CELL_SIZE
|
|
|
|
|
this.height = gridHeight * CELL_SIZE
|
|
|
|
@ -105,6 +114,7 @@ class TimeMap(fileName: String, val state: GameState) {
|
|
|
|
|
walls.clear()
|
|
|
|
|
doors.clear()
|
|
|
|
|
val wallsLayer = map.layers["Walls"] as TiledMapTileLayer
|
|
|
|
|
|
|
|
|
|
for (column in 0 until wallsLayer.width) {
|
|
|
|
|
for (row in 0 until wallsLayer.height) {
|
|
|
|
|
val cell: TiledMapTileLayer.Cell? = wallsLayer.getCell(column, row)
|
|
|
|
@ -191,6 +201,14 @@ class TimeMap(fileName: String, val state: GameState) {
|
|
|
|
|
fun render(batch: SpriteBatch, camera: OrthographicCamera, delta: Float) {
|
|
|
|
|
mapRenderer.setView(camera)
|
|
|
|
|
mapRenderer.render()
|
|
|
|
|
this.collectibles.forEach { coll ->
|
|
|
|
|
val image = Image(textureLoader.getTexture(coll.name))
|
|
|
|
|
image.x = coll.pos.x + this.getTileWidth() * 0.1f
|
|
|
|
|
image.y = coll.pos.y + this.getTileHeight() * 0.1f
|
|
|
|
|
image.width = this.getTileWidth() * 0.8f
|
|
|
|
|
image.height = this.getTileHeight() * 0.8f
|
|
|
|
|
image.draw(batch, 1f)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun isCollidingWith(collidable: Collidable): Boolean {
|
|
|
|
|