diff --git a/assets/tiled/level_herbst.tmx b/assets/tiled/level_herbst.tmx
index f19218c..1975e45 100644
--- a/assets/tiled/level_herbst.tmx
+++ b/assets/tiled/level_herbst.tmx
@@ -356,7 +356,7 @@
0,0,0,0,184,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,0,0,0,0,0,0,0,0,177,0,0,0,0,0,0,0,0,0,
0,0,0,0,211,212,0,0,184,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,129,129,0,0,0,0,0,129,177,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,211,212,0,0,0,0,0,0,0,0,184,185,0,0,0,0,0,0,184,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,129,129,0,0,0,0,129,129,177,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,211,212,0,0,0,0,0,0,211,212,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,204,204,204,467,204,204,204,204,153,0,0,0,0,0,0,0,0,0,
+0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,211,212,0,0,0,0,0,0,211,212,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,204,204,204,299,204,204,204,204,153,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,184,185,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
diff --git a/assets/tiled/tilesheet_complete.png b/assets/tiled/tilesheet_complete.png
index 904e7b3..e82553b 100644
Binary files a/assets/tiled/tilesheet_complete.png and b/assets/tiled/tilesheet_complete.png differ
diff --git a/assets/tiled/tilesheet_complete.tsx b/assets/tiled/tilesheet_complete.tsx
index f5f8137..82de67e 100644
--- a/assets/tiled/tilesheet_complete.tsx
+++ b/assets/tiled/tilesheet_complete.tsx
@@ -4,2701 +4,3241 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
+
+
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
-
+
+
+
+
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/src/main/kotlin/com/last/commit/GameInputProcessor.kt b/core/src/main/kotlin/com/last/commit/GameInputProcessor.kt
index 654ee48..1a46eae 100644
--- a/core/src/main/kotlin/com/last/commit/GameInputProcessor.kt
+++ b/core/src/main/kotlin/com/last/commit/GameInputProcessor.kt
@@ -1,10 +1,9 @@
package com.last.commit
-import com.badlogic.gdx.Input
import com.badlogic.gdx.InputProcessor
import com.last.commit.screen.TimeTravelScreen
-class GameInputProcessor(val game: Game, ) : InputProcessor{
+class GameInputProcessor(val game: Game) : InputProcessor {
lateinit var activeScreen: TimeTravelScreen
@@ -13,6 +12,7 @@ class GameInputProcessor(val game: Game, ) : InputProcessor{
}
override fun keyTyped(character: Char): Boolean {
+
return false
}
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 d81303b..8f9934a 100644
--- a/core/src/main/kotlin/com/last/commit/map/Collectible.kt
+++ b/core/src/main/kotlin/com/last/commit/map/Collectible.kt
@@ -1,15 +1,17 @@
package com.last.commit.map
+import GameState
+import Position
import com.badlogic.gdx.math.Rectangle
import com.last.commit.audio.GameSoundEffect
-import Position
-import GameState
+import com.last.commit.inventory.InventoryItem
class Collectible(
- name: String,
- val pos: Position,
- width: Float,
- height: Float
+ name: String,
+ val pos: Position,
+ width: Float,
+ height: Float,
+ val requiredItem: String
) : Interactable {
val name: String
@@ -26,6 +28,20 @@ class Collectible(
state.inventory.add(this.name)
}
+ override fun canInteract(state: GameState): Boolean {
+ if (requiredItem == "") {
+ return true
+ }
+ val item: InventoryItem? = state.inventory.items.find { it.name == requiredItem }
+
+ if (item == null) {
+ return false
+ }
+
+ return true
+
+ }
+
override fun getCollider(): Rectangle {
return this.collider
}
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 450b094..491fdb0 100644
--- a/core/src/main/kotlin/com/last/commit/map/Door.kt
+++ b/core/src/main/kotlin/com/last/commit/map/Door.kt
@@ -5,9 +5,24 @@ import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell
import com.badlogic.gdx.math.Rectangle
import com.last.commit.Wall
import com.last.commit.audio.GameSoundEffect
+import com.last.commit.inventory.InventoryItem
class Door(gridX: Int, gridY: Int, wallCollider: Rectangle, cell: Cell) :
- Wall(gridX, gridY, wallCollider, cell), Interactable {
+ Wall(gridX, gridY, wallCollider, cell), Interactable {
+
+
+ override fun canInteract(state: GameState): Boolean {
+
+ val requiredItem: String = cell.getTile().getProperties().get("requiredItem", "", String::class.java)
+
+ val item: InventoryItem? = state.inventory.items.find { it.name == requiredItem }
+
+ if (item == null) {
+ return requiredItem == ""
+ } else {
+ return requiredItem == item.name
+ }
+ }
override fun interact(otherCollider: Rectangle, state: GameState) {
println("interacting with door $this")
@@ -46,12 +61,12 @@ class Door(gridX: Int, gridY: Int, wallCollider: Rectangle, cell: Cell) :
override fun toString(): String {
return String.format(
- "Door: %f:%f - %f:%f (isOpen: %b)",
- wallCollider.x,
- wallCollider.y,
- wallCollider.width,
- wallCollider.height,
- isOpen
+ "Door: %f:%f - %f:%f (isOpen: %b)",
+ wallCollider.x,
+ wallCollider.y,
+ wallCollider.width,
+ wallCollider.height,
+ isOpen
)
}
}
diff --git a/core/src/main/kotlin/com/last/commit/map/Interactable.kt b/core/src/main/kotlin/com/last/commit/map/Interactable.kt
index b111726..8e2b494 100644
--- a/core/src/main/kotlin/com/last/commit/map/Interactable.kt
+++ b/core/src/main/kotlin/com/last/commit/map/Interactable.kt
@@ -1,10 +1,12 @@
package com.last.commit.map
-import com.badlogic.gdx.math.Rectangle
import GameState
+import com.badlogic.gdx.math.Rectangle
interface Interactable {
fun getCollider(): Rectangle
fun interact(otherCollider: Rectangle, state: GameState)
+
+ fun canInteract(state: GameState): Boolean
}
\ No newline at end of file
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 8dd9435..5ddfd4f 100644
--- a/core/src/main/kotlin/com/last/commit/map/TimeMap.kt
+++ b/core/src/main/kotlin/com/last/commit/map/TimeMap.kt
@@ -158,10 +158,11 @@ class TimeMap(fileName: String, val state: GameState) {
val height = mapObjectProperties.get("height", Float::class.java)
if (mapObject is RectangleMapObject) {
- val itemName = mapObjectProperties.get("item", String::class.java)
- itemName?. let {
- this.collectibles.add(Collectible(itemName, Position(x, y, gridX, gridY), width, height))
- }
+ //check wether itemName is null and continue in case it is
+ val itemName = mapObjectProperties.get("item", String::class.java) ?: continue
+ val requiredItem = mapObjectProperties.get("requiredItem", String::class.java) ?: ""
+
+ this.collectibles.add(Collectible(itemName, Position(x, y, gridX, gridY), width, height, requiredItem))
} else {
println("Found non-rectangular map object at ${x}-${y} skipping it")
}
@@ -186,13 +187,16 @@ class TimeMap(fileName: String, val state: GameState) {
fun interactWith(x: Float, y: Float, blockingCollider: Rectangle) {
val gridX = x.toInt() / CELL_SIZE
val gridY = y.toInt() / CELL_SIZE
- println("Interacting with element at $gridX:$gridY")
//if no door is found return
val interactable: Interactable = this.findInteractableAtPosition(gridX, gridY) ?: return
//else continue
-
- interactable.interact(blockingCollider, state)
+ if (interactable.canInteract(state)) {
+ println("Interacting with element at $gridX:$gridY")
+ interactable.interact(blockingCollider, state)
+ } else {
+ println("Cannot interact with $gridX:$gridY")
+ }
}