forked from 2121578/gai-ca2
values werden jetzt in den StatusBars angezeigt und aktualisiert
parent
162812b9c7
commit
fe7db59dd8
|
|
@ -45,19 +45,21 @@ text = "INV"
|
|||
|
||||
[node name="HealthBar" type="ProgressBar" parent="Camera2D/CanvasLayer/VBoxContainer"]
|
||||
modulate = Color(0.787561, 0.0888135, 0.00437393, 1)
|
||||
custom_minimum_size = Vector2(150, 15)
|
||||
custom_minimum_size = Vector2(150, 20)
|
||||
layout_mode = 2
|
||||
tooltip_text = "
|
||||
"
|
||||
show_percentage = false
|
||||
|
||||
[node name="FoodBar" type="ProgressBar" parent="Camera2D/CanvasLayer/VBoxContainer"]
|
||||
modulate = Color(0.166826, 0.552224, 0.153144, 1)
|
||||
custom_minimum_size = Vector2(0, 15)
|
||||
custom_minimum_size = Vector2(0, 20)
|
||||
layout_mode = 2
|
||||
show_percentage = false
|
||||
|
||||
[node name="TemperatureBar" type="ProgressBar" parent="Camera2D/CanvasLayer/VBoxContainer"]
|
||||
modulate = Color(0.0235294, 0.0392157, 1, 1)
|
||||
custom_minimum_size = Vector2(0, 15)
|
||||
custom_minimum_size = Vector2(0, 20)
|
||||
layout_mode = 2
|
||||
max_value = 50.0
|
||||
show_percentage = false
|
||||
|
|
@ -67,6 +69,22 @@ layout_mode = 2
|
|||
expand_mode = 5
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="HealthLabel" type="Label" parent="Camera2D/CanvasLayer"]
|
||||
offset_left = 1.0
|
||||
offset_top = 26.0
|
||||
offset_right = 151.0
|
||||
offset_bottom = 49.0
|
||||
|
||||
[node name="FoodLabel" type="Label" parent="Camera2D/CanvasLayer"]
|
||||
offset_top = 50.0
|
||||
offset_right = 150.0
|
||||
offset_bottom = 73.0
|
||||
|
||||
[node name="TemperatureLabel" type="Label" parent="Camera2D/CanvasLayer"]
|
||||
offset_top = 74.0
|
||||
offset_right = 150.0
|
||||
offset_bottom = 97.0
|
||||
|
||||
[node name="Tileset" type="Node2D" parent="."]
|
||||
script = ExtResource("1_k0rw8")
|
||||
|
||||
|
|
|
|||
|
|
@ -16,72 +16,73 @@ var tilemap_navigation: TilemapNavigation = TilemapNavigation.new()
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
tilemap_navigation.world = world
|
||||
tilemap_navigation.player = player
|
||||
player.game_manager = self
|
||||
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()
|
||||
$Camera2D/CanvasLayer/VBoxContainer/TextureRect.texture = world.tilemap_interactive.get_cell_texture(tilemap_types.OBJECT_I_BOAT_PART_CHEST)
|
||||
tilemap_navigation.world = world
|
||||
tilemap_navigation.player = player
|
||||
player.game_manager = self
|
||||
world.camp_manager.game_manager = self
|
||||
world.step_visualizer.game_manager = self
|
||||
world.step_visualizer.world = world
|
||||
update_bars()
|
||||
$Camera2D/CanvasLayer/VBoxContainer/TextureRect.texture = world.tilemap_interactive.get_cell_texture(tilemap_types.OBJECT_I_BOAT_PART_CHEST)
|
||||
|
||||
|
||||
# game_ticker.start()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if Input.is_action_just_pressed("key_1"):
|
||||
camera.go_to_zooming(Vector2(517.469787597656, 289.846008300781), 1.771561)
|
||||
if Input.is_action_just_pressed("key_2"):
|
||||
camera.go_to_zooming(Vector2(789.883972167969, 450.102813720703), 0.56015348434448)
|
||||
if Input.is_action_just_pressed("key_9"):
|
||||
world.camp_manager.campfire_light()
|
||||
world.camp_manager.sleep_effect()
|
||||
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()
|
||||
if Input.is_action_just_pressed("key_1"):
|
||||
camera.go_to_zooming(Vector2(517.469787597656, 289.846008300781), 1.771561)
|
||||
if Input.is_action_just_pressed("key_2"):
|
||||
camera.go_to_zooming(Vector2(789.883972167969, 450.102813720703), 0.56015348434448)
|
||||
if Input.is_action_just_pressed("key_9"):
|
||||
world.camp_manager.campfire_light()
|
||||
world.camp_manager.sleep_effect()
|
||||
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():
|
||||
# TODO
|
||||
pass
|
||||
# TODO
|
||||
pass
|
||||
|
||||
|
||||
func _on_game_tick_timeout() -> void:
|
||||
var timer_on_game_tick_timeout: PerformanceTimer = PerformanceTimer.new()
|
||||
timer_on_game_tick_timeout.display_name = "game tick duration"
|
||||
tilemap_navigation.game_tick_start()
|
||||
world.step_visualizer.game_tick_start()
|
||||
player.game_tick()
|
||||
tilemap_navigation.game_tick_end()
|
||||
world.step_visualizer.game_tick_end()
|
||||
timer_on_game_tick_timeout.stop()
|
||||
update_bars()
|
||||
var timer_on_game_tick_timeout: PerformanceTimer = PerformanceTimer.new()
|
||||
timer_on_game_tick_timeout.display_name = "game tick duration"
|
||||
tilemap_navigation.game_tick_start()
|
||||
world.step_visualizer.game_tick_start()
|
||||
player.game_tick()
|
||||
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 health_bar != null:
|
||||
health_bar.max_value = player.max_health
|
||||
health_bar.value = clamp(player.health, 0, player.max_health)
|
||||
$Camera2D/CanvasLayer/HealthLabel.text = str(player.health) + "/" + str(player.max_health)
|
||||
$Camera2D/CanvasLayer/HealthLabel.add_theme_color_override("font_color", Color(1, 1, 1))
|
||||
|
||||
if food_bar != null:
|
||||
food_bar.max_value = player.max_food
|
||||
food_bar.value = clamp(player.food, 0, player.max_food)
|
||||
if food_bar != null:
|
||||
food_bar.max_value = player.max_food
|
||||
food_bar.value = clamp(player.food, 0, player.max_food)
|
||||
$Camera2D/CanvasLayer/FoodLabel.text = str(player.food) + "/" + str(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)
|
||||
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)
|
||||
$Camera2D/CanvasLayer/TemperatureLabel.text = str(player.temperature_endure) + "/" + str(player.max_temperature)
|
||||
|
||||
|
||||
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!")
|
||||
if temperature_layer != null:
|
||||
temperature_layer.visible = not temperature_layer.visible
|
||||
print("TemperatureLayer visibility:", temperature_layer.visible)
|
||||
else:
|
||||
print("TemperatureLayer is null!")
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ extends Node
|
|||
@export var food_addon_per_berry: int = 100
|
||||
@export var food_critical_threshold: int = 50
|
||||
# temperature
|
||||
@export var max_temperature: int = 50
|
||||
@export var temperature: int
|
||||
@export var temperature_damage: int = 1
|
||||
@export var temperature_endure: int = 50
|
||||
# viewing
|
||||
|
|
|
|||
Loading…
Reference in New Issue