1
0
Fork 0

Statusbars und TemperatureLayerToggle hinzugefügt

Luca 2025-01-10 20:45:33 +01:00
parent b89131bbaa
commit 93e3a26b24
3 changed files with 199 additions and 165 deletions

View File

@ -5,6 +5,10 @@ extends Node
@onready var player: PlayerManager = $PlayerManager
@onready var camera: CameraController = $Camera2D as CameraController
@onready var game_ticker: Timer = $GameTick
@onready var health_bar: ProgressBar = $Camera2D/CanvasLayer/VBoxContainer/HealthBar
@onready var food_bar: ProgressBar = $Camera2D/CanvasLayer/VBoxContainer/FoodBar
@onready var temperature_bar: ProgressBar = $Camera2D/CanvasLayer/VBoxContainer/TemperatureBar
@onready var temperature_layer: Node2D = $Tileset/TemperatureLayer
var tilemap_navigation: TilemapNavigation = TilemapNavigation.new()
@ -16,6 +20,10 @@ func _ready() -> void:
world.camp_manager.game_manager = self
world.step_visualizer.game_manager = self
world.step_visualizer.world = world
health_bar.value = player.max_health
food_bar.value = player.max_food
temperature_bar.value = player.temperature_endure
update_bars()
# game_ticker.start()
@ -32,6 +40,8 @@ func _process(delta: float) -> void:
world.camp_manager.campfire_extinguish()
if Input.is_action_just_pressed("force_game_tick"):
_on_game_tick_timeout()
if Input.is_action_just_pressed("key_6"):
toggle_temperature_layer()
func player_health_depleted():
@ -48,3 +58,25 @@ func _on_game_tick_timeout() -> void:
tilemap_navigation.game_tick_end()
world.step_visualizer.game_tick_end()
timer_on_game_tick_timeout.stop()
update_bars()
func update_bars() -> void:
if health_bar != null:
health_bar.max_value = player.max_health
health_bar.value = clamp(player.health, 0, player.max_health)
if food_bar != null:
food_bar.max_value = player.max_food
food_bar.value = clamp(player.food, 0, player.max_food)
if temperature_bar != null:
var temperature_value = player.temperature_endure - player.temperature_timer
temperature_bar.max_value = player.temperature_endure
temperature_bar.value = clamp(temperature_value, 0, player.temperature_endure)
func toggle_temperature_layer() -> void:
if temperature_layer != null:
temperature_layer.visible = not temperature_layer.visible
print("TemperatureLayer visibility:", temperature_layer.visible)
else:
print("TemperatureLayer is null!")

View File

@ -3,7 +3,9 @@ extends Node
@onready var inventory_label: Label = %InventoryLabel
@export var max_health: int = 100
# food system
@export var max_food: int = 100
@export var food_damage: int = 1
@export var food_addon_per_berry: int = 100
@export var food_critical_threshold: int = 50
@ -26,10 +28,10 @@ var board_position: Vector2i = Vector2i(0, 0):
@onready var behavior_tree: BehaviorTree = $BehaviorTree
var food: int = 0
var food: int = max_food
# var water: int = 0
var temperature_timer: int = 0
var health: int = 0
var health: int = max_health
#
var inventory_slot: Vector2i = tilemap_types.EMPTY:

View File

@ -10,7 +10,7 @@ func run(blackboard: Dictionary) -> void:
return
player.inventory_slot = tilemap_types.EMPTY
player.food += player.food_addon_per_berry
player.food = player.max_food
status = SUCCESS
status_reason = "Ate berry, player now has " + str(player.food) + " food"