diff --git a/core/src/main/kotlin/com/last/commit/Game.kt b/core/src/main/kotlin/com/last/commit/Game.kt index e3584ef..bf5410a 100644 --- a/core/src/main/kotlin/com/last/commit/Game.kt +++ b/core/src/main/kotlin/com/last/commit/Game.kt @@ -9,6 +9,7 @@ import com.last.commit.config.GameSettings import com.last.commit.config.TimeTravelAssetManager import com.last.commit.inventory.Inventory import com.last.commit.screen.* +import com.last.commit.map.MapState import java.awt.AWTEventMulticaster import java.sql.Time diff --git a/core/src/main/kotlin/com/last/commit/GameState.kt b/core/src/main/kotlin/com/last/commit/GameState.kt index f8695a6..9736d6e 100644 --- a/core/src/main/kotlin/com/last/commit/GameState.kt +++ b/core/src/main/kotlin/com/last/commit/GameState.kt @@ -2,11 +2,12 @@ import com.last.commit.inventory.Inventory import com.last.commit.config.GameSettings import com.last.commit.audio.SoundEngine import com.last.commit.config.TimeTravelAssetManager +import com.last.commit.map.MapState data class GameState( val inventory: Inventory, val settings: GameSettings, val soundEngine: SoundEngine, val assetManager: TimeTravelAssetManager, - var mapDescription: String = "2020", + var map: MapState? = null ) \ No newline at end of file diff --git a/core/src/main/kotlin/com/last/commit/map/Collectible.kt b/core/src/main/kotlin/com/last/commit/map/Collectible.kt index e7be7d2..dd844dc 100644 --- a/core/src/main/kotlin/com/last/commit/map/Collectible.kt +++ b/core/src/main/kotlin/com/last/commit/map/Collectible.kt @@ -25,6 +25,7 @@ class Collectible( println("Interacting with item $name") state.soundEngine.play(GameSoundEffect.GRAB) state.inventory.add(this.name) + state.map?.collectibles?.remove(this) } override fun canInteract(state: GameState): Boolean { diff --git a/core/src/main/kotlin/com/last/commit/map/TimeMap.kt b/core/src/main/kotlin/com/last/commit/map/TimeMap.kt index 600df1b..050b82c 100644 --- a/core/src/main/kotlin/com/last/commit/map/TimeMap.kt +++ b/core/src/main/kotlin/com/last/commit/map/TimeMap.kt @@ -51,6 +51,7 @@ class TimeMap(fileName: String, val state: GameState) { init { map = mapLoader.load(fileName) mapState = MapState(map) + state.map = mapState mapStates[fileName] = mapState mapRenderer = OrthogonalTiledMapRenderer(map) this.textureLoader.parse() @@ -80,6 +81,7 @@ class TimeMap(fileName: String, val state: GameState) { mapState = MapState(map) mapStates[name] = mapState } + state.map = mapState } fun getPlayerSpawn(): Vector2 { diff --git a/core/src/main/kotlin/com/last/commit/stages/UIStage.kt b/core/src/main/kotlin/com/last/commit/stages/UIStage.kt index 9dc93c6..b286f15 100644 --- a/core/src/main/kotlin/com/last/commit/stages/UIStage.kt +++ b/core/src/main/kotlin/com/last/commit/stages/UIStage.kt @@ -11,7 +11,7 @@ import com.last.commit.inventory.InventoryItemTextureLoader class UIStage(path: String, val state: GameState) : Stage() { val textureLoader = InventoryItemTextureLoader(path) private val labelStyle = Label.LabelStyle(BitmapFont(), Color.BLACK) - var mapLabel = Label(state.mapDescription, labelStyle) + var mapLabel = Label("unknown time", labelStyle) var fpsLabel = Label("0", labelStyle) private var lastFpsUpdate = 0L @@ -60,10 +60,12 @@ class UIStage(path: String, val state: GameState) : Stage() { } private fun addMapDescriptionLabel() { - this.actors.removeValue(this.mapLabel, true) - this.mapLabel = Label(state.mapDescription, labelStyle) - mapLabel.x = 0f - mapLabel.y = this.viewport.worldHeight - mapLabel.height - addActor(mapLabel) + if (state.map != null) { + this.actors.removeValue(this.mapLabel, true) + this.mapLabel = Label(state.map!!.description, labelStyle) + mapLabel.x = 0f + mapLabel.y = this.viewport.worldHeight - mapLabel.height + addActor(mapLabel) + } } }