Merge remote-tracking branch 'origin/main'

main
trivernis 1 year ago
commit 5113f58ab5
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.9" tiledversion="1.9.1" orientation="orthogonal" renderorder="right-down" width="64" height="64" tilewidth="64" tileheight="64" infinite="0" nextlayerid="13" nextobjectid="7">
<map version="1.9" tiledversion="1.9.1" orientation="orthogonal" renderorder="right-down" width="64" height="64" tilewidth="64" tileheight="64" infinite="0" nextlayerid="13" nextobjectid="9">
<properties>
<property name="description" value="01.10.2001"/>
<property name="id" type="int" value="1"/>
@ -504,6 +504,16 @@
<property name="item" value="key"/>
</properties>
</object>
<object id="7" x="1600" y="2304" width="64" height="64">
<properties>
<property name="item" value="compass"/>
</properties>
</object>
<object id="8" x="1664" y="2368" width="64" height="64">
<properties>
<property name="item" value="compass"/>
</properties>
</object>
</objectgroup>
<objectgroup id="8" name="Spawnpoints">
<object id="1" x="2081" y="2330">

@ -22,10 +22,6 @@ class Player(private val textureRegion: TextureRegion, private val gameState: Ga
position = Vector2()
}
fun addItemToInventory(name: String) {
gameState.inventory.add(name)
}
fun getX(): Float {
return position.x
}

@ -1,21 +1,33 @@
package com.last.commit.inventory
class Inventory {
import com.last.commit.GameState
class Inventory() {
val items: MutableList<InventoryItem> = ArrayList()
public var updated = false
/**
* @param name the name of the subtexture loaded from xml
* @return wether the item was added
*/
fun add(name: String) {
if (this.items.size < 8) {
items.add(InventoryItem(name))
this.updated = true
fun add(name: String, state: GameState): Boolean {
if (this.items.find { it.name == name } == null) {
if (this.items.size < 8) {
items.add(InventoryItem(name))
this.updated = true
return true
}
} else {
// Item is already in inventory
state.dialogStage.setTexts("You already have this item.")
state.dialogStage.show()
}
return false
}
fun remove(name: String) {
items.removeIf() {item -> item.name == name}
items.removeIf() { item -> item.name == name }
}
}

@ -24,8 +24,9 @@ class Collectible(
override fun interact(otherCollider: Rectangle, state: GameState) {
println("Interacting with item $name")
state.soundEngine.play(GameSoundEffect.GRAB)
state.inventory.add(this.name)
state.map?.collectibles?.remove(this)
if (state.inventory.add(this.name, state)) {
state.map?.collectibles?.remove(this)
}
}
override fun canInteract(state: GameState): Boolean {

@ -63,7 +63,6 @@ class FirstScreen(private val parent: Game) : TimeTravelScreen() {
uiStage = UIStage("sprites/genericItems_spritesheet_colored", gameState)
shapeRenderer.setAutoShapeType(true)
player.addItemToInventory("drill")
gameState.soundEngine.play(GameMusic.WORLD_MUSIC, 0.25f)
viewport.camera = camera

@ -77,6 +77,10 @@ class DialogStage(skin: Skin?) : Stage(ExtendViewport(512f, 512f)) {
return true
}
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
return keyDown(Input.Keys.SPACE)
}
private operator fun next() {
area.clear()
area.text = texts.first()

Loading…
Cancel
Save