From 28c9b857bdff2b1b2922c3eb229f5ec43ba0504e Mon Sep 17 00:00:00 2001 From: Yan Wittmann Date: Tue, 14 Jan 2025 10:13:35 +0100 Subject: [PATCH] Added outro sequence --- project/main-scenes/island.tscn | 18 +++++++++++++++++- project/scripts/global/GameManager.gd | 12 +++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/project/main-scenes/island.tscn b/project/main-scenes/island.tscn index deece86..8318be5 100644 --- a/project/main-scenes/island.tscn +++ b/project/main-scenes/island.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=47 format=4 uid="uid://b88asko1ugyd2"] +[gd_scene load_steps=48 format=4 uid="uid://b88asko1ugyd2"] [ext_resource type="Script" path="res://scripts/global/GameManager.gd" id="1_eeg2d"] [ext_resource type="Script" path="res://scripts/tilemap/World.gd" id="1_k0rw8"] @@ -12,6 +12,7 @@ [ext_resource type="Script" path="res://scripts/tilemap/StepVisualization.gd" id="5_sr2su"] [ext_resource type="Script" path="res://scripts/player/tree/BehaviorTree.gd" id="6_efs30"] [ext_resource type="Texture2D" uid="uid://cr4e1faypphkg" path="res://assets/images/ingame-instructions.png" id="6_q5cos"] +[ext_resource type="Texture2D" uid="uid://cynull1bsik42" path="res://assets/images/outro.png" id="6_uoa7b"] [ext_resource type="Script" path="res://scripts/player/tree/impl/base/TaskSelector.gd" id="7_1jajd"] [ext_resource type="Script" path="res://scripts/player/tree/impl/testing/WalkUpToMouse.gd" id="8_s6mqc"] [ext_resource type="Script" path="res://scripts/player/tree/impl/base/TaskSequence.gd" id="9_i67mw"] @@ -288,6 +289,21 @@ size_flags_horizontal = 4 size_flags_vertical = 8 texture = ExtResource("6_q5cos") +[node name="OutroImageContainer" type="VBoxContainer" parent="Camera2D/CanvasLayer"] +unique_name_in_owner = true +visible = false +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="OutroImage" type="TextureRect" parent="Camera2D/CanvasLayer/OutroImageContainer"] +layout_mode = 2 +texture = ExtResource("6_uoa7b") +expand_mode = 4 +stretch_mode = 5 + [node name="IntroImage" type="Sprite2D" parent="Camera2D"] visible = false z_index = 1 diff --git a/project/scripts/global/GameManager.gd b/project/scripts/global/GameManager.gd index 95c3701..24347ca 100644 --- a/project/scripts/global/GameManager.gd +++ b/project/scripts/global/GameManager.gd @@ -62,6 +62,10 @@ func _process(delta: float) -> void: game_ticker.start() else: game_ticker.stop() + if Input.is_action_just_pressed("key_1"): + get_tree().reload_current_scene() + if Input.is_action_just_pressed("key_2"): + handle_result_game_state( {"game_state_win": true} ) if intro_image.is_visible(): intro_image.set_scale(calculate_scale(intro_image.texture.get_size())) @@ -73,7 +77,7 @@ func calculate_scale(image_size: Vector2) -> Vector2: return Vector2(scale, scale) -# SECTION: intro +# SECTION: intro / outro func set_intro_opacity(opacity: float) -> void: intro_image.set_modulate(Color(1, 1, 1, opacity)) @@ -84,6 +88,11 @@ func set_instructions_opacity(opacity: float) -> void: %InstructionsRect.show() +func set_outro_opacity(opacity: float) -> void: + %OutroImageContainer.set_modulate(Color(1, 1, 1, opacity)) + %OutroImageContainer.show() + + # SECTION: game tick func player_health_depleted(): @@ -151,6 +160,7 @@ func handle_result_game_state(blackboard: Dictionary) -> void: if blackboard.has("game_state_win"): EventsTracker.track(EventsTracker.Event.GAME_STATE_WIN) game_ticker.stop() + get_tree().create_tween().tween_method(set_outro_opacity, 0.0, 1.0, 1.0) func update_bars() -> void: