diff --git a/concept/breadwinner/.obsidian/workspace.json b/concept/breadwinner/.obsidian/workspace.json index 9cc5eda..36ac6e3 100644 --- a/concept/breadwinner/.obsidian/workspace.json +++ b/concept/breadwinner/.obsidian/workspace.json @@ -27,12 +27,12 @@ "state": { "type": "markdown", "state": { - "file": "game mechanics/Clipboard.md", + "file": "game mechanics/The upgrain shop.md", "mode": "source", "source": false }, "icon": "lucide-file", - "title": "Clipboard" + "title": "The upgrain shop" } } ], @@ -211,6 +211,12 @@ }, "active": "cc30646b046d3148", "lastOpenFiles": [ + "game mechanics/The safe zone computer.md", + "game mechanics/The upgrain shop.md", + "thing groups/Player.md", + "game mechanics/Run.md", + "game mechanics/XP earning.md", + "game mechanics/Clipboard.md", "game mechanics/Day cycle.md", "game mechanics/Smartwatch.md", "game mechanics/THE NARRATOR.md", @@ -225,10 +231,7 @@ "TLDR/MVP.md", "TLDR", "concepts and lore/Lore.md", - "thing groups/Player.md", - "game mechanics/Clipboard.md", "game mechanics/The pawn shop.md", - "game mechanics/The safe zone computer.md", "game mechanics/The safe zone.md", "game mechanics/The PSA system.md", "thing groups/Equippable.md", @@ -237,7 +240,6 @@ "thing groups/Entity.md", "Pasted image 20260728145533.png", "game mechanics", - "concepts and lore/Multiplayer (bredren).md", "thing groups", "concepts and lore", "entities" diff --git a/concept/breadwinner/game mechanics/Run.md b/concept/breadwinner/game mechanics/Run.md new file mode 100644 index 0000000..27a5a2b --- /dev/null +++ b/concept/breadwinner/game mechanics/Run.md @@ -0,0 +1,8 @@ +Each session is tracked as a run. Of course. + +A run has different statistics after done: +- Total time +- Entity related stats + - How many [[Serbreads]] did you shoo away + - What did you get killed by + - How many times did you die \ No newline at end of file diff --git a/concept/breadwinner/game mechanics/The safe zone computer.md b/concept/breadwinner/game mechanics/The safe zone computer.md index 83a681b..186aa9c 100644 --- a/concept/breadwinner/game mechanics/The safe zone computer.md +++ b/concept/breadwinner/game mechanics/The safe zone computer.md @@ -6,6 +6,7 @@ It is an old CRT monitor placed on top of an old pc case. # The desktop the desktop has 2 major apps: - [[The pawn shop]] +- [[The upgrain shop]] - The quota machine ## the quota machine diff --git a/concept/breadwinner/game mechanics/The upgrain shop.md b/concept/breadwinner/game mechanics/The upgrain shop.md new file mode 100644 index 0000000..adcdaf1 --- /dev/null +++ b/concept/breadwinner/game mechanics/The upgrain shop.md @@ -0,0 +1,23 @@ +The upgrade and usables shop + +this is where you can purchase upgrades and usables with your hard earned cash. + +upgradables: +- charisma + - increases positive bidding chances for the player +- inventory size + - increases inventory size to a max of 5 +- backpack + - lets you have extra inventory, but you can only access it if you slow down + - upgradable size +- exosuit + - increases carrying capability + - increases grabbing ability + - slows down stamina loss + +usables: +- extra life + - brAID +- energy drink + - +- \ No newline at end of file diff --git a/concept/breadwinner/game mechanics/XP earning.md b/concept/breadwinner/game mechanics/XP earning.md new file mode 100644 index 0000000..b253b99 --- /dev/null +++ b/concept/breadwinner/game mechanics/XP earning.md @@ -0,0 +1,18 @@ +You can earn XP from + +- selling a thing instantly + - +10 +- selling a thing through an auction + - $+10 \cdot \frac{\text{sell\_price}}{\text{item\_value}}$ +- putting bread in the bread storage + - +5 +- completing a quota + - $+ 100 \cdot \frac{\text{correct delivery}}{\text{{total delivery}}}$ +- putting bread on a tray + - +5 +- scaring [[Serbreads]] + - +2 +- finishing a day + - $$+1000 \cdot \frac{\Sigma \text{correct delivery}}{\Sigma\text{{total delivery}}}$$ + - nighttime earnings are **doubled** to encourage nighttime exploration +- add extra if you want to \ No newline at end of file diff --git a/concept/breadwinner/thing groups/Player.md b/concept/breadwinner/thing groups/Player.md index c9f2039..09b1b87 100644 --- a/concept/breadwinner/thing groups/Player.md +++ b/concept/breadwinner/thing groups/Player.md @@ -42,3 +42,12 @@ Properties: - influences the audio and what can and cant the player do (cannot run and walk at the same time) - grabbing force - if increased, you can move more bread on a tray or hold and drag heavier objects easier +- experience + - tracks how much XP the player has + - XP can be earned through different meant + - [[XP earning]] +- life + - a player starts with 3 lives + - they lose a life once they get jumped + - they respawn in the safe zone + - lives can be bought as upgrades diff --git a/maps/dev_map.tscn4763014726.tmp b/maps/dev_map.tscn4763014726.tmp new file mode 100644 index 0000000..e6fe9e7 --- /dev/null +++ b/maps/dev_map.tscn4763014726.tmp @@ -0,0 +1,119 @@ +[gd_scene format=3 uid="uid://chykk2a3opu0d"] + +[ext_resource type="PackedScene" uid="uid://kqq30y24c6kd" path="res://scenes/player/player.tscn" id="1_s8b7j"] +[ext_resource type="AudioStream" uid="uid://db0yck6trekrs" path="res://assets/sounds/ambiance/pc-fan-paulstretched.mp3" id="2_phkhq"] +[ext_resource type="Script" uid="uid://y8x4svl5kej2" path="res://addons/spatial_audio_3d/spatial_audio_3d.gd" id="4_yb1w3"] + +[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_g4v7s"] + +[sub_resource type="PlaneMesh" id="PlaneMesh_g4v7s"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_g4v7s"] + +[sub_resource type="BoxMesh" id="BoxMesh_g4v7s"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_yf5fn"] + +[sub_resource type="BoxMesh" id="BoxMesh_yf5fn"] + +[sub_resource type="BoxShape3D" id="BoxShape3D_57qmd"] +size = Vector3(20.447998, 11.038544, 1) + +[node name="DevMap" type="Node3D" unique_id=471389571] + +[node name="Plane" type="StaticBody3D" parent="." unique_id=1943923809] +collision_layer = 17 +collision_mask = 17 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Plane" unique_id=2072732464] +shape = SubResource("WorldBoundaryShape3D_g4v7s") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Plane" unique_id=810695750] +transform = Transform3D(9.905844, 0, 0, 0, 1, 0, 0, 0, 9.900972, 0, 0, 0) +mesh = SubResource("PlaneMesh_g4v7s") + +[node name="TestObject" type="RigidBody3D" parent="." unique_id=1889494210] +transform = Transform3D(0.9224609, 0.38609046, 0, -0.38609046, 0.9224609, 0, 0, 0, 1, 1.1603341, 0.9219521, -1.1464608) +collision_layer = 17 +collision_mask = 17 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="TestObject" unique_id=507616212] +shape = SubResource("BoxShape3D_g4v7s") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="TestObject" unique_id=1356474788] +mesh = SubResource("BoxMesh_g4v7s") + +[node name="TestObjectGrabbable" type="RigidBody3D" parent="." unique_id=162241126 groups=["grabbable"]] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.776662, -3.2358055) +collision_layer = 17 +collision_mask = 17 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="TestObjectGrabbable" unique_id=2049402651] +shape = SubResource("BoxShape3D_yf5fn") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="TestObjectGrabbable" unique_id=1899834557] +mesh = SubResource("BoxMesh_yf5fn") + +[node name="TestObjectEquippable" type="RigidBody3D" parent="." unique_id=1086000939] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.874709, 1.0290127, -3.1515453) +collision_layer = 17 +collision_mask = 17 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="TestObjectEquippable" unique_id=740741417] +shape = SubResource("BoxShape3D_yf5fn") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="TestObjectEquippable" unique_id=1967579265] +mesh = SubResource("BoxMesh_yf5fn") + +[node name="Player" parent="." unique_id=423228143 instance=ExtResource("1_s8b7j")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.77974355, 1.137004) +UI_MOVEMENT_SENSITIVITY = 1.0 + +[node name="OmniLight3D" type="OmniLight3D" parent="." unique_id=1317582521] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.2949467, -3.755646) + +[node name="SpatialAudio3D" type="AudioStreamPlayer3D" parent="." unique_id=351573539] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15.887349, 4.01754, -1.2293816) +stream = ExtResource("2_phkhq") +autoplay = true +max_distance = 1927.53 +script = ExtResource("4_yb1w3") +occlusion_fadetime = 0.0 +bass_proximity = 0 +max_raycast_distance = 30 +roomsize_multiplicator = 2.0 +prox_reduction = 16.0 +debug = true +metadata/_custom_type_script = "uid://y8x4svl5kej2" + +[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=1656249102] +transform = Transform3D(1, 0, -1.7484555e-07, 0, 1, 0, 1.7484555e-07, 0, 1, 10.053528, 0, 9.284716) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" unique_id=1173755237] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.723999, 5.019272, 0) +shape = SubResource("BoxShape3D_57qmd") + +[node name="StaticBody3D2" type="StaticBody3D" parent="." unique_id=23077148] +transform = Transform3D(-4.371138e-08, 0, -1, 0, 1, 0, 1, 0, -4.371138e-08, 10.053528, 0, 8.284716) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D2" unique_id=1774765140] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.723999, 5.019272, 0) +shape = SubResource("BoxShape3D_57qmd") + +[node name="StaticBody3D3" type="StaticBody3D" parent="." unique_id=2124365943] +transform = Transform3D(-1, 0, 8.742278e-08, 0, 1, 0, -8.742278e-08, 0, -1, -8.946472, 0, -10.715284) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D3" unique_id=652377662] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.723999, 5.019272, 0) +shape = SubResource("BoxShape3D_57qmd") + +[node name="StaticBody3D4" type="StaticBody3D" parent="." unique_id=942386107] +transform = Transform3D(1.3113416e-07, 0, 1, 0, 1, 0, -1, 0, 1.3113416e-07, -8.946472, 0, -10.715284) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D4" unique_id=1055230632] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.723999, 5.019272, 0) +shape = SubResource("BoxShape3D_57qmd") + +[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D4" unique_id=967910627] +transform = Transform3D(1, 1.3113416e-07, -1.3113416e-07, -1.3113416e-07, -4.371139e-08, -1, -1.3113416e-07, 1, -4.371137e-08, -9.723998, 10.984082, 10) +shape = SubResource("BoxShape3D_57qmd") diff --git a/scenes/player/player_manager.gd b/scenes/player/player_manager.gd index 937a953..34d7009 100644 --- a/scenes/player/player_manager.gd +++ b/scenes/player/player_manager.gd @@ -55,22 +55,3 @@ class_name PlayerCharacter @onready var input_controller: Node = %InputController @onready var player_state: Node = %PlayerState @onready var player_properties: Node = %PlayerProperties - -func _process(_delta: float) -> void: - if Input.is_action_just_pressed("next_item"): - ui_handler.next_item() - - if Input.is_action_just_pressed("prev_item"): - ui_handler.prev_item() - - if Input.is_action_just_pressed("select_item_1"): - ui_handler.select_item(0) - - if Input.is_action_just_pressed("select_item_2"): - ui_handler.select_item(1) - - if Input.is_action_just_pressed("select_item_3"): - ui_handler.select_item(2) - -func _ready() -> void: - ui_handler.select_item(0) diff --git a/scenes/player/player_properties.gd b/scenes/player/player_properties.gd index 986a2e7..ded6ec1 100644 --- a/scenes/player/player_properties.gd +++ b/scenes/player/player_properties.gd @@ -3,20 +3,64 @@ extends Node @export_category("Inventory") @export var INVENTORY_MAX = 3 ##max number of items that can be in the player's inventory @export var INVENTORY_ITEMS: Array = [] ##the items in the player's inventory +@onready var ui_handler: Node = %UiHandler + + var stamina: float = 100.0 var selected_item: int = 0 var stamina_recharge: bool = true +var inventory: Array[PackedScene] = [] + +signal selected_item_changed + +func next_item(): + if selected_item + 1 > INVENTORY_MAX - 1: + selected_item = 0 + else: + selected_item += 1 + select_item(selected_item) + +func prev_item(): + if selected_item - 1 < 0: + selected_item = INVENTORY_MAX - 1 + else: + selected_item -= 1 + select_item(selected_item) + +func select_item(index:int): + selected_item = index + ui_handler.update_inventory_ui() + emit_signal("selected_item_changed") + +func get_selected_item() -> PackedScene: + return inventory[selected_item] func stamina_recharge_off(): stamina_recharge = false -func select_item(index:int): - selected_item = index +func _on_stamina_reset_timeout() -> void: + stamina_recharge = true + +func _ready() -> void: + select_item(0) func _process(delta: float) -> void: if stamina_recharge: stamina = move_toward(stamina, 100, .5) - -func _on_stamina_reset_timeout() -> void: - stamina_recharge = true + + if Input.is_action_just_pressed("next_item"): + next_item() + + if Input.is_action_just_pressed("prev_item"): + prev_item() + +func _input(event: InputEvent) -> void: + if Input.is_action_just_pressed("select_item_1"): + select_item(0) + + if Input.is_action_just_pressed("select_item_2"): + select_item(1) + + if Input.is_action_just_pressed("select_item_3"): + select_item(2) diff --git a/scenes/player/player_ui.tscn b/scenes/player/player_ui.tscn index b9ce2d3..b414b82 100644 --- a/scenes/player/player_ui.tscn +++ b/scenes/player/player_ui.tscn @@ -13,6 +13,7 @@ offset_transform_enabled = true script = ExtResource("1_32d7b") [node name="StaminaBar" type="ProgressBar" parent="." unique_id=1844702202] +unique_name_in_owner = true layout_mode = 1 anchors_preset = -1 anchor_left = 0.05 @@ -43,6 +44,7 @@ layout_mode = 2 size_flags_horizontal = 3 [node name="InvSlot1" type="ColorRect" parent="InventoryPanels/Inv1" unique_id=497482827] +unique_name_in_owner = true custom_minimum_size = Vector2(60, 60) layout_mode = 2 size_flags_horizontal = 3 @@ -53,6 +55,7 @@ layout_mode = 2 size_flags_horizontal = 3 [node name="InvSlot2" type="ColorRect" parent="InventoryPanels/Inv2" unique_id=340220249] +unique_name_in_owner = true custom_minimum_size = Vector2(60, 60) layout_mode = 2 size_flags_horizontal = 3 @@ -63,6 +66,7 @@ layout_mode = 2 size_flags_horizontal = 3 [node name="InvSlot3" type="ColorRect" parent="InventoryPanels/Inv3" unique_id=398133665] +unique_name_in_owner = true custom_minimum_size = Vector2(60, 60) layout_mode = 2 size_flags_horizontal = 3 diff --git a/scenes/player/player_ui_manager.gd b/scenes/player/player_ui_manager.gd index 44d864e..a87ba2a 100644 --- a/scenes/player/player_ui_manager.gd +++ b/scenes/player/player_ui_manager.gd @@ -1,31 +1,32 @@ extends Control -@onready var stamina_bar = $StaminaBar -@onready var inventory_slots_panels: Array = [$InventoryPanels/Inv1/InvSlot1, $InventoryPanels/Inv2/InvSlot2, $InventoryPanels/Inv3/InvSlot3] +@onready var stamina_bar: ProgressBar = %StaminaBar +@onready var inventory_slots_panels: Array = [%InvSlot1, %InvSlot2, %InvSlot3] var inventory: Array = [null,null,null] - -var stamina: float = 100 -var selected_item: int = 0 - -const SELECTED_COLOR = 0xcfcfcf78 -const UNSELECTED_COLOR = 0x3d3d3d78 - -func set_stamina_bar(value:float): - stamina = value - -func get_selected_item() -> PackedScene: - return inventory[selected_item] - -func select_item(index: int): - inventory_slots_panels[selected_item].color = Color.hex(UNSELECTED_COLOR) - selected_item = index - inventory_slots_panels[index].color = Color.hex(SELECTED_COLOR) - -func put_item(index: int, item: PackedScene): - inventory[index] = item - -func _process(delta: float) -> void: - stamina_bar.value = lerpf(stamina_bar.value, stamina, delta * 5) - -func set_ui_scale(scale:float) -> void: - pass +#var inventory: Array = [null,null,null] +# +#var stamina: float = 100 +#var selected_item: int = 0 +# +#const SELECTED_COLOR = 0xcfcfcf78 +#const UNSELECTED_COLOR = 0x3d3d3d78 +# +#func set_stamina_bar(value:float): + #stamina = value + # +#func get_selected_item() -> PackedScene: + #return inventory[selected_item] + # +#func select_item(index: int): + #inventory_slots_panels[selected_item].color = Color.hex(UNSELECTED_COLOR) + #selected_item = index + #inventory_slots_panels[index].color = Color.hex(SELECTED_COLOR) +# +#func put_item(index: int, item: PackedScene): + #inventory[index] = item +# +#func _process(delta: float) -> void: + #stamina_bar.value = lerpf(stamina_bar.value, stamina, delta * 5) + # +#func set_ui_scale(scale:float) -> void: + #pass diff --git a/scenes/player/procedural_camera_mover_component.gd b/scenes/player/procedural_camera_mover_component.gd index 4a67e11..229d6a7 100644 --- a/scenes/player/procedural_camera_mover_component.gd +++ b/scenes/player/procedural_camera_mover_component.gd @@ -20,22 +20,34 @@ extends Node @onready var ui: Control = %PlayerUi @onready var player_properties: Node = %PlayerProperties @onready var ui_base_position = ui.position +@onready var ui_handler: Node = %UiHandler var t_bob: float = 0.0 var last_bob_y: float = 0.0 +var t_breath: float = 0.0 +var last_breath_y: float = 0.0 var _camera_original_position: Vector3 = Vector3(0,.75,0) var _mouse_motion: Vector2 = Vector2.ZERO var _mouse_motion_delta: Vector2 = Vector2.ZERO var _last_camera_global_position: Vector3 = Vector3.ZERO +var _breathing: bool = true func _ready() -> void: _last_camera_global_position = camera.global_position +func _process(delta: float) -> void: + if player.is_on_floor(): + _breathing = true + else: + _breathing = false + + camera_breathing(delta) + func do(delta): ui.offset_transform_scale *= UI_SCALE ui_movement_handling(delta) - ui.set_stamina_bar(player_properties.stamina) + ui_handler.set_stamina_bar(player_properties.stamina) var horizontal_speed = Vector3(player.velocity.x, player.velocity.y, player.velocity.z).length() var current_sin_pos = sin(t_bob * CAMERA_BOB_FREQUENCY) @@ -50,23 +62,7 @@ func do(delta): last_bob_y = current_sin_pos - camera_bobbing(t_bob) - - #idle breathing - elif player.is_on_floor() and horizontal_speed < 0.05: - t_bob += delta * (100 / (40 + player_properties.stamina)) - - camera_breathing(t_bob) - - - if last_bob_y <= -.60 and current_sin_pos > -.60: - sound_controller.play_breath_sound(true) - - if last_bob_y >= .60 and current_sin_pos < .60: - sound_controller.play_breath_sound(false) - - last_bob_y = current_sin_pos - + camera_bobbing(t_bob) else: camera.rotation.z = lerpf(camera.rotation.z,0, delta * 0.004) @@ -105,5 +101,18 @@ func camera_bobbing(time: float): camera.rotation.z += sin(time * CAMERA_BOB_FREQUENCY * .5) * CAMERA_SIDEWAYS_BOB_AMPLITUDE func camera_breathing(time: float): - camera.transform.origin.y = sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE + .75 - camera.rotation.x += sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_SIDEWAYS_BOB_AMPLITUDE + if _breathing: + t_breath += time * (100 / (40 + player_properties.stamina)) + var current_sin_pos = sin(t_breath * CAMERA_BOB_FREQUENCY) + + if last_breath_y <= -.60 and current_sin_pos > -.60: + sound_controller.play_breath_sound(true) + + if last_breath_y >= .60 and current_sin_pos < .60: + sound_controller.play_breath_sound(false) + + last_breath_y = current_sin_pos + + camera.transform.origin.y = sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_BOB_AMPLITUDE + .75 + camera.rotation.x += sin(time * CAMERA_BOB_FREQUENCY) * CAMERA_SIDEWAYS_BOB_AMPLITUDE + diff --git a/scenes/player/sound_controller_component.gd b/scenes/player/sound_controller_component.gd index e883084..1eb5cae 100644 --- a/scenes/player/sound_controller_component.gd +++ b/scenes/player/sound_controller_component.gd @@ -65,8 +65,10 @@ func _ready() -> void: var is_right_leg := func () -> SpatialAudio3D: if _current_leg_is_right: + _current_leg_is_right = !_current_leg_is_right return right_foot else: + _current_leg_is_right = !_current_leg_is_right return left_foot ##only use for sparse effects @@ -92,16 +94,16 @@ func create_spatial_audio_sphere(pos:Vector3, audio:AudioStream, pitch:float = 1 spatial_audio.queue_free() func play_stream_on_player(player:SpatialAudio3D, audio:AudioStream, pitch: float = randf_range(.8, 1.2)): - player.process_mode = Node.PROCESS_MODE_INHERIT - player.do_set_stream(audio) - player.pitch_scale = pitch - player.do_play() - await get_tree().create_timer(3).timeout - player.process_mode = Node.PROCESS_MODE_DISABLED + if player.finished: + player.process_mode = Node.PROCESS_MODE_INHERIT + player.do_set_stream(audio) + player.pitch_scale = pitch + player.do_play() + await get_tree().create_timer(3).timeout + player.process_mode = Node.PROCESS_MODE_DISABLED func play_breath_sound(breathe_in:bool = true): var play_sound - if breathe_in: play_sound = _current_breath_in_sound while play_sound == _current_breath_in_sound: @@ -152,7 +154,7 @@ func play_jump_sound(start:bool = true): var sound_to_play_foot: AudioStream = null var sound_to_play_breath: AudioStream = null - match player.is_on_floor(): + match start: true: while sound_to_play_foot == _current_jump_start_sound: sound_to_play_foot = JUMP_STARTING_SOUNDS.pick_random() @@ -187,4 +189,3 @@ func play_footstep_sound(): _current_footstep_sound = sound_to_play play_stream_on_player(is_right_leg.call(), sound_to_play) - _current_leg_is_right = !_current_leg_is_right diff --git a/scenes/player/ui_handler_component.gd b/scenes/player/ui_handler_component.gd index e48f8e0..476f221 100644 --- a/scenes/player/ui_handler_component.gd +++ b/scenes/player/ui_handler_component.gd @@ -17,6 +17,9 @@ extends Node @onready var cursor: TextureRect = %Cursor @onready var player_camera: Camera3D = %PlayerCamera +const SELECTED_COLOR = 0xcfcfcf78 +const UNSELECTED_COLOR = 0x3d3d3d78 + var grabbable_panel = null var grabbable_panel_body = null @@ -32,7 +35,15 @@ func _on_grabbable_finder_body_exited(body: Node3D) -> void: grabbable_panel = null grabbable_panel_body = null +func update_inventory_ui(): + set_selected_item(player_properties.selected_item) + +func _ready() -> void: + player_properties.selected_item_changed.connect(update_inventory_ui) + update_inventory_ui() + func _process(delta: float) -> void: + ui.stamina_bar.value = lerpf(ui.stamina_bar.value, player_properties.stamina, delta * 5) if grabbable_panel != null: var target_position = cursor.position - player_camera.unproject_position(grabbable_panel_body.global_position) grabbable_panel.position = grabbable_panel.position.lerp(-target_position / 2, delta * 50) @@ -53,20 +64,18 @@ func toggle_menu(): Input.mouse_mode = Input.MOUSE_MODE_CAPTURED player_state.in_menu = false -func next_item(): - if player_properties.selected_item + 1 > player_properties.INVENTORY_MAX - 1: - player_properties.selected_item = 0 - else: - player_properties.selected_item += 1 - ui.select_item(player_properties.selected_item) +func set_stamina_bar(value:float): + ui.stamina_bar.value = value + +func set_selected_item(index: int): + for i in len(ui.inventory_slots_panels): + if i == player_properties.selected_item: + ui.inventory_slots_panels[i].color = Color.hex(SELECTED_COLOR) + else: + ui.inventory_slots_panels[i].color = Color.hex(UNSELECTED_COLOR) -func prev_item(): - if player_properties.selected_item - 1 < 0: - player_properties.selected_item = player_properties.INVENTORY_MAX - 1 - else: - player_properties.selected_item -= 1 - ui.select_item(player_properties.selected_item) - -func select_item(index: int): - player_properties.select_item(index) - ui.select_item(index) +func put_item(index: int, item: PackedScene): + player_properties.inventory[index] = item + +func set_ui_scale(scale:float) -> void: + pass