Compare commits

...

5 Commits

Author SHA1 Message Date
Yan Wittmann 3b4d8a4d8e Merge pull request 'CampAndInventoryUI' (#8) from CampAndInventoryUI into main
Reviewed-on: #8
2025-01-14 21:37:23 +01:00
Yan Wittmann 3d716ed06d Added "better" implementation for camp UI 2025-01-14 21:37:13 +01:00
Yan Wittmann f3f4cef1bf Added image files back in 2025-01-14 19:30:01 +01:00
Yan Wittmann 263816fa53 Merge branch 'main' into CampAndInventoryUI 2025-01-14 19:26:43 +01:00
Luca 08647a4188 BoatParrtProgress und CampUI hinzugefügt 2025-01-14 19:25:18 +01:00
4 changed files with 146 additions and 25 deletions

File diff suppressed because one or more lines are too long

View File

@ -45,8 +45,6 @@ func defer_ready() -> void:
get_tree().create_tween().tween_method(set_instructions_opacity, 0.0, 1.0, 1.0)
# game_ticker.start()
func _process(delta: float) -> void:
if Input.is_action_just_pressed("force_game_tick"):
Task.print_behavior_tree_evaluation = true
@ -123,6 +121,7 @@ func _on_game_tick_timeout() -> void:
EventsTracker.populate_visual_log(%RecentEventsLog, self)
update_bars()
world.camp_manager.populate_camp_visualization(%BoatProcessUI, %CampItemUI)
handle_result_game_state(player.behavior_tree.blackboard)
if not game_ticker.is_stopped():
@ -174,6 +173,61 @@ func handle_result_game_state(blackboard: Dictionary) -> void:
get_tree().create_tween().tween_method(set_outro_opacity, 0.0, 1.0, 1.0)
func update_boat_progress_old() -> void:
var part_counts: Dictionary = { # @formatter:off
tilemap_types.OBJECT_I_BOAT_PART_ENGINE: 0,
tilemap_types.OBJECT_I_BOAT_PART_FUEL: 0,
tilemap_types.OBJECT_I_BOAT_PART_ANCHOR: 0,
tilemap_types.OBJECT_I_BOAT_PART_CHEST: 0,
tilemap_types.OBJECT_I_BOAT_PART_GEARS: 0,
tilemap_types.OBJECT_I_BOAT_PART_MEDIKIT: 0,
tilemap_types.OBJECT_I_BOAT_PART_PADDLE: 0,
tilemap_types.OBJECT_I_BOAT_PART_GAS_STOVE: 0
} # @formatter:on
for boat_part in world.camp_manager.boat_items:
if part_counts.has(boat_part):
part_counts[boat_part] += 1
for part in part_counts.keys():
var count = part_counts[part]
if count > 0:
if part == tilemap_types.OBJECT_I_BOAT_PART_ENGINE:
%BoatPartEngine.texture = world.tilemap_interactive.get_cell_texture(tilemap_types.OBJECT_I_BOAT_PART_ENGINE)
%BoatPartEngine.visible = true
%EngineCount.text = str(count)
elif part == tilemap_types.OBJECT_I_BOAT_PART_FUEL:
%BoatPartFuel.texture = world.tilemap_interactive.get_cell_texture(tilemap_types.OBJECT_I_BOAT_PART_FUEL)
%BoatPartFuel.visible = true
%FuelCount.text = str(count)
elif part == tilemap_types.OBJECT_I_BOAT_PART_ANCHOR:
%BoatPartAnchor.texture = world.tilemap_interactive.get_cell_texture(tilemap_types.OBJECT_I_BOAT_PART_ANCHOR)
%BoatPartAnchor.visible = true
%AnchorCount.text = str(count)
elif part == tilemap_types.OBJECT_I_BOAT_PART_CHEST:
%BoatPartChest.texture = world.tilemap_interactive.get_cell_texture(tilemap_types.OBJECT_I_BOAT_PART_CHEST)
%BoatPartChest.visible = true
%ChestCount.text = str(count)
elif part == tilemap_types.OBJECT_I_BOAT_PART_GEARS:
%BoatPartGears.texture = world.tilemap_interactive.get_cell_texture(tilemap_types.OBJECT_I_BOAT_PART_GEARS)
%BoatPartGears.visible = true
%GearsCount.text = str(count)
elif part == tilemap_types.OBJECT_I_BOAT_PART_MEDIKIT:
%BoatPartMedikit.texture = world.tilemap_interactive.get_cell_texture(tilemap_types.OBJECT_I_BOAT_PART_MEDIKIT)
%BoatPartMedikit.visible = true
%MedikitCount.text = str(count)
elif part == tilemap_types.OBJECT_I_BOAT_PART_PADDLE:
%BoatPartPaddle.texture = world.tilemap_interactive.get_cell_texture(tilemap_types.OBJECT_I_BOAT_PART_PADDLE)
%BoatPartPaddle.visible = true
%PaddleCount.text = str(count)
elif part == tilemap_types.OBJECT_I_BOAT_PART_GAS_STOVE:
%BoatPartGasStove.texture = world.tilemap_interactive.get_cell_texture(tilemap_types.OBJECT_I_BOAT_PART_GAS_STOVE)
%BoatPartGasStove.visible = true
%StoveCount.text = str(count)
else:
push_error("Unknown boat part: " + str(part))
func update_bars() -> void:
if health_bar != null:
health_bar.max_value = player.max_health

View File

@ -2,19 +2,19 @@ class_name TaskDeliverBoatPart
extends Task
func run(blackboard: Dictionary) -> void:
var world: World = blackboard["world"]
var player: PlayerManager = blackboard["player"]
var world: World = blackboard["world"]
var player: PlayerManager = blackboard["player"]
if tilemap_types.is_part_of_collection(tilemap_types.OBJECT_COLLECTION_BOAT_PARTS, player.inventory_slot):
EventsTracker.track(EventsTracker.Event.CAMP_BOAT_PART_DELIVERED, {"item": player.inventory_slot})
world.camp_manager.boat_items.append(player.inventory_slot)
player.inventory_slot = tilemap_types.EMPTY
if world.camp_manager.boat_items.size() >= world.camp_manager.required_boat_parts:
EventsTracker.track(EventsTracker.Event.CAMP_BOAT_COMPLETE, {"item": tilemap_types.OBJECT_I_BOAT_WITH_ENGINE})
world.tilemap_interactive.set_cell(world.camp_manager.boat_build_location, tilemap_types.OBJECT_I_BOAT_WITH_ENGINE)
status = SUCCESS
status_reason = "Player delivered boat part"
return
if tilemap_types.is_part_of_collection(tilemap_types.OBJECT_COLLECTION_BOAT_PARTS, player.inventory_slot):
EventsTracker.track(EventsTracker.Event.CAMP_BOAT_PART_DELIVERED, {"item": player.inventory_slot})
world.camp_manager.boat_items.append(player.inventory_slot)
player.inventory_slot = tilemap_types.EMPTY
if world.camp_manager.boat_items.size() >= world.camp_manager.required_boat_parts:
EventsTracker.track(EventsTracker.Event.CAMP_BOAT_COMPLETE, {"item": tilemap_types.OBJECT_I_BOAT_WITH_ENGINE})
world.tilemap_interactive.set_cell(world.camp_manager.boat_build_location, tilemap_types.OBJECT_I_BOAT_WITH_ENGINE)
status = SUCCESS
status_reason = "Player delivered boat part"
return
status = FAILURE
status_reason = "Player does not have boat part to deliver"
status = FAILURE
status_reason = "Player does not have boat part to deliver"

View File

@ -16,7 +16,7 @@ var boat_leave_location: Vector2i = tilemap_types.EMPTY
var time_of_day: int = 0
var day_length: int = 1000
@export var required_boat_parts: int = 6
@export var required_boat_parts: int = 8
func setup() -> void:
@ -153,3 +153,32 @@ func sleep_effect() -> void:
print("Sleep effect done")
is_sleep_active = false
time_of_day = 0
func populate_camp_visualization(boat_ui: HBoxContainer, camp_ui: HBoxContainer) -> void:
for child in boat_ui.get_children():
if child.name != "HeightLabel":
boat_ui.remove_child(child)
for boat_part in boat_items:
var texture: TextureRect = create_item_texture(boat_part)
boat_ui.add_child(texture)
for child in camp_ui.get_children():
if child.name != "HeightLabel":
camp_ui.remove_child(child)
for boat_part in camp_items:
var texture: TextureRect = create_item_texture(boat_part)
camp_ui.add_child(texture)
func create_item_texture(item: Vector2i) -> TextureRect:
var item_texture: Texture = game_manager.world.tilemap_interactive.get_cell_texture(item)
if item_texture:
var item_texture_rect: TextureRect = TextureRect.new()
item_texture_rect.texture = item_texture
item_texture_rect.set_expand_mode(TextureRect.EXPAND_FIT_WIDTH)
item_texture_rect.set_stretch_mode(TextureRect.STRETCH_KEEP_ASPECT_CENTERED)
return item_texture_rect
return null