Add removal of collectible from map after collecting it

main
trivernis 1 year ago
parent d977560644
commit f768723d88
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -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

@ -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
)

@ -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 {

@ -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 {

@ -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)
}
}
}

Loading…
Cancel
Save