Compare commits
8 Commits
sprint/5-f
...
6b0c41bbfd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b0c41bbfd | ||
|
|
13db45bb04 | ||
|
|
ace7d722ed | ||
|
|
f7c8a7ec03 | ||
|
|
9a1e30d808 | ||
|
|
c2028edb2f | ||
|
|
9daf06c9b1 | ||
|
|
2ebed0a511 |
23
.editorconfig
Normal file
23
.editorconfig
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.gd]
|
||||||
|
indent_style = tab
|
||||||
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.{tscn,tres,godot,cfg}]
|
||||||
|
indent_style = tab
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.json]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
58
docs/smoke-tests.md
Normal file
58
docs/smoke-tests.md
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
# Smoke-Test-Checkliste
|
||||||
|
|
||||||
|
> Smoke Tests werden nach jedem Sprint manuell auf einem echten Android-Tablet durchgeführt.
|
||||||
|
> Ziel ist kein vollständiger Test, sondern ein schnelles "Geht es grundlegend?" vor dem Zeigen an die Kinder.
|
||||||
|
> Neue Sprint-Abschnitte werden jeweils zu Beginn des Sprints ergänzt.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Basis-Tests (jeder Sprint)
|
||||||
|
|
||||||
|
Diese Tests werden bei jedem Sprint-Abschluss durchgeführt, unabhängig vom Inhalt.
|
||||||
|
|
||||||
|
- [ ] App startet ohne Absturz
|
||||||
|
- [ ] Kein Freeze oder schwarzer Screen in den ersten 5 Sekunden
|
||||||
|
- [ ] Musik spielt beim Start (ca. 60% Lautstärke)
|
||||||
|
- [ ] HUD: Back-Button sichtbar und funktionsfähig
|
||||||
|
- [ ] HUD: Musik-Toggle funktioniert (an/aus)
|
||||||
|
- [ ] Performance: Keine sichtbaren Ruckler beim Scrollen/Navigieren
|
||||||
|
- [ ] Touch-Targets: Alle interaktiven Elemente mit Kinderfingern erreichbar (min. 48dp)
|
||||||
|
- [ ] Offline: Spiel funktioniert vollständig ohne WLAN/Mobilfunk
|
||||||
|
- [ ] Kein Netzwerk-Request im Hintergrund (DevTools / Android Profiler prüfen)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Sprint 1 — Proof of Concept
|
||||||
|
|
||||||
|
Ziel: Erster spielbarer Raum (Empfang/Reception), Drag & Drop einer Figur, ein interaktives Objekt.
|
||||||
|
|
||||||
|
- [ ] Empfangs-Raum lädt ohne Fehler
|
||||||
|
- [ ] Figur (Häschen oder Kätzchen) ist auf dem Bildschirm sichtbar
|
||||||
|
- [ ] Figur lässt sich per Touch aufheben (Drag-Start)
|
||||||
|
- [ ] Figur lässt sich an beliebiger Stelle loslassen (Drop)
|
||||||
|
- [ ] Figur kehrt nicht automatisch zur Startposition zurück
|
||||||
|
- [ ] Interaktives Objekt (Blume) reagiert auf Touch (Animation oder Sound)
|
||||||
|
- [ ] Position der Figur bleibt nach App-Neustart erhalten (Save/Load)
|
||||||
|
- [ ] Keine GDScript-Fehler in der Godot-Konsole
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Sprint 2 — (wird ergänzt)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Sprint 3 — (wird ergänzt)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Sprint 4 — (wird ergänzt)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Sprint 5 — (wird ergänzt)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Notizen
|
||||||
|
|
||||||
|
_Auffälligkeiten, Geräte-spezifische Bugs oder UAT-Feedback der Kinder hier festhalten._
|
||||||
43
project.godot
Normal file
43
project.godot
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
; Engine configuration file.
|
||||||
|
; It's best edited using the editor UI and not directly,
|
||||||
|
; since the parameters that go here are not all obvious.
|
||||||
|
;
|
||||||
|
; Format:
|
||||||
|
; [section] ; section goes between []
|
||||||
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
|
config_version=5
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="Cozypaw Hospital"
|
||||||
|
config/description="Werbefrei. Offline. Für Kinder."
|
||||||
|
config/version="0.1.0"
|
||||||
|
run/main_scene="res://scenes/main/Main.tscn"
|
||||||
|
config/features=PackedStringArray("4.6", "Mobile")
|
||||||
|
boot_splash/show_image=false
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
GameState="*res://scripts/autoload/GameState.gd"
|
||||||
|
SaveManager="*res://scripts/autoload/SaveManager.gd"
|
||||||
|
AudioManager="*res://scripts/autoload/AudioManager.gd"
|
||||||
|
InputManager="*res://scripts/autoload/InputManager.gd"
|
||||||
|
RoomNavigator="*res://scripts/systems/room_navigator.gd"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/viewport_width=1280
|
||||||
|
window/size/viewport_height=720
|
||||||
|
window/stretch/mode="canvas_items"
|
||||||
|
window/stretch/aspect="expand"
|
||||||
|
|
||||||
|
[input_devices]
|
||||||
|
|
||||||
|
pointing/emulate_touch_from_mouse=true
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
renderer/rendering_method="gl_compatibility"
|
||||||
|
renderer/rendering_method.mobile="gl_compatibility"
|
||||||
|
textures/vram_compression/import_etc2_astc=true
|
||||||
51
scenes/characters/Character.tscn
Normal file
51
scenes/characters/Character.tscn
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://cozypaw_char"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/characters/character.gd" id="1_char"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/systems/drag_drop_component.gd" id="2_drag"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_char"]
|
||||||
|
size = Vector2(64, 80)
|
||||||
|
|
||||||
|
[node name="Character" type="Node2D"]
|
||||||
|
script = ExtResource("1_char")
|
||||||
|
character_id = "bunny_01"
|
||||||
|
display_name = "Bunny"
|
||||||
|
|
||||||
|
[node name="Visual" type="ColorRect" parent="."]
|
||||||
|
color = Color(0.95, 0.85, 0.9, 1)
|
||||||
|
size = Vector2(64, 80)
|
||||||
|
position = Vector2(-32, -80)
|
||||||
|
|
||||||
|
[node name="Eyes" type="Node2D" parent="Visual"]
|
||||||
|
|
||||||
|
[node name="EyeLeft" type="ColorRect" parent="Visual/Eyes"]
|
||||||
|
color = Color(0.1, 0.1, 0.1, 1)
|
||||||
|
size = Vector2(8, 8)
|
||||||
|
position = Vector2(14, 20)
|
||||||
|
|
||||||
|
[node name="EyeRight" type="ColorRect" parent="Visual/Eyes"]
|
||||||
|
color = Color(0.1, 0.1, 0.1, 1)
|
||||||
|
size = Vector2(8, 8)
|
||||||
|
position = Vector2(42, 20)
|
||||||
|
|
||||||
|
[node name="Ears" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="EarLeft" type="ColorRect" parent="Ears"]
|
||||||
|
color = Color(0.95, 0.85, 0.9, 1)
|
||||||
|
size = Vector2(18, 36)
|
||||||
|
position = Vector2(-22, -114)
|
||||||
|
|
||||||
|
[node name="EarRight" type="ColorRect" parent="Ears"]
|
||||||
|
color = Color(0.95, 0.85, 0.9, 1)
|
||||||
|
size = Vector2(18, 36)
|
||||||
|
position = Vector2(4, -114)
|
||||||
|
|
||||||
|
[node name="DragDropComponent" type="Node" parent="."]
|
||||||
|
script = ExtResource("2_drag")
|
||||||
|
|
||||||
|
[node name="CollisionArea" type="Area2D" parent="."]
|
||||||
|
input_pickable = true
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape2D" parent="CollisionArea"]
|
||||||
|
shape = SubResource("RectangleShape2D_char")
|
||||||
|
position = Vector2(0, -40)
|
||||||
101
scenes/main/Main.tscn
Normal file
101
scenes/main/Main.tscn
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
[gd_scene load_steps=8 format=3 uid="uid://cozypaw_main"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/main/main.gd" id="1_main"]
|
||||||
|
[ext_resource type="PackedScene" path="res://scenes/rooms/floor0/Reception.tscn" id="2_reception"]
|
||||||
|
[ext_resource type="PackedScene" path="res://scenes/characters/Character.tscn" id="3_char"]
|
||||||
|
[ext_resource type="PackedScene" path="res://scenes/ui/HUD.tscn" id="4_hud"]
|
||||||
|
[ext_resource type="PackedScene" path="res://scenes/ui/SettingsMenu.tscn" id="5_settings"]
|
||||||
|
[ext_resource type="PackedScene" path="res://scenes/objects/ElevatorButton.tscn" id="6_elevbtn"]
|
||||||
|
|
||||||
|
[sub_resource type="CharacterData" id="CharacterData_bunny1"]
|
||||||
|
id = "bunny_01"
|
||||||
|
display_name = "Bunny"
|
||||||
|
species = 0
|
||||||
|
state = 0
|
||||||
|
current_floor = 0
|
||||||
|
position = Vector2(0, 0)
|
||||||
|
|
||||||
|
[node name="Main" type="Node2D"]
|
||||||
|
script = ExtResource("1_main")
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
|
position = Vector2(640, 360)
|
||||||
|
zoom = Vector2(1, 1)
|
||||||
|
|
||||||
|
[node name="Hospital" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Floor0" type="Node2D" parent="Hospital"]
|
||||||
|
position = Vector2(0, 0)
|
||||||
|
|
||||||
|
[node name="Reception" parent="Hospital/Floor0" instance=ExtResource("2_reception")]
|
||||||
|
position = Vector2(0, 0)
|
||||||
|
|
||||||
|
[node name="ElevatorUp0" parent="Hospital/Floor0" instance=ExtResource("6_elevbtn")]
|
||||||
|
position = Vector2(1200, 360)
|
||||||
|
target_floor = 1
|
||||||
|
|
||||||
|
[node name="Floor1" type="Node2D" parent="Hospital"]
|
||||||
|
position = Vector2(0, -720)
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="Hospital/Floor1"]
|
||||||
|
color = Color(0.78, 0.88, 0.96, 1)
|
||||||
|
size = Vector2(1280, 720)
|
||||||
|
position = Vector2(0, 0)
|
||||||
|
|
||||||
|
[node name="FloorLabel" type="Label" parent="Hospital/Floor1"]
|
||||||
|
offset_left = 560.0
|
||||||
|
offset_top = 300.0
|
||||||
|
offset_right = 720.0
|
||||||
|
offset_bottom = 360.0
|
||||||
|
text = "1. OG"
|
||||||
|
theme_override_font_sizes/font_size = 32
|
||||||
|
|
||||||
|
[node name="FloorRect" type="ColorRect" parent="Hospital/Floor1"]
|
||||||
|
color = Color(0.88, 0.80, 0.68, 1)
|
||||||
|
size = Vector2(1280, 100)
|
||||||
|
position = Vector2(0, 620)
|
||||||
|
|
||||||
|
[node name="ElevatorDown1" parent="Hospital/Floor1" instance=ExtResource("6_elevbtn")]
|
||||||
|
position = Vector2(1200, 540)
|
||||||
|
target_floor = 0
|
||||||
|
|
||||||
|
[node name="ElevatorUp1" parent="Hospital/Floor1" instance=ExtResource("6_elevbtn")]
|
||||||
|
position = Vector2(1200, 180)
|
||||||
|
target_floor = 2
|
||||||
|
|
||||||
|
[node name="Floor2" type="Node2D" parent="Hospital"]
|
||||||
|
position = Vector2(0, -1440)
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="Hospital/Floor2"]
|
||||||
|
color = Color(0.96, 0.88, 0.96, 1)
|
||||||
|
size = Vector2(1280, 720)
|
||||||
|
position = Vector2(0, 0)
|
||||||
|
|
||||||
|
[node name="FloorLabel" type="Label" parent="Hospital/Floor2"]
|
||||||
|
offset_left = 560.0
|
||||||
|
offset_top = 300.0
|
||||||
|
offset_right = 720.0
|
||||||
|
offset_bottom = 360.0
|
||||||
|
text = "2. OG"
|
||||||
|
theme_override_font_sizes/font_size = 32
|
||||||
|
|
||||||
|
[node name="FloorRect" type="ColorRect" parent="Hospital/Floor2"]
|
||||||
|
color = Color(0.88, 0.80, 0.68, 1)
|
||||||
|
size = Vector2(1280, 100)
|
||||||
|
position = Vector2(0, 620)
|
||||||
|
|
||||||
|
[node name="ElevatorDown2" parent="Hospital/Floor2" instance=ExtResource("6_elevbtn")]
|
||||||
|
position = Vector2(1200, 360)
|
||||||
|
target_floor = 1
|
||||||
|
|
||||||
|
[node name="Characters" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Bunny1" parent="Characters" instance=ExtResource("3_char")]
|
||||||
|
position = Vector2(300, 400)
|
||||||
|
data = SubResource("CharacterData_bunny1")
|
||||||
|
|
||||||
|
[node name="UI" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
[node name="HUD" parent="UI" instance=ExtResource("4_hud")]
|
||||||
|
|
||||||
|
[node name="SettingsMenu" parent="UI" instance=ExtResource("5_settings")]
|
||||||
29
scenes/objects/ElevatorButton.tscn
Normal file
29
scenes/objects/ElevatorButton.tscn
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
[gd_scene load_steps=3 format=3 uid="uid://cozypaw_elevator_btn"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/objects/elevator_button.gd" id="1_elevbtn"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_elevbtn"]
|
||||||
|
size = Vector2(80, 80)
|
||||||
|
|
||||||
|
[node name="ElevatorButton" type="Node2D"]
|
||||||
|
script = ExtResource("1_elevbtn")
|
||||||
|
|
||||||
|
[node name="Visual" type="ColorRect" parent="."]
|
||||||
|
color = Color(0.95, 0.75, 0.3, 1)
|
||||||
|
size = Vector2(80, 80)
|
||||||
|
position = Vector2(-40, -40)
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="Visual"]
|
||||||
|
offset_left = 0.0
|
||||||
|
offset_top = 0.0
|
||||||
|
offset_right = 80.0
|
||||||
|
offset_bottom = 80.0
|
||||||
|
horizontal_alignment = 1
|
||||||
|
vertical_alignment = 1
|
||||||
|
text = "▲"
|
||||||
|
|
||||||
|
[node name="CollisionArea" type="Area2D" parent="."]
|
||||||
|
input_pickable = true
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape2D" parent="CollisionArea"]
|
||||||
|
shape = SubResource("RectangleShape2D_elevbtn")
|
||||||
32
scenes/objects/InteractiveObject.tscn
Normal file
32
scenes/objects/InteractiveObject.tscn
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://cozypaw_iobj"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/objects/interactive_object.gd" id="1_iobj"]
|
||||||
|
[ext_resource type="Script" path="res://scripts/systems/drag_drop_component.gd" id="2_drag"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_obj"]
|
||||||
|
size = Vector2(48, 48)
|
||||||
|
|
||||||
|
[node name="InteractiveObject" type="Node2D"]
|
||||||
|
script = ExtResource("1_iobj")
|
||||||
|
object_id = "flower_01"
|
||||||
|
|
||||||
|
[node name="Visual" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Stem" type="ColorRect" parent="Visual"]
|
||||||
|
color = Color(0.2, 0.7, 0.2, 1)
|
||||||
|
size = Vector2(8, 40)
|
||||||
|
position = Vector2(-4, -40)
|
||||||
|
|
||||||
|
[node name="Bloom" type="ColorRect" parent="Visual"]
|
||||||
|
color = Color(1.0, 0.4, 0.6, 1)
|
||||||
|
size = Vector2(32, 32)
|
||||||
|
position = Vector2(-16, -72)
|
||||||
|
|
||||||
|
[node name="DragDropComponent" type="Node" parent="."]
|
||||||
|
script = ExtResource("2_drag")
|
||||||
|
|
||||||
|
[node name="CollisionArea" type="Area2D" parent="."]
|
||||||
|
input_pickable = true
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape2D" parent="CollisionArea"]
|
||||||
|
shape = SubResource("RectangleShape2D_obj")
|
||||||
41
scenes/rooms/floor0/Reception.tscn
Normal file
41
scenes/rooms/floor0/Reception.tscn
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://cozypaw_reception"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" path="res://scenes/objects/InteractiveObject.tscn" id="1_iobj"]
|
||||||
|
|
||||||
|
[node name="Reception" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Background" type="ColorRect" parent="."]
|
||||||
|
color = Color(0.78, 0.94, 0.80, 1)
|
||||||
|
size = Vector2(1280, 720)
|
||||||
|
position = Vector2(0, 0)
|
||||||
|
|
||||||
|
[node name="Counter" type="ColorRect" parent="."]
|
||||||
|
color = Color(0.55, 0.35, 0.18, 1)
|
||||||
|
size = Vector2(300, 80)
|
||||||
|
position = Vector2(490, 610)
|
||||||
|
|
||||||
|
[node name="CounterTop" type="ColorRect" parent="."]
|
||||||
|
color = Color(0.70, 0.50, 0.28, 1)
|
||||||
|
size = Vector2(300, 12)
|
||||||
|
position = Vector2(490, 598)
|
||||||
|
|
||||||
|
[node name="Floor" type="ColorRect" parent="."]
|
||||||
|
color = Color(0.88, 0.80, 0.68, 1)
|
||||||
|
size = Vector2(1280, 100)
|
||||||
|
position = Vector2(0, 620)
|
||||||
|
|
||||||
|
[node name="WallLeft" type="ColorRect" parent="."]
|
||||||
|
color = Color(0.92, 0.88, 0.82, 1)
|
||||||
|
size = Vector2(40, 620)
|
||||||
|
position = Vector2(0, 0)
|
||||||
|
|
||||||
|
[node name="WallRight" type="ColorRect" parent="."]
|
||||||
|
color = Color(0.92, 0.88, 0.82, 1)
|
||||||
|
size = Vector2(40, 620)
|
||||||
|
position = Vector2(1240, 0)
|
||||||
|
|
||||||
|
[node name="CharacterSpawn" type="Marker2D" parent="."]
|
||||||
|
position = Vector2(300, 520)
|
||||||
|
|
||||||
|
[node name="Flower" parent="." instance=ExtResource("1_iobj")]
|
||||||
|
position = Vector2(200, 560)
|
||||||
49
scenes/ui/HUD.tscn
Normal file
49
scenes/ui/HUD.tscn
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://cozypaw_hud"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/systems/hud.gd" id="1_hud"]
|
||||||
|
|
||||||
|
[node name="HUD" type="CanvasLayer"]
|
||||||
|
script = ExtResource("1_hud")
|
||||||
|
|
||||||
|
[node name="BackButton" type="Button" parent="."]
|
||||||
|
anchors_preset = 0
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
offset_left = 16.0
|
||||||
|
offset_top = 16.0
|
||||||
|
offset_right = 80.0
|
||||||
|
offset_bottom = 80.0
|
||||||
|
text = "←"
|
||||||
|
flat = false
|
||||||
|
|
||||||
|
[node name="MusicToggle" type="Button" parent="."]
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
offset_left = -80.0
|
||||||
|
offset_top = 16.0
|
||||||
|
offset_right = -16.0
|
||||||
|
offset_bottom = 80.0
|
||||||
|
text = "♪"
|
||||||
|
flat = false
|
||||||
|
|
||||||
|
[node name="SettingsButton" type="Button" parent="."]
|
||||||
|
anchors_preset = 1
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
offset_left = -160.0
|
||||||
|
offset_top = 16.0
|
||||||
|
offset_right = -96.0
|
||||||
|
offset_bottom = 80.0
|
||||||
|
text = "⚙"
|
||||||
|
flat = false
|
||||||
|
|
||||||
|
[connection signal="pressed" from="BackButton" to="." method="_on_back_button_pressed"]
|
||||||
|
[connection signal="pressed" from="MusicToggle" to="." method="_on_music_toggle_pressed"]
|
||||||
|
[connection signal="pressed" from="SettingsButton" to="." method="_on_settings_button_pressed"]
|
||||||
103
scenes/ui/SettingsMenu.tscn
Normal file
103
scenes/ui/SettingsMenu.tscn
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
[gd_scene load_steps=2 format=3 uid="uid://cozypaw_settings"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scripts/systems/settings_menu.gd" id="1_settings"]
|
||||||
|
|
||||||
|
[node name="SettingsMenu" type="CanvasLayer"]
|
||||||
|
script = ExtResource("1_settings")
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="Backdrop" type="ColorRect" parent="."]
|
||||||
|
color = Color(0, 0, 0, 0.7)
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_left = 0.0
|
||||||
|
offset_top = 0.0
|
||||||
|
offset_right = 0.0
|
||||||
|
offset_bottom = 0.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="Panel" type="Panel" parent="."]
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -200.0
|
||||||
|
offset_top = -150.0
|
||||||
|
offset_right = 200.0
|
||||||
|
offset_bottom = 150.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|
||||||
|
[node name="Title" type="Label" parent="Panel"]
|
||||||
|
offset_left = 0.0
|
||||||
|
offset_top = 16.0
|
||||||
|
offset_right = 400.0
|
||||||
|
offset_bottom = 64.0
|
||||||
|
horizontal_alignment = 1
|
||||||
|
text = "⚙"
|
||||||
|
theme_override_font_sizes/font_size = 32
|
||||||
|
|
||||||
|
[node name="MusicLabel" type="Label" parent="Panel"]
|
||||||
|
offset_left = 24.0
|
||||||
|
offset_top = 76.0
|
||||||
|
offset_right = 80.0
|
||||||
|
offset_bottom = 108.0
|
||||||
|
text = "♪"
|
||||||
|
theme_override_font_sizes/font_size = 24
|
||||||
|
|
||||||
|
[node name="MusicSlider" type="HSlider" parent="Panel"]
|
||||||
|
min_value = 0.0
|
||||||
|
max_value = 1.0
|
||||||
|
step = 0.05
|
||||||
|
value = 0.6
|
||||||
|
offset_left = 88.0
|
||||||
|
offset_top = 76.0
|
||||||
|
offset_right = 376.0
|
||||||
|
offset_bottom = 108.0
|
||||||
|
|
||||||
|
[node name="SfxLabel" type="Label" parent="Panel"]
|
||||||
|
offset_left = 24.0
|
||||||
|
offset_top = 120.0
|
||||||
|
offset_right = 80.0
|
||||||
|
offset_bottom = 152.0
|
||||||
|
text = "🔊"
|
||||||
|
theme_override_font_sizes/font_size = 24
|
||||||
|
|
||||||
|
[node name="SfxSlider" type="HSlider" parent="Panel"]
|
||||||
|
min_value = 0.0
|
||||||
|
max_value = 1.0
|
||||||
|
step = 0.05
|
||||||
|
value = 1.0
|
||||||
|
offset_left = 88.0
|
||||||
|
offset_top = 120.0
|
||||||
|
offset_right = 376.0
|
||||||
|
offset_bottom = 152.0
|
||||||
|
|
||||||
|
[node name="ResetButton" type="Button" parent="Panel"]
|
||||||
|
offset_left = 24.0
|
||||||
|
offset_top = 172.0
|
||||||
|
offset_right = 88.0
|
||||||
|
offset_bottom = 236.0
|
||||||
|
text = "↺"
|
||||||
|
theme_override_font_sizes/font_size = 28
|
||||||
|
|
||||||
|
[node name="ResetConfirmDialog" type="ConfirmationDialog" parent="Panel"]
|
||||||
|
title = "Reset?"
|
||||||
|
dialog_text = "Spielstand löschen?"
|
||||||
|
|
||||||
|
[node name="CloseButton" type="Button" parent="Panel"]
|
||||||
|
offset_left = 312.0
|
||||||
|
offset_top = 172.0
|
||||||
|
offset_right = 376.0
|
||||||
|
offset_bottom = 236.0
|
||||||
|
text = "✕"
|
||||||
|
theme_override_font_sizes/font_size = 28
|
||||||
|
|
||||||
|
[connection signal="value_changed" from="Panel/MusicSlider" to="." method="_on_music_slider_value_changed"]
|
||||||
|
[connection signal="value_changed" from="Panel/SfxSlider" to="." method="_on_sfx_slider_value_changed"]
|
||||||
|
[connection signal="pressed" from="Panel/ResetButton" to="." method="_on_reset_button_pressed"]
|
||||||
|
[connection signal="confirmed" from="Panel/ResetConfirmDialog" to="." method="_on_reset_confirmed"]
|
||||||
|
[connection signal="pressed" from="Panel/CloseButton" to="." method="_on_close_button_pressed"]
|
||||||
63
scripts/autoload/AudioManager.gd
Normal file
63
scripts/autoload/AudioManager.gd
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
## AudioManager — music playback with cross-fade, SFX playback, volume control.
|
||||||
|
class_name AudioManager extends Node
|
||||||
|
|
||||||
|
const DEFAULT_MUSIC_VOLUME: float = 0.6
|
||||||
|
const CROSSFADE_DURATION: float = 1.0
|
||||||
|
|
||||||
|
var _music_player_a: AudioStreamPlayer
|
||||||
|
var _music_player_b: AudioStreamPlayer
|
||||||
|
var _active_player: AudioStreamPlayer
|
||||||
|
var _sfx_player: AudioStreamPlayer
|
||||||
|
var _music_volume: float = DEFAULT_MUSIC_VOLUME
|
||||||
|
var _sfx_volume: float = 1.0
|
||||||
|
var _is_fading: bool = false
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
_music_player_a = AudioStreamPlayer.new()
|
||||||
|
_music_player_b = AudioStreamPlayer.new()
|
||||||
|
_sfx_player = AudioStreamPlayer.new()
|
||||||
|
add_child(_music_player_a)
|
||||||
|
add_child(_music_player_b)
|
||||||
|
add_child(_sfx_player)
|
||||||
|
_active_player = _music_player_a
|
||||||
|
_apply_music_volume()
|
||||||
|
|
||||||
|
|
||||||
|
func play_music(stream: AudioStream) -> void:
|
||||||
|
if _active_player.stream == stream and _active_player.playing:
|
||||||
|
return
|
||||||
|
var next_player: AudioStreamPlayer = _music_player_b if _active_player == _music_player_a else _music_player_a
|
||||||
|
next_player.stream = stream
|
||||||
|
next_player.volume_db = linear_to_db(0.0)
|
||||||
|
next_player.play()
|
||||||
|
var prev_player: AudioStreamPlayer = _active_player
|
||||||
|
_active_player = next_player
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
tween.set_parallel(true)
|
||||||
|
tween.tween_property(prev_player, "volume_db", linear_to_db(0.0), CROSSFADE_DURATION)
|
||||||
|
tween.tween_property(next_player, "volume_db", linear_to_db(_music_volume), CROSSFADE_DURATION)
|
||||||
|
tween.chain().tween_callback(prev_player.stop)
|
||||||
|
|
||||||
|
|
||||||
|
func play_sfx(stream: AudioStream) -> void:
|
||||||
|
_sfx_player.stream = stream
|
||||||
|
_sfx_player.volume_db = linear_to_db(_sfx_volume)
|
||||||
|
_sfx_player.play()
|
||||||
|
|
||||||
|
|
||||||
|
func set_music_volume(value: float) -> void:
|
||||||
|
_music_volume = clampf(value, 0.0, 1.0)
|
||||||
|
_apply_music_volume()
|
||||||
|
|
||||||
|
|
||||||
|
func set_sfx_volume(value: float) -> void:
|
||||||
|
_sfx_volume = clampf(value, 0.0, 1.0)
|
||||||
|
|
||||||
|
|
||||||
|
func get_music_volume() -> float:
|
||||||
|
return _music_volume
|
||||||
|
|
||||||
|
|
||||||
|
func _apply_music_volume() -> void:
|
||||||
|
_active_player.volume_db = linear_to_db(_music_volume)
|
||||||
57
scripts/autoload/GameState.gd
Normal file
57
scripts/autoload/GameState.gd
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
## GameState — global game state: character positions, object states, current room.
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
signal state_changed
|
||||||
|
signal character_moved(character_id: String, position: Vector2)
|
||||||
|
|
||||||
|
var _character_positions: Dictionary = {}
|
||||||
|
var _object_states: Dictionary = {}
|
||||||
|
var current_room: String = "reception"
|
||||||
|
var music_volume: float = 0.6
|
||||||
|
var sfx_volume: float = 1.0
|
||||||
|
|
||||||
|
|
||||||
|
func has_character_position(id: String) -> bool:
|
||||||
|
return _character_positions.has(id)
|
||||||
|
|
||||||
|
|
||||||
|
func get_character_position(id: String) -> Vector2:
|
||||||
|
return _character_positions.get(id, Vector2.ZERO)
|
||||||
|
|
||||||
|
|
||||||
|
func set_character_position(id: String, pos: Vector2) -> void:
|
||||||
|
_character_positions[id] = pos
|
||||||
|
character_moved.emit(id, pos)
|
||||||
|
state_changed.emit()
|
||||||
|
|
||||||
|
|
||||||
|
func get_object_state(id: String) -> String:
|
||||||
|
return _object_states.get(id, "idle")
|
||||||
|
|
||||||
|
|
||||||
|
func set_object_state(id: String, state: String) -> void:
|
||||||
|
_object_states[id] = state
|
||||||
|
state_changed.emit()
|
||||||
|
|
||||||
|
|
||||||
|
func get_save_data() -> Dictionary:
|
||||||
|
return {
|
||||||
|
"character_positions": _character_positions,
|
||||||
|
"object_states": _object_states,
|
||||||
|
"current_room": current_room,
|
||||||
|
"music_volume": music_volume,
|
||||||
|
"sfx_volume": sfx_volume,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func apply_save_data(data: Dictionary) -> void:
|
||||||
|
if data.has("character_positions"):
|
||||||
|
_character_positions = data["character_positions"]
|
||||||
|
if data.has("object_states"):
|
||||||
|
_object_states = data["object_states"]
|
||||||
|
if data.has("current_room"):
|
||||||
|
current_room = data["current_room"]
|
||||||
|
if data.has("music_volume"):
|
||||||
|
music_volume = data["music_volume"]
|
||||||
|
if data.has("sfx_volume"):
|
||||||
|
sfx_volume = data["sfx_volume"]
|
||||||
40
scripts/autoload/InputManager.gd
Normal file
40
scripts/autoload/InputManager.gd
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
## InputManager — abstracts touch and mouse input into unified drag signals.
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
signal drag_started(position: Vector2)
|
||||||
|
signal drag_moved(position: Vector2)
|
||||||
|
signal drag_ended(position: Vector2)
|
||||||
|
|
||||||
|
var _is_dragging: bool = false
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if event is InputEventScreenTouch:
|
||||||
|
if event.pressed:
|
||||||
|
_emit_drag_started(event.position)
|
||||||
|
else:
|
||||||
|
_emit_drag_ended(event.position)
|
||||||
|
elif event is InputEventScreenDrag:
|
||||||
|
if _is_dragging:
|
||||||
|
_emit_drag_moved(event.position)
|
||||||
|
elif event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
|
if event.pressed:
|
||||||
|
_emit_drag_started(event.position)
|
||||||
|
else:
|
||||||
|
_emit_drag_ended(event.position)
|
||||||
|
elif event is InputEventMouseMotion and _is_dragging:
|
||||||
|
_emit_drag_moved(event.position)
|
||||||
|
|
||||||
|
|
||||||
|
func _emit_drag_started(pos: Vector2) -> void:
|
||||||
|
_is_dragging = true
|
||||||
|
drag_started.emit(pos)
|
||||||
|
|
||||||
|
|
||||||
|
func _emit_drag_moved(pos: Vector2) -> void:
|
||||||
|
drag_moved.emit(pos)
|
||||||
|
|
||||||
|
|
||||||
|
func _emit_drag_ended(pos: Vector2) -> void:
|
||||||
|
_is_dragging = false
|
||||||
|
drag_ended.emit(pos)
|
||||||
43
scripts/autoload/SaveManager.gd
Normal file
43
scripts/autoload/SaveManager.gd
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
## SaveManager — persists game state as JSON to user://savegame.json, auto-saves on state_changed.
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
const SAVE_PATH: String = "user://savegame.json"
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
GameState.state_changed.connect(_on_state_changed)
|
||||||
|
|
||||||
|
|
||||||
|
func save_game() -> void:
|
||||||
|
var data: Dictionary = GameState.get_save_data()
|
||||||
|
var file: FileAccess = FileAccess.open(SAVE_PATH, FileAccess.WRITE)
|
||||||
|
if file == null:
|
||||||
|
push_error("SaveManager: cannot open save file for writing")
|
||||||
|
return
|
||||||
|
file.store_string(JSON.stringify(data))
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
|
func load_game() -> void:
|
||||||
|
if not FileAccess.file_exists(SAVE_PATH):
|
||||||
|
return
|
||||||
|
var file: FileAccess = FileAccess.open(SAVE_PATH, FileAccess.READ)
|
||||||
|
if file == null:
|
||||||
|
return
|
||||||
|
var raw: String = file.get_as_text()
|
||||||
|
file.close()
|
||||||
|
var parsed: Variant = JSON.parse_string(raw)
|
||||||
|
if parsed is Dictionary:
|
||||||
|
GameState.apply_save_data(parsed)
|
||||||
|
|
||||||
|
|
||||||
|
func reset_game() -> void:
|
||||||
|
if FileAccess.file_exists(SAVE_PATH):
|
||||||
|
var dir: DirAccess = DirAccess.open("user://")
|
||||||
|
if dir != null:
|
||||||
|
dir.remove("savegame.json")
|
||||||
|
GameState.apply_save_data({})
|
||||||
|
|
||||||
|
|
||||||
|
func _on_state_changed() -> void:
|
||||||
|
save_game()
|
||||||
67
scripts/characters/character.gd
Normal file
67
scripts/characters/character.gd
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
## Character — base class for all playable figures (bunny, cat, etc.).
|
||||||
|
class_name Character extends Node2D
|
||||||
|
|
||||||
|
signal character_picked_up(character: Character)
|
||||||
|
signal character_placed(character: Character, position: Vector2)
|
||||||
|
signal state_changed(new_state: CharacterData.State)
|
||||||
|
|
||||||
|
@export var character_id: String = ""
|
||||||
|
@export var display_name: String = ""
|
||||||
|
@export var data: CharacterData
|
||||||
|
|
||||||
|
var _is_held: bool = false
|
||||||
|
|
||||||
|
const _STATE_COLORS: Dictionary = {
|
||||||
|
CharacterData.State.HEALTHY: Color(0.6, 0.8, 1.0),
|
||||||
|
CharacterData.State.SICK: Color(0.7, 0.9, 0.7),
|
||||||
|
CharacterData.State.SLEEPING: Color(0.8, 0.7, 0.95),
|
||||||
|
CharacterData.State.TIRED: Color(1.0, 0.95, 0.6),
|
||||||
|
CharacterData.State.PREGNANT: Color(1.0, 0.85, 0.9),
|
||||||
|
CharacterData.State.BABY: Color(0.9, 0.95, 1.0),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
var drag: DragDropComponent = get_node_or_null("DragDropComponent") as DragDropComponent
|
||||||
|
if drag != null:
|
||||||
|
drag.drag_picked_up.connect(_on_drag_picked_up)
|
||||||
|
drag.drag_released.connect(_on_drag_released)
|
||||||
|
if data != null:
|
||||||
|
_update_visual_state()
|
||||||
|
|
||||||
|
|
||||||
|
func set_state(new_state: CharacterData.State) -> void:
|
||||||
|
if data == null:
|
||||||
|
return
|
||||||
|
data.state = new_state
|
||||||
|
_update_visual_state()
|
||||||
|
state_changed.emit(new_state)
|
||||||
|
|
||||||
|
|
||||||
|
func _update_visual_state() -> void:
|
||||||
|
if data == null:
|
||||||
|
return
|
||||||
|
var visual: ColorRect = get_node_or_null("Visual") as ColorRect
|
||||||
|
if visual == null:
|
||||||
|
return
|
||||||
|
var color: Color = _STATE_COLORS.get(data.state, Color(0.6, 0.8, 1.0))
|
||||||
|
visual.color = color
|
||||||
|
var ear_left: ColorRect = get_node_or_null("Ears/EarLeft") as ColorRect
|
||||||
|
var ear_right: ColorRect = get_node_or_null("Ears/EarRight") as ColorRect
|
||||||
|
if ear_left != null:
|
||||||
|
ear_left.color = color
|
||||||
|
if ear_right != null:
|
||||||
|
ear_right.color = color
|
||||||
|
|
||||||
|
|
||||||
|
func _on_drag_picked_up(_pos: Vector2) -> void:
|
||||||
|
_is_held = true
|
||||||
|
character_picked_up.emit(self)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_drag_released(pos: Vector2) -> void:
|
||||||
|
_is_held = false
|
||||||
|
if data == null or data.id.is_empty():
|
||||||
|
return
|
||||||
|
GameState.set_character_position(character_id, global_position)
|
||||||
|
character_placed.emit(self, global_position)
|
||||||
12
scripts/characters/character_data.gd
Normal file
12
scripts/characters/character_data.gd
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
## CharacterData — Resource holding all persistent state for one character.
|
||||||
|
class_name CharacterData extends Resource
|
||||||
|
|
||||||
|
enum State { HEALTHY, SICK, SLEEPING, TIRED, PREGNANT, BABY }
|
||||||
|
enum Species { BUNNY, KITTEN }
|
||||||
|
|
||||||
|
@export var id: String = ""
|
||||||
|
@export var display_name: String = ""
|
||||||
|
@export var species: Species = Species.BUNNY
|
||||||
|
@export var state: State = State.HEALTHY
|
||||||
|
@export var current_floor: int = 0
|
||||||
|
@export var position: Vector2 = Vector2.ZERO
|
||||||
17
scripts/main/main.gd
Normal file
17
scripts/main/main.gd
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
## Main — scene root: wires up RoomNavigator and restores saved character positions.
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
RoomNavigator.initialize($Camera2D)
|
||||||
|
SaveManager.load_game()
|
||||||
|
AudioManager.set_music_volume(GameState.music_volume)
|
||||||
|
AudioManager.set_sfx_volume(GameState.sfx_volume)
|
||||||
|
_apply_saved_state()
|
||||||
|
|
||||||
|
|
||||||
|
func _apply_saved_state() -> void:
|
||||||
|
for character in $Characters.get_children():
|
||||||
|
if character is Character and character.data != null:
|
||||||
|
if GameState.has_character_position(character.data.id):
|
||||||
|
character.global_position = GameState.get_character_position(character.data.id)
|
||||||
32
scripts/objects/elevator_button.gd
Normal file
32
scripts/objects/elevator_button.gd
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
## ElevatorButton — tappable button that navigates the camera to a target floor.
|
||||||
|
class_name ElevatorButton extends Node2D
|
||||||
|
|
||||||
|
@export var target_floor: int = 0
|
||||||
|
|
||||||
|
var _area: Area2D
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
_area = get_node_or_null("CollisionArea") as Area2D
|
||||||
|
if _area != null:
|
||||||
|
_area.input_event.connect(_on_input_event)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
|
||||||
|
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
|
_on_pressed()
|
||||||
|
elif event is InputEventScreenTouch and event.pressed:
|
||||||
|
_on_pressed()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_pressed() -> void:
|
||||||
|
if target_floor < 0:
|
||||||
|
return
|
||||||
|
RoomNavigator.go_to_floor(target_floor)
|
||||||
|
_play_bounce()
|
||||||
|
|
||||||
|
|
||||||
|
func _play_bounce() -> void:
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
tween.tween_property(self, "scale", Vector2(1.15, 1.15), 0.08)
|
||||||
|
tween.tween_property(self, "scale", Vector2(1.0, 1.0), 0.08)
|
||||||
57
scripts/objects/interactive_object.gd
Normal file
57
scripts/objects/interactive_object.gd
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
## InteractiveObject — base class for all interactive room objects (flowers, equipment, etc.).
|
||||||
|
class_name InteractiveObject extends Node2D
|
||||||
|
|
||||||
|
signal object_interacted(object: InteractiveObject)
|
||||||
|
|
||||||
|
enum State { IDLE, ACTIVE, RETURNING }
|
||||||
|
|
||||||
|
@export var object_id: String = ""
|
||||||
|
|
||||||
|
var _current_state: State = State.IDLE
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
var drag: DragDropComponent = get_node_or_null("DragDropComponent") as DragDropComponent
|
||||||
|
if drag != null:
|
||||||
|
drag.drag_picked_up.connect(_on_drag_picked_up)
|
||||||
|
drag.drag_released.connect(_on_drag_released)
|
||||||
|
var area: Area2D = get_node_or_null("CollisionArea") as Area2D
|
||||||
|
if area != null:
|
||||||
|
area.input_event.connect(_on_area_input_event)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_drag_picked_up(_pos: Vector2) -> void:
|
||||||
|
_set_state(State.ACTIVE)
|
||||||
|
object_interacted.emit(self)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_drag_released(_pos: Vector2) -> void:
|
||||||
|
_set_state(State.RETURNING)
|
||||||
|
GameState.set_object_state(object_id, "idle")
|
||||||
|
_play_bounce_animation()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_area_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void:
|
||||||
|
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
|
_trigger_interaction()
|
||||||
|
elif event is InputEventScreenTouch and event.pressed:
|
||||||
|
_trigger_interaction()
|
||||||
|
|
||||||
|
|
||||||
|
func _trigger_interaction() -> void:
|
||||||
|
_set_state(State.ACTIVE)
|
||||||
|
object_interacted.emit(self)
|
||||||
|
GameState.set_object_state(object_id, "active")
|
||||||
|
_play_bounce_animation()
|
||||||
|
|
||||||
|
|
||||||
|
func _set_state(new_state: State) -> void:
|
||||||
|
_current_state = new_state
|
||||||
|
|
||||||
|
|
||||||
|
func _play_bounce_animation() -> void:
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
tween.tween_property(self, "scale", Vector2(1.2, 1.2), 0.1)
|
||||||
|
tween.tween_property(self, "scale", Vector2(0.9, 0.9), 0.1)
|
||||||
|
tween.tween_property(self, "scale", Vector2(1.0, 1.0), 0.1)
|
||||||
|
tween.tween_callback(func() -> void: _set_state(State.IDLE))
|
||||||
81
scripts/systems/drag_drop_component.gd
Normal file
81
scripts/systems/drag_drop_component.gd
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
## DragDropComponent — reusable drag-and-drop node; attach to any Character or InteractiveObject.
|
||||||
|
class_name DragDropComponent extends Node
|
||||||
|
|
||||||
|
signal drag_picked_up(global_position: Vector2)
|
||||||
|
signal drag_released(global_position: Vector2)
|
||||||
|
|
||||||
|
const DRAG_Z_INDEX: int = 10
|
||||||
|
const DRAG_SCALE: float = 1.1
|
||||||
|
const DEFAULT_DRAG_RADIUS: float = 64.0
|
||||||
|
|
||||||
|
@export var drag_target: Node2D
|
||||||
|
|
||||||
|
var _is_dragging: bool = false
|
||||||
|
var _drag_offset: Vector2 = Vector2.ZERO
|
||||||
|
var _original_z_index: int = 0
|
||||||
|
var _original_scale: Vector2 = Vector2.ONE
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
if drag_target == null:
|
||||||
|
drag_target = get_parent() as Node2D
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if event is InputEventScreenTouch:
|
||||||
|
_handle_press(event.pressed, event.position)
|
||||||
|
elif event is InputEventScreenDrag and _is_dragging:
|
||||||
|
_move_to(event.position)
|
||||||
|
elif event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
|
_handle_press(event.pressed, event.position)
|
||||||
|
elif event is InputEventMouseMotion and _is_dragging:
|
||||||
|
_move_to(event.position)
|
||||||
|
|
||||||
|
|
||||||
|
func _handle_press(pressed: bool, screen_pos: Vector2) -> void:
|
||||||
|
if pressed and _is_position_over_target(screen_pos):
|
||||||
|
_start_drag(screen_pos)
|
||||||
|
elif not pressed and _is_dragging:
|
||||||
|
_end_drag(screen_pos)
|
||||||
|
|
||||||
|
|
||||||
|
func _start_drag(screen_pos: Vector2) -> void:
|
||||||
|
_is_dragging = true
|
||||||
|
var world_pos: Vector2 = _screen_to_world(screen_pos)
|
||||||
|
_drag_offset = drag_target.global_position - world_pos
|
||||||
|
_original_z_index = drag_target.z_index
|
||||||
|
_original_scale = drag_target.scale
|
||||||
|
drag_target.z_index = DRAG_Z_INDEX
|
||||||
|
drag_target.scale = _original_scale * DRAG_SCALE
|
||||||
|
drag_picked_up.emit(drag_target.global_position)
|
||||||
|
|
||||||
|
|
||||||
|
func _end_drag(_screen_pos: Vector2) -> void:
|
||||||
|
_is_dragging = false
|
||||||
|
drag_target.z_index = _original_z_index
|
||||||
|
drag_target.scale = _original_scale
|
||||||
|
drag_released.emit(drag_target.global_position)
|
||||||
|
|
||||||
|
|
||||||
|
func _move_to(screen_pos: Vector2) -> void:
|
||||||
|
var world_pos: Vector2 = _screen_to_world(screen_pos)
|
||||||
|
drag_target.global_position = world_pos + _drag_offset
|
||||||
|
|
||||||
|
|
||||||
|
func _screen_to_world(screen_pos: Vector2) -> Vector2:
|
||||||
|
var canvas_transform: Transform2D = drag_target.get_viewport().get_canvas_transform()
|
||||||
|
return canvas_transform.affine_inverse() * screen_pos
|
||||||
|
|
||||||
|
|
||||||
|
func _is_position_over_target(screen_pos: Vector2) -> bool:
|
||||||
|
if drag_target == null:
|
||||||
|
return false
|
||||||
|
var world_pos: Vector2 = _screen_to_world(screen_pos)
|
||||||
|
var local_pos: Vector2 = drag_target.to_local(world_pos)
|
||||||
|
var area: Area2D = drag_target.get_node_or_null("CollisionArea") as Area2D
|
||||||
|
if area == null:
|
||||||
|
return local_pos.length() < DEFAULT_DRAG_RADIUS
|
||||||
|
for child in area.get_children():
|
||||||
|
if child is CollisionShape2D and child.shape != null:
|
||||||
|
return child.shape.get_rect().has_point(local_pos)
|
||||||
|
return local_pos.length() < DEFAULT_DRAG_RADIUS
|
||||||
26
scripts/systems/hud.gd
Normal file
26
scripts/systems/hud.gd
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
## HUD — heads-up display with back button, music toggle, and settings access.
|
||||||
|
class_name HUD extends CanvasLayer
|
||||||
|
|
||||||
|
const MUSIC_ON_SYMBOL: String = "♪"
|
||||||
|
const MUSIC_OFF_SYMBOL: String = "✕"
|
||||||
|
|
||||||
|
var _music_enabled: bool = true
|
||||||
|
@onready var _settings_menu: SettingsMenu = get_node_or_null("../SettingsMenu") as SettingsMenu
|
||||||
|
|
||||||
|
|
||||||
|
func _on_back_button_pressed() -> void:
|
||||||
|
get_tree().quit()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_music_toggle_pressed() -> void:
|
||||||
|
_music_enabled = not _music_enabled
|
||||||
|
var volume: float = AudioManager.DEFAULT_MUSIC_VOLUME if _music_enabled else 0.0
|
||||||
|
AudioManager.set_music_volume(volume)
|
||||||
|
var btn: Button = get_node_or_null("MusicToggle") as Button
|
||||||
|
if btn != null:
|
||||||
|
btn.text = MUSIC_ON_SYMBOL if _music_enabled else MUSIC_OFF_SYMBOL
|
||||||
|
|
||||||
|
|
||||||
|
func _on_settings_button_pressed() -> void:
|
||||||
|
if _settings_menu != null:
|
||||||
|
_settings_menu.show_menu()
|
||||||
30
scripts/systems/room_navigator.gd
Normal file
30
scripts/systems/room_navigator.gd
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
## RoomNavigator — autoload that moves the Camera2D smoothly between hospital floors.
|
||||||
|
class_name RoomNavigator extends Node
|
||||||
|
|
||||||
|
signal room_changed(floor_index: int)
|
||||||
|
|
||||||
|
const FLOOR_HEIGHT: float = 720.0
|
||||||
|
const CAMERA_TWEEN_DURATION: float = 0.6
|
||||||
|
|
||||||
|
var _current_floor: int = 0
|
||||||
|
var _camera: Camera2D
|
||||||
|
|
||||||
|
|
||||||
|
func initialize(camera: Camera2D) -> void:
|
||||||
|
_camera = camera
|
||||||
|
|
||||||
|
|
||||||
|
func go_to_floor(floor_index: int) -> void:
|
||||||
|
if _camera == null or floor_index == _current_floor:
|
||||||
|
return
|
||||||
|
_current_floor = floor_index
|
||||||
|
var target_y: float = floor_index * -FLOOR_HEIGHT
|
||||||
|
var tween: Tween = create_tween()
|
||||||
|
tween.set_ease(Tween.EASE_IN_OUT)
|
||||||
|
tween.set_trans(Tween.TRANS_SINE)
|
||||||
|
tween.tween_property(_camera, "position:y", target_y, CAMERA_TWEEN_DURATION)
|
||||||
|
tween.finished.connect(func() -> void: room_changed.emit(floor_index))
|
||||||
|
|
||||||
|
|
||||||
|
func get_current_floor() -> int:
|
||||||
|
return _current_floor
|
||||||
39
scripts/systems/settings_menu.gd
Normal file
39
scripts/systems/settings_menu.gd
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
## SettingsMenu — overlay panel for audio volume and game reset.
|
||||||
|
class_name SettingsMenu extends CanvasLayer
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
|
||||||
|
func show_menu() -> void:
|
||||||
|
visible = true
|
||||||
|
|
||||||
|
|
||||||
|
func hide_menu() -> void:
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
|
||||||
|
func _on_music_slider_value_changed(value: float) -> void:
|
||||||
|
AudioManager.set_music_volume(value)
|
||||||
|
GameState.music_volume = value
|
||||||
|
|
||||||
|
|
||||||
|
func _on_sfx_slider_value_changed(value: float) -> void:
|
||||||
|
AudioManager.set_sfx_volume(value)
|
||||||
|
GameState.sfx_volume = value
|
||||||
|
|
||||||
|
|
||||||
|
func _on_reset_button_pressed() -> void:
|
||||||
|
var dialog: ConfirmationDialog = get_node_or_null("Panel/ResetConfirmDialog") as ConfirmationDialog
|
||||||
|
if dialog != null:
|
||||||
|
dialog.popup_centered()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_reset_confirmed() -> void:
|
||||||
|
SaveManager.reset_game()
|
||||||
|
get_tree().reload_current_scene()
|
||||||
|
|
||||||
|
|
||||||
|
func _on_close_button_pressed() -> void:
|
||||||
|
hide_menu()
|
||||||
Reference in New Issue
Block a user