diff --git a/.gitignore b/.gitignore index 68b38fd..fe33dc0 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ desktop.ini # Editor *.tmp +.idea/ diff --git a/data/dialogue/viaduct_wren.json b/data/dialogue/viaduct_wren.json new file mode 100644 index 0000000..4f8b72a --- /dev/null +++ b/data/dialogue/viaduct_wren.json @@ -0,0 +1,46 @@ +{ + "id": "viaduct_wren", + "start": "stumble", + "can_abort": false, + "speakers": { + "wren": "Wren", + "player": "Tyrveil" + }, + "nodes": { + "stumble": { + "speaker": "wren", + "text": "Tyrveil—! Die Platte— sie kippt, ich rutsche—! Ich krieg keinen Halt, ich kann nicht—!", + "options": [ + { + "text": "Sieh mich an! Hand her. JETZT. Du fällst heute nicht — beweg dich!", + "blade_heart": -10, + "relationship": { "wren": 1 }, + "story_flag": { "viaduct_wren_rescue": "blade" }, + "next": "saved_blade" + }, + { + "text": "Wren. Atme. Nur der nächste Schritt — ich bin genau hier, ich lasse dich nicht fallen.", + "blade_heart": 10, + "relationship": { "wren": 3 }, + "story_flag": { "viaduct_wren_rescue": "heart" }, + "next": "saved_heart" + } + ] + }, + "saved_blade": { + "speaker": "wren", + "text": "Ja— ja! Hab deine Hand. Ich steh. Ich steh wieder. Tut mir leid, ich wollte nicht—", + "next": "onward" + }, + "saved_heart": { + "speaker": "wren", + "text": "Ein Schritt. Noch einer. ... Ich steh wieder. Du hast nicht mal gezittert. Ich schon. Danke.", + "next": "onward" + }, + "onward": { + "speaker": "wren", + "text": "Geh du vor. Wenn ich deinen Rücken sehe, weiß ich, wohin ich muss.", + "next": null + } + } +} diff --git a/scenes/ui/character_creation.tscn b/scenes/ui/character_creation.tscn new file mode 100644 index 0000000..b374866 --- /dev/null +++ b/scenes/ui/character_creation.tscn @@ -0,0 +1,71 @@ +[gd_scene load_steps=2 format=3] + +[ext_resource type="Script" path="res://scripts/ui/character_creation.gd" id="1_creation"] + +[node name="CharacterCreation" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_creation") + +[node name="Background" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.07, 0.08, 0.1, 1) + +[node name="CenterContainer" type="CenterContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] +layout_mode = 2 +theme_override_constants/separation = 16 + +[node name="TitleLabel" type="Label" parent="CenterContainer/VBoxContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 40 +text = "Wer bist du, Gezeichneter?" +horizontal_alignment = 1 + +[node name="HintLabel" type="Label" parent="CenterContainer/VBoxContainer"] +layout_mode = 2 +theme_override_font_sizes/font_size = 16 +theme_override_colors/font_color = Color(0.7, 0.7, 0.7, 1) +text = "Name eintippen (Tastatur) oder den Vorschlag bestätigen (Controller)." +horizontal_alignment = 1 + +[node name="TitleSpacer" type="Control" parent="CenterContainer/VBoxContainer"] +custom_minimum_size = Vector2(0, 12) +layout_mode = 2 + +[node name="NameEdit" type="LineEdit" parent="CenterContainer/VBoxContainer"] +custom_minimum_size = Vector2(320, 44) +layout_mode = 2 +max_length = 24 +alignment = 1 + +[node name="Buttons" type="HBoxContainer" parent="CenterContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/separation = 12 +alignment = 1 + +[node name="ConfirmButton" type="Button" parent="CenterContainer/VBoxContainer/Buttons"] +custom_minimum_size = Vector2(180, 44) +layout_mode = 2 +text = "Bestätigen" + +[node name="BackButton" type="Button" parent="CenterContainer/VBoxContainer/Buttons"] +custom_minimum_size = Vector2(180, 44) +layout_mode = 2 +text = "Zurück" diff --git a/scenes/viaduct/viaduct.tscn b/scenes/viaduct/viaduct.tscn new file mode 100644 index 0000000..f5b07b0 --- /dev/null +++ b/scenes/viaduct/viaduct.tscn @@ -0,0 +1,284 @@ +[gd_scene load_steps=31 format=3] + +[ext_resource type="Script" path="res://scripts/gameplay/viaduct.gd" id="1_viaduct"] +[ext_resource type="PackedScene" path="res://scenes/player.tscn" id="2_player"] +[ext_resource type="PackedScene" path="res://scenes/ui/debug_overlay.tscn" id="3_debug"] +[ext_resource type="Script" path="res://scripts/gameplay/zone_trigger.gd" id="4_zone"] +[ext_resource type="PackedScene" path="res://scenes/ui/speech_bubble.tscn" id="5_bubble"] + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_sky"] +sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) +ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) + +[sub_resource type="Sky" id="Sky_sky"] +sky_material = SubResource("ProceduralSkyMaterial_sky") + +[sub_resource type="Environment" id="Environment_env"] +background_mode = 2 +sky = SubResource("Sky_sky") +tonemap_mode = 2 + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_stone"] +albedo_color = Color(0.45, 0.44, 0.42, 1) + +[sub_resource type="BoxShape3D" id="BoxShape3D_platform"] +size = Vector3(8, 1, 8) + +[sub_resource type="BoxMesh" id="BoxMesh_platform"] +material = SubResource("StandardMaterial3D_stone") +size = Vector3(8, 1, 8) + +[sub_resource type="BoxShape3D" id="BoxShape3D_walkway"] +size = Vector3(2, 1, 10) + +[sub_resource type="BoxMesh" id="BoxMesh_walkway"] +material = SubResource("StandardMaterial3D_stone") +size = Vector3(2, 1, 10) + +[sub_resource type="BoxShape3D" id="BoxShape3D_connector"] +size = Vector3(2, 1, 3) + +[sub_resource type="BoxMesh" id="BoxMesh_connector"] +material = SubResource("StandardMaterial3D_stone") +size = Vector3(2, 1, 3) + +[sub_resource type="BoxShape3D" id="BoxShape3D_wide"] +size = Vector3(4, 1, 10) + +[sub_resource type="BoxMesh" id="BoxMesh_wide"] +material = SubResource("StandardMaterial3D_stone") +size = Vector3(4, 1, 10) + +[sub_resource type="BoxShape3D" id="BoxShape3D_wall"] +size = Vector3(2, 2, 2) + +[sub_resource type="BoxMesh" id="BoxMesh_wall"] +material = SubResource("StandardMaterial3D_stone") +size = Vector3(2, 2, 2) + +[sub_resource type="BoxShape3D" id="BoxShape3D_rail"] +size = Vector3(0.3, 1, 4) + +[sub_resource type="BoxMesh" id="BoxMesh_rail"] +material = SubResource("StandardMaterial3D_stone") +size = Vector3(0.3, 1, 4) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_wren"] +albedo_color = Color(0.45, 0.72, 0.45, 1) + +[sub_resource type="CapsuleMesh" id="CapsuleMesh_wren"] +material = SubResource("StandardMaterial3D_wren") +radius = 0.4 +height = 1.8 + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_wren"] +radius = 0.4 +height = 1.8 + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_trigger"] +transparency = 1 +albedo_color = Color(0.3, 0.8, 1, 0.35) + +[sub_resource type="BoxShape3D" id="BoxShape3D_trigger"] +size = Vector3(2, 2, 2) + +[sub_resource type="BoxMesh" id="BoxMesh_trigger"] +material = SubResource("StandardMaterial3D_trigger") +size = Vector3(2, 2, 2) + +[sub_resource type="BoxShape3D" id="BoxShape3D_killzone"] +size = Vector3(60, 6, 80) + +[sub_resource type="BoxShape3D" id="BoxShape3D_checkpoint"] +size = Vector3(3, 2, 2) + +[sub_resource type="BoxShape3D" id="BoxShape3D_wren_trigger"] +size = Vector3(4, 3, 3) + +[node name="Viaduct" type="Node3D"] +script = ExtResource("1_viaduct") + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_env") + +[node name="Sun" type="DirectionalLight3D" parent="."] +transform = Transform3D(0.866025, 0.383022, -0.321394, 0, 0.642788, 0.766044, 0.5, -0.663414, 0.55667, 0, 12, 0) +shadow_enabled = true + +[node name="StartPlatform" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="StartPlatform"] +shape = SubResource("BoxShape3D_platform") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="StartPlatform"] +mesh = SubResource("BoxMesh_platform") + +[node name="Walk1a" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, -9) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walk1a"] +shape = SubResource("BoxShape3D_walkway") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walk1a"] +mesh = SubResource("BoxMesh_walkway") + +[node name="Walk1b" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, -20.5) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walk1b"] +shape = SubResource("BoxShape3D_walkway") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walk1b"] +mesh = SubResource("BoxMesh_walkway") + +[node name="RailWest" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.15, 0.5, -7) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="RailWest"] +shape = SubResource("BoxShape3D_rail") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="RailWest"] +mesh = SubResource("BoxMesh_rail") + +[node name="RailEast" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.15, 0.5, -11) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="RailEast"] +shape = SubResource("BoxShape3D_rail") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="RailEast"] +mesh = SubResource("BoxMesh_rail") + +[node name="ClimbWall" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -26.5) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="ClimbWall"] +shape = SubResource("BoxShape3D_wall") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="ClimbWall"] +mesh = SubResource("BoxMesh_wall") + +[node name="Walk2" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, -32.5) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walk2"] +shape = SubResource("BoxShape3D_walkway") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walk2"] +mesh = SubResource("BoxMesh_walkway") + +[node name="WidePlatform" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, -41.5) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="WidePlatform"] +shape = SubResource("BoxShape3D_wide") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="WidePlatform"] +mesh = SubResource("BoxMesh_wide") + +[node name="Connector" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, -47.5) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Connector"] +shape = SubResource("BoxShape3D_connector") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Connector"] +mesh = SubResource("BoxMesh_connector") + +[node name="EndPlatform" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, -52.5) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="EndPlatform"] +shape = SubResource("BoxShape3D_platform") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="EndPlatform"] +mesh = SubResource("BoxMesh_platform") + +[node name="Wren" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.9, 0, -42) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Wren"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0) +shape = SubResource("CapsuleShape3D_wren") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Wren"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0) +mesh = SubResource("CapsuleMesh_wren") + +[node name="NameLabel" type="Label3D" parent="Wren"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.2, 0) +billboard = 1 +text = "Wren" +font_size = 64 +outline_size = 16 + +[node name="SpeechBubble" parent="Wren" instance=ExtResource("5_bubble")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.8, 0) + +[node name="Checkpoints" type="Node3D" parent="."] + +[node name="Checkpoint1" type="Area3D" parent="Checkpoints"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -5) +collision_layer = 0 +collision_mask = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Checkpoints/Checkpoint1"] +shape = SubResource("BoxShape3D_checkpoint") + +[node name="Checkpoint2" type="Area3D" parent="Checkpoints"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -24) +collision_layer = 0 +collision_mask = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Checkpoints/Checkpoint2"] +shape = SubResource("BoxShape3D_checkpoint") + +[node name="Checkpoint3" type="Area3D" parent="Checkpoints"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -37) +collision_layer = 0 +collision_mask = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Checkpoints/Checkpoint3"] +shape = SubResource("BoxShape3D_checkpoint") + +[node name="WrenTrigger" type="Area3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, -40) +collision_layer = 0 +collision_mask = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="WrenTrigger"] +shape = SubResource("BoxShape3D_wren_trigger") + +[node name="KillZone" type="Area3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -10, -26) +collision_layer = 0 +collision_mask = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="KillZone"] +shape = SubResource("BoxShape3D_killzone") + +[node name="EndTrigger" type="Area3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -53.5) +collision_layer = 0 +collision_mask = 2 +script = ExtResource("4_zone") +target_scene_path = "res://scenes/hub/rider_quadrant.tscn" + +[node name="CollisionShape3D" type="CollisionShape3D" parent="EndTrigger"] +shape = SubResource("BoxShape3D_trigger") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="EndTrigger"] +mesh = SubResource("BoxMesh_trigger") + +[node name="Label3D" type="Label3D" parent="EndTrigger"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) +billboard = 1 +text = "Zum Reiterquadrant" +font_size = 40 +outline_size = 12 + +[node name="Player" parent="." instance=ExtResource("2_player")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 2) + +[node name="DebugOverlay" parent="." instance=ExtResource("3_debug")] diff --git a/scripts/autoloads/dialogue_system.gd b/scripts/autoloads/dialogue_system.gd index 8a31d44..b159e5c 100644 --- a/scripts/autoloads/dialogue_system.gd +++ b/scripts/autoloads/dialogue_system.gd @@ -16,7 +16,12 @@ extends Node ## Dialog ab; Tyrveil sagt dem Gegenüber dabei eine zufällig gewählte ## Zeile aus dem abort_lines-Array der Dialog-Datei an (Fallback: ## abort_line bzw. Standard) — so klingt der Abschied pro Charakter -## unterschiedlich. Abgebrochene Dialoge gelten nur dann als geführt, wenn in diesem +## unterschiedlich. Dialoge mit "can_abort": false (z. B. der +## Wren-Moment am Viadukt) sind nicht abbrechbar: Der Spieler muss eine +## Option wählen, bevor die Szene fortschreitet. Options-Tag story_flag +## (Flag-Name -> Wert) schreibt Story-Flags in den GameState (z. B. WIE +## Wren gerettet wurde). Der Anzeigename des Spielers in der Box kommt +## aus GameState.player_name (Charakter-Anlage). Abgebrochene Dialoge gelten nur dann als geführt, wenn in diesem ## Durchlauf bereits Options-Effekte angewendet wurden — so bleibt der ## Erst-Durchlauf-Effekt erhalten, ohne dass Abbrechen zum Werte-Farming ## taugt. dialogue_started/dialogue_finished erlauben es, Spielerbewegung @@ -31,6 +36,7 @@ const FALLBACK_LINE_SECONDS := 2.5 const DEFAULT_ABORT_LINE := "Nicht jetzt. Wir reden später weiter." var is_dialogue_active := false +var is_abort_allowed := true var _speakers: Dictionary = {} var _speaker_names: Dictionary = {} @@ -60,6 +66,7 @@ func start_dialogue(dialogue_path: String, speakers: Dictionary) -> void: _abort_lines = data.get("abort_lines", []) if _abort_lines.is_empty(): _abort_lines = [str(data.get("abort_line", DEFAULT_ABORT_LINE))] + is_abort_allowed = bool(data.get("can_abort", true)) is_dialogue_active = true dialogue_started.emit(dialogue_id) _run_dialogue(data) @@ -68,7 +75,7 @@ func start_dialogue(dialogue_path: String, speakers: Dictionary) -> void: ## Merkt einen Abbruch-Wunsch (cancel) während laufender Dialog-Zeilen ## vor; offene Antwortauswahlen behandelt die Dialog-Box selbst. func _unhandled_input(event: InputEvent) -> void: - if not is_dialogue_active: + if not is_dialogue_active or not is_abort_allowed: return if _box != null and _box.has_open_options(): return @@ -188,6 +195,10 @@ func _apply_option_effects(option: Dictionary) -> void: for npc_id in relationship_shifts: RelationshipSystem.adjust_relationship(str(npc_id), int(relationship_shifts[npc_id])) _has_applied_effects = true + var flag_changes: Dictionary = option.get("story_flag", {}) + for flag_name in flag_changes: + GameState.set_story_flag(str(flag_name), flag_changes[flag_name]) + _has_applied_effects = true ## Spielt eine zufällig gewählte Abbruch-Zeile Tyrveils, damit der @@ -229,9 +240,12 @@ func _bubble_for(speaker_id: String) -> Node: return bubble -## Liefert den Anzeigenamen eines Sprechers aus der speakers-Map der -## Dialog-Datei, sonst die großgeschriebene Sprecher-ID. +## Liefert den Anzeigenamen eines Sprechers: für den Spieler den in der +## Charakter-Anlage gewählten Namen, sonst den Eintrag aus der +## speakers-Map der Dialog-Datei bzw. die großgeschriebene Sprecher-ID. func _display_name(speaker_id: String) -> String: + if speaker_id == PLAYER_SPEAKER_ID: + return GameState.player_name return str(_speaker_names.get(speaker_id, speaker_id.capitalize())) diff --git a/scripts/autoloads/game_state.gd b/scripts/autoloads/game_state.gd index ac1a4a0..51da3c9 100644 --- a/scripts/autoloads/game_state.gd +++ b/scripts/autoloads/game_state.gd @@ -23,7 +23,9 @@ const HUMANITY_MAX := 100 const DEFAULT_STRENGTH := 35 const DEFAULT_AGILITY := 35 const DEFAULT_INTELLECT := 15 +const DEFAULT_PLAYER_NAME := "Tyrveil" +var player_name := DEFAULT_PLAYER_NAME var strength := DEFAULT_STRENGTH var agility := DEFAULT_AGILITY var intellect := DEFAULT_INTELLECT @@ -31,11 +33,13 @@ var blade_heart_tone := 0 var humanity := 0 var relationships: Dictionary = {} var completed_dialogues: Dictionary = {} +var story_flags: Dictionary = {} var is_permadeath_enabled := true ## Setzt alle Werte auf die Startwerte eines neuen Spiels zurück. func reset() -> void: + player_name = DEFAULT_PLAYER_NAME strength = DEFAULT_STRENGTH agility = DEFAULT_AGILITY intellect = DEFAULT_INTELLECT @@ -43,6 +47,7 @@ func reset() -> void: humanity = 0 relationships.clear() completed_dialogues.clear() + story_flags.clear() is_permadeath_enabled = true blade_heart_tone_changed.emit(blade_heart_tone) @@ -110,9 +115,22 @@ func has_completed_dialogue(dialogue_id: String) -> bool: return completed_dialogues.get(dialogue_id, false) +## Setzt ein Story-Flag (z. B. wie Wren am Viadukt gerettet wurde) — +## gleiches gespeichertes Muster wie completed_dialogues, damit spätere +## Phasen darauf reagieren können. +func set_story_flag(flag_name: String, value: Variant) -> void: + story_flags[flag_name] = value + + +## Liest ein Story-Flag, default wenn es nicht gesetzt ist. +func get_story_flag(flag_name: String, default: Variant = null) -> Variant: + return story_flags.get(flag_name, default) + + ## Serialisiert den kompletten Zustand als Dictionary für das SaveSystem. func to_save_dict() -> Dictionary: return { + "player_name": player_name, "strength": strength, "agility": agility, "intellect": intellect, @@ -120,6 +138,7 @@ func to_save_dict() -> Dictionary: "humanity": humanity, "relationships": relationships.duplicate(), "completed_dialogues": completed_dialogues.duplicate(), + "story_flags": story_flags.duplicate(), "is_permadeath_enabled": is_permadeath_enabled, } @@ -129,6 +148,9 @@ func to_save_dict() -> Dictionary: ## normalisiert und alle Werte geklemmt; Änderungs-Signale werden nach dem ## Laden ausgelöst. func apply_save_dict(data: Dictionary) -> void: + player_name = str(data.get("player_name", DEFAULT_PLAYER_NAME)) + if player_name.strip_edges().is_empty(): + player_name = DEFAULT_PLAYER_NAME strength = clampi(int(data.get("strength", DEFAULT_STRENGTH)), STAT_MIN, STAT_MAX) agility = clampi(int(data.get("agility", DEFAULT_AGILITY)), STAT_MIN, STAT_MAX) intellect = clampi(int(data.get("intellect", DEFAULT_INTELLECT)), STAT_MIN, STAT_MAX) @@ -143,6 +165,10 @@ func apply_save_dict(data: Dictionary) -> void: var saved_dialogues: Dictionary = data.get("completed_dialogues", {}) for dialogue_id in saved_dialogues: completed_dialogues[String(dialogue_id)] = bool(saved_dialogues[dialogue_id]) + story_flags.clear() + var saved_flags: Dictionary = data.get("story_flags", {}) + for flag_name in saved_flags: + story_flags[String(flag_name)] = saved_flags[flag_name] blade_heart_tone_changed.emit(blade_heart_tone) for npc_id in relationships: relationship_changed.emit(npc_id, relationships[npc_id]) diff --git a/scripts/gameplay/player.gd b/scripts/gameplay/player.gd index 54bf057..faa2f1b 100644 --- a/scripts/gameplay/player.gd +++ b/scripts/gameplay/player.gd @@ -46,9 +46,15 @@ const CLIMB_LANDING_INSET := 0.35 const CLIMB_HEADROOM := 1.7 const CLIMB_DURATION := 0.4 const CLIMB_VERTICAL_PHASE := 0.6 +const PAN_START_YAW := 2.4 +const PAN_START_PITCH := -0.55 +const PAN_START_ZOOM := 14.0 +const PAN_END_PITCH := -0.35 +const PAN_DURATION := 3.0 var _state := MovementState.NORMAL var _is_dialogue_locked := false +var _is_panning := false var _target_zoom := 9.0 var _gravity: float = ProjectSettings.get_setting("physics/3d/default_gravity") var _slide_direction := Vector3.ZERO @@ -115,13 +121,36 @@ func _physics_process(delta: float) -> void: ## Hält den Spieler während eines Dialogs an: Schwerkraft und Auslaufen ## bleiben aktiv, Eingaben für Bewegung, Sprung, Slide und Look nicht. +## Während eines Kamera-Schwenks steuert der Tween die SpringArm-Länge, +## nicht die Zoom-Glättung. func _process_dialogue_lock(delta: float) -> void: if not is_on_floor(): velocity.y -= _gravity * delta velocity.x = move_toward(velocity.x, 0.0, STOP_SPEED * delta) velocity.z = move_toward(velocity.z, 0.0, STOP_SPEED * delta) move_and_slide() - _apply_zoom_smoothing(delta) + if not _is_panning: + _apply_zoom_smoothing(delta) + + +## Spielt einen kurzen cineastischen Kamera-Schwenk für Set-Pieces +## (SPEC Abschnitt 2): Die Kamera startet weit draußen und seitlich und +## fährt weich in die Standard-Third-Person-Ansicht zurück; die Steuerung +## ist für die Dauer gesperrt. +func play_camera_pan(duration := PAN_DURATION) -> void: + _is_dialogue_locked = true + _is_panning = true + _camera_pivot.rotation.y = PAN_START_YAW + _spring_arm.rotation.x = PAN_START_PITCH + _spring_arm.spring_length = PAN_START_ZOOM + _target_zoom = 9.0 + var tween := create_tween().set_parallel(true).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT) + tween.tween_property(_camera_pivot, "rotation:y", 0.0, duration) + tween.tween_property(_spring_arm, "rotation:x", PAN_END_PITCH, duration) + tween.tween_property(_spring_arm, "spring_length", _target_zoom, duration) + await tween.finished + _is_panning = false + _is_dialogue_locked = false ## Sperrt Bewegung und Look bei Dialogbeginn; ein laufender Slide endet diff --git a/scripts/gameplay/viaduct.gd b/scripts/gameplay/viaduct.gd new file mode 100644 index 0000000..101e08f --- /dev/null +++ b/scripts/gameplay/viaduct.gd @@ -0,0 +1,67 @@ +extends Node3D +## Ablauf-Steuerung des Viadukt-Set-Pieces (Phase 3, STORY.md Prolog). +## +## Spielt beim Betreten den cineastischen Kamera-Schwenk (SPEC Abschnitt +## 2), verwaltet die Checkpoints der Segmente und die KillZone unter dem +## Steg: Bei Permadeath AN führt ein Sturz zum Game Over (zurück ins +## Hauptmenü), bei Permadeath AUS zum Respawn am zuletzt erreichten +## Segment-Anfang. Der Wren-Moment (Segment 3) startet einmalig beim +## Betreten des Trigger-Bereichs als nicht abbrechbarer Dialog +## (viaduct_wren.json) — beide Optionen retten Wren, die Wahl landet als +## Story-Flag im GameState. Der Übergang am Ende ist ein Platzhalter +## Richtung Reiterquadrant; Ankunft und Squad-Logik folgen später. + +const MAIN_MENU_SCENE := "res://scenes/ui/main_menu.tscn" +const WREN_DIALOGUE_PATH := "res://data/dialogue/viaduct_wren.json" + +var _checkpoint_position := Vector3.ZERO +var _has_wren_triggered := false + +@onready var _wren: Node3D = $Wren + + +## Merkt den Startpunkt als ersten Checkpoint, verbindet Checkpoints, +## KillZone und Wren-Trigger und spielt den Kamera-Schwenk. +func _ready() -> void: + var player := get_tree().get_first_node_in_group("player") + if player != null: + _checkpoint_position = player.global_position + player.play_camera_pan() + for checkpoint in $Checkpoints.get_children(): + checkpoint.body_entered.connect(_on_checkpoint_entered.bind(checkpoint)) + $KillZone.body_entered.connect(_on_kill_zone_entered) + $WrenTrigger.body_entered.connect(_on_wren_trigger_entered) + + +## Setzt den Respawn-Punkt auf den erreichten Segment-Anfang. +func _on_checkpoint_entered(body: Node3D, checkpoint: Area3D) -> void: + if not body.is_in_group("player"): + return + _checkpoint_position = Vector3(checkpoint.global_position.x, 0.1, checkpoint.global_position.z) + + +## Sturz in den Abgrund: Game Over bei Permadeath AN, sonst Respawn am +## letzten Checkpoint. +func _on_kill_zone_entered(body: Node3D) -> void: + if not body.is_in_group("player"): + return + if GameState.is_permadeath_enabled: + print("Game Over — das Viadukt fordert seinen Preis.") + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + get_tree().change_scene_to_file.call_deferred(MAIN_MENU_SCENE) + return + body.velocity = Vector3.ZERO + body.global_position = _checkpoint_position + + +## Startet den Wren-Moment einmalig als nicht abbrechbaren Dialog. +func _on_wren_trigger_entered(body: Node3D) -> void: + if not body.is_in_group("player"): + return + if _has_wren_triggered or DialogueSystem.is_dialogue_active: + return + _has_wren_triggered = true + DialogueSystem.start_dialogue(WREN_DIALOGUE_PATH, { + "wren": _wren, + DialogueSystem.PLAYER_SPEAKER_ID: body, + }) diff --git a/scripts/gameplay/viaduct.gd.uid b/scripts/gameplay/viaduct.gd.uid new file mode 100644 index 0000000..f4415c5 --- /dev/null +++ b/scripts/gameplay/viaduct.gd.uid @@ -0,0 +1 @@ +uid://b5770kb2okfgx diff --git a/scripts/ui/character_creation.gd b/scripts/ui/character_creation.gd new file mode 100644 index 0000000..32d9155 --- /dev/null +++ b/scripts/ui/character_creation.gd @@ -0,0 +1,77 @@ +extends Control +## Charakter-Anlage (Phase 3): Eingabe von Tyrveils Anzeigenamen, wird +## nach "Neues Spiel" vor dem Viadukt-Prolog aufgerufen. +## +## Tastatur: Name direkt eintippen, Enter bestätigt. Controller: +## Fokus-Navigation (D-Pad/Stick) plus confirm bestätigt den eingegebenen +## bzw. Default-Namen, cancel führt zurück ins Hauptmenü. Auf eine +## virtuelle Controller-Tastatur wird bewusst verzichtet: Godots +## eingebaute Bildschirmtastatur existiert nur auf Mobile/Web, eine +## eigene wäre für den Vertical Slice unverhältnismäßig — der +## Tastatur-Fallback mit bestätigbarem Default-Namen deckt beide +## Eingabewege ab. Der Name landet in GameState.player_name und erscheint +## u. a. in der Dialog-Box. + +const VIADUCT_SCENE := "res://scenes/viaduct/viaduct.tscn" +const MAIN_MENU_SCENE := "res://scenes/ui/main_menu.tscn" + +var _is_leaving := false + +@onready var _name_edit: LineEdit = $CenterContainer/VBoxContainer/NameEdit +@onready var _confirm_button: Button = $CenterContainer/VBoxContainer/Buttons/ConfirmButton +@onready var _back_button: Button = $CenterContainer/VBoxContainer/Buttons/BackButton + + +## Gibt die Maus frei, füllt den Default-Namen ein und setzt den Fokus in +## das Eingabefeld. +func _ready() -> void: + Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) + _name_edit.text = GameState.DEFAULT_PLAYER_NAME + _name_edit.caret_column = _name_edit.text.length() + _name_edit.text_submitted.connect(_on_name_submitted) + _confirm_button.pressed.connect(_on_confirm_pressed) + _back_button.pressed.connect(_on_back_pressed) + _name_edit.grab_focus.call_deferred() + + +## Controller-Bestätigung (Ⓐ/✕) übernimmt den Namen bzw. aktiviert den +## fokussierten Button; cancel führt zurück ins Hauptmenü. Enter läuft +## über LineEdit (text_submitted) bzw. ui_accept der Buttons. +func _unhandled_input(event: InputEvent) -> void: + if _is_leaving: + return + if event.is_action_pressed("cancel"): + _on_back_pressed() + return + if not event.is_action_pressed("confirm"): + return + if event.is_action("ui_accept"): + return + var focused := get_viewport().gui_get_focus_owner() + if focused == _back_button: + _on_back_pressed() + else: + _on_confirm_pressed() + + +## Enter im Eingabefeld bestätigt den Namen. +func _on_name_submitted(_text: String) -> void: + _on_confirm_pressed() + + +## Übernimmt den Namen (leer -> Default) und startet das Viadukt. +func _on_confirm_pressed() -> void: + if _is_leaving: + return + _is_leaving = true + var chosen := _name_edit.text.strip_edges() + GameState.player_name = chosen if not chosen.is_empty() else GameState.DEFAULT_PLAYER_NAME + get_tree().change_scene_to_file(VIADUCT_SCENE) + + +## Zurück ins Hauptmenü, ohne den GameState anzufassen. +func _on_back_pressed() -> void: + if _is_leaving: + return + _is_leaving = true + get_tree().change_scene_to_file(MAIN_MENU_SCENE) diff --git a/scripts/ui/character_creation.gd.uid b/scripts/ui/character_creation.gd.uid new file mode 100644 index 0000000..2a673b1 --- /dev/null +++ b/scripts/ui/character_creation.gd.uid @@ -0,0 +1 @@ +uid://bxcrf1rspx0he diff --git a/scripts/ui/dialogue_box.gd b/scripts/ui/dialogue_box.gd index 50eee3f..7878f17 100644 --- a/scripts/ui/dialogue_box.gd +++ b/scripts/ui/dialogue_box.gd @@ -60,6 +60,8 @@ func _unhandled_input(event: InputEvent) -> void: if not has_open_options(): return if event.is_action_pressed("cancel") or event.is_action_pressed("dialogue_abort"): + if not DialogueSystem.is_abort_allowed: + return _clear_options() option_chosen.emit(ABORT_INDEX) return diff --git a/scripts/ui/main_menu.gd b/scripts/ui/main_menu.gd index 5fa066b..32992c7 100644 --- a/scripts/ui/main_menu.gd +++ b/scripts/ui/main_menu.gd @@ -10,7 +10,8 @@ extends Control ## auf den Beenden-Button. Die Aktivierung läuft explizit über die ## Input-Map-Action confirm und hängt nicht an Godots internem ui_accept. -const GAME_SCENE := "res://scenes/hub/rider_quadrant.tscn" +const CREATION_SCENE := "res://scenes/ui/character_creation.tscn" +const CONTINUE_SCENE := "res://scenes/hub/rider_quadrant.tscn" @onready var _start_button: Button = $CenterContainer/VBoxContainer/StartButton @onready var _continue_button: Button = $CenterContainer/VBoxContainer/ContinueButton @@ -56,17 +57,17 @@ func _handle_confirm(event: InputEvent) -> void: ## Startet ein neues Spiel mit frisch zurückgesetztem GameState und -## Tageszyklus. +## Tageszyklus: erst Charakter-Anlage, von dort geht es aufs Viadukt. func _on_start_pressed() -> void: GameState.reset() TimeSystem.reset() - get_tree().change_scene_to_file(GAME_SCENE) + get_tree().change_scene_to_file(CREATION_SCENE) -## Lädt den Spielstand und wechselt bei Erfolg in die Testszene. +## Lädt den Spielstand und wechselt bei Erfolg in den Reiterquadranten. func _on_continue_pressed() -> void: if SaveSystem.load_game(): - get_tree().change_scene_to_file(GAME_SCENE) + get_tree().change_scene_to_file(CONTINUE_SCENE) ## Beendet das Spiel.