diff --git a/core/src/main/kotlin/com/last/commit/Game.kt b/core/src/main/kotlin/com/last/commit/Game.kt index 72779db..6a19558 100644 --- a/core/src/main/kotlin/com/last/commit/Game.kt +++ b/core/src/main/kotlin/com/last/commit/Game.kt @@ -5,7 +5,6 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.Screen import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.scenes.scene2d.ui.Skin -import com.last.commit.audio.SoundEngine import com.last.commit.inventory.Inventory import com.last.commit.screen.* import com.last.commit.stages.DialogStage @@ -51,7 +50,6 @@ class Game : Game() { fun createState() { state = GameState( Inventory(), - SoundEngine, null, DialogStage(Skin(Gdx.files.internal("ui/uiskin.json"))) ) diff --git a/core/src/main/kotlin/com/last/commit/GameState.kt b/core/src/main/kotlin/com/last/commit/GameState.kt index 9cd9a39..f886d75 100644 --- a/core/src/main/kotlin/com/last/commit/GameState.kt +++ b/core/src/main/kotlin/com/last/commit/GameState.kt @@ -1,13 +1,11 @@ package com.last.commit -import com.last.commit.audio.SoundEngine import com.last.commit.inventory.Inventory import com.last.commit.map.MapState import com.last.commit.stages.DialogStage data class GameState( val inventory: Inventory, - val soundEngine: SoundEngine, var map: MapState? = null, val dialogStage: DialogStage ) { diff --git a/core/src/main/kotlin/com/last/commit/Player.kt b/core/src/main/kotlin/com/last/commit/Player.kt index 07ee950..b0ea038 100644 --- a/core/src/main/kotlin/com/last/commit/Player.kt +++ b/core/src/main/kotlin/com/last/commit/Player.kt @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch import com.badlogic.gdx.graphics.g2d.TextureRegion import com.badlogic.gdx.math.Rectangle import com.badlogic.gdx.math.Vector2 +import com.last.commit.audio.SoundEngine class Player(private val textureRegion: TextureRegion, private val gameState: GameState) : Collidable { @@ -35,7 +36,7 @@ class Player(private val textureRegion: TextureRegion, private val gameState: Ga updateCollider() if (System.currentTimeMillis() - lastStep > 500) { - gameState.soundEngine.play("STEPS_INDOOR") //0.5F + SoundEngine.play("STEPS_INDOOR") //0.5F lastStep = System.currentTimeMillis() } } 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 037a860..1f54586 100644 --- a/core/src/main/kotlin/com/last/commit/map/Collectible.kt +++ b/core/src/main/kotlin/com/last/commit/map/Collectible.kt @@ -4,6 +4,7 @@ import com.badlogic.gdx.math.Rectangle import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.scenes.scene2d.ui.Image import com.last.commit.GameState +import com.last.commit.audio.SoundEngine class Collectible( name: String, @@ -23,7 +24,7 @@ class Collectible( override fun interact(otherCollider: Rectangle, state: GameState): Boolean { println("Interacting with item $name") - state.soundEngine.play("GRAB") + SoundEngine.play("GRAB") if (state.inventory.hasItem(this.name)) { state.dialogStage.setTexts("You already have this item.") state.dialogStage.show() diff --git a/core/src/main/kotlin/com/last/commit/map/Door.kt b/core/src/main/kotlin/com/last/commit/map/Door.kt index 9b1de7c..26f013f 100644 --- a/core/src/main/kotlin/com/last/commit/map/Door.kt +++ b/core/src/main/kotlin/com/last/commit/map/Door.kt @@ -4,6 +4,7 @@ import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell import com.badlogic.gdx.math.Rectangle import com.last.commit.GameState import com.last.commit.Wall +import com.last.commit.audio.SoundEngine import com.last.commit.inventory.InventoryItem class Door(gridX: Int, gridY: Int, wallCollider: Rectangle, cell: Cell) : @@ -33,13 +34,13 @@ class Door(gridX: Int, gridY: Int, wallCollider: Rectangle, cell: Cell) : override fun interact(otherCollider: Rectangle, state: GameState): Boolean { println("interacting with door $this") if (isClosed) { - state.soundEngine.play("DOOR_OPEN") + SoundEngine.play("DOOR_OPEN") isOpen = true } else if (isOpen) { if (getCollider().overlaps(otherCollider)) { // can't close the door cause it is colliding with given collider } else { - state.soundEngine.play("DOOR_CLOSE") + SoundEngine.play("DOOR_CLOSE") isOpen = false } } diff --git a/core/src/main/kotlin/com/last/commit/map/MapState.kt b/core/src/main/kotlin/com/last/commit/map/MapState.kt index 5196393..21148b5 100644 --- a/core/src/main/kotlin/com/last/commit/map/MapState.kt +++ b/core/src/main/kotlin/com/last/commit/map/MapState.kt @@ -43,11 +43,12 @@ class MapState(val map: TiledMap, val textureLoader: SpritesheetTextureLoader) { for (obj in map.layers["Teleporter"].objects) { if (obj is RectangleMapObject) { this.teleporters.add(obj) - println("Teleporter ${obj}") } } if (this.teleporters.isEmpty()) { println("No Teleporters defined!") + } else { + println("Found ${teleporters.size} teleporters") } } 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 fa71f0f..a5c0ca6 100644 --- a/core/src/main/kotlin/com/last/commit/map/TimeMap.kt +++ b/core/src/main/kotlin/com/last/commit/map/TimeMap.kt @@ -12,6 +12,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Image import com.last.commit.Collidable import com.last.commit.GameState import com.last.commit.Player +import com.last.commit.audio.SoundEngine import com.last.commit.inventory.SpritesheetTextureLoader @@ -57,7 +58,7 @@ class TimeMap(fileName: String, val state: GameState) { it.rectangle.contains(player.getX(), player.getY()) } if (teleporter != null) { - state.soundEngine.play("TIME_TRAVEL") + SoundEngine.play("TIME_TRAVEL") val targetMap = teleporter.properties.get("target", String::class.java) System.out.println("Teleporting to targetMap $targetMap") loadMap("tiled/$targetMap")