From ad414a92327840a031537611d24da3212e3f0a06 Mon Sep 17 00:00:00 2001 From: Tomasz Boruc Date: Fri, 7 Nov 2025 17:59:16 +0100 Subject: [PATCH] Gracz +dane globalne gracza + panel --- project.godot | 1 + scenes/galaxy.tscn | 19 +++++++++---- scenes/menu.tscn | 56 ++++++++++++++++++------------------- scenes/planet.tscn | 8 +++--- scenes/planet_panel.tscn | 14 ++++++++-- scenes/top_panel.tscn | 36 ++++++++++++++++++++++++ scenes/ui/time_display.tscn | 12 ++++---- scripts/PlayerData.gd | 45 +++++++++++++++++++++++++++++ scripts/PlayerData.gd.uid | 1 + scripts/planet_panel.gd | 26 +++++++++++++++++ scripts/technologies.gd | 28 +++++++++++++++++++ scripts/technologies.gd.uid | 1 + scripts/top_panel.gd | 27 ++++++++++++++++++ scripts/top_panel.gd.uid | 1 + 14 files changed, 228 insertions(+), 47 deletions(-) create mode 100644 scenes/top_panel.tscn create mode 100644 scripts/PlayerData.gd create mode 100644 scripts/PlayerData.gd.uid create mode 100644 scripts/technologies.gd create mode 100644 scripts/technologies.gd.uid create mode 100644 scripts/top_panel.gd create mode 100644 scripts/top_panel.gd.uid diff --git a/project.godot b/project.godot index 6f8d304..4be5fdf 100644 --- a/project.godot +++ b/project.godot @@ -23,6 +23,7 @@ ObjectNames="*res://scripts/ObjectNames.gd" Settings="*res://scripts/settings.gd" GameData="*res://scripts/GameData.gd" BuildingsList="*res://scripts/BuildingsList.gd" +PlayerData="*res://scripts/PlayerData.gd" [display] diff --git a/scenes/galaxy.tscn b/scenes/galaxy.tscn index 4075203..0337a07 100644 --- a/scenes/galaxy.tscn +++ b/scenes/galaxy.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://b1vxl6rs5odt1"] +[gd_scene load_steps=9 format=3 uid="uid://b1vxl6rs5odt1"] [ext_resource type="Script" uid="uid://cts6e8xmnqsax" path="res://scripts/galaxy.gd" id="1_jxn3g"] [ext_resource type="PackedScene" uid="uid://bbgymc0drqpbx" path="res://scenes/ui/time_display.tscn" id="3_fmtwf"] @@ -7,6 +7,7 @@ [ext_resource type="Texture2D" uid="uid://bvucvdvh00uaw" path="res://assets/background/galback1.jpg" id="5_xhm0b"] [ext_resource type="Script" uid="uid://dpwk3ruw8mx6k" path="res://scripts/background.gd" id="6_xhm0b"] [ext_resource type="PackedScene" uid="uid://dgxm8txsiukwf" path="res://scenes/planet_panel.tscn" id="7_xhm0b"] +[ext_resource type="PackedScene" uid="uid://c405r414rsut2" path="res://scenes/top_panel.tscn" id="8_0pfb5"] [node name="Galaxy" type="Node2D"] script = ExtResource("1_jxn3g") @@ -44,17 +45,16 @@ offset = Vector2(50, 50) transform = Transform2D(1, 0, 0, 1, 50, 50) [node name="PlanetPanel" parent="UI" instance=ExtResource("7_xhm0b")] -visible = false show_behind_parent = true anchors_preset = 0 anchor_left = 0.0 anchor_top = 0.0 anchor_right = 0.0 anchor_bottom = 0.0 -offset_left = 1814.0 -offset_top = 38.0 -offset_right = 2422.0 -offset_bottom = 774.0 +offset_left = 1758.0 +offset_top = 30.0 +offset_right = 2418.0 +offset_bottom = 1086.0 grow_vertical = 1 size_flags_horizontal = 4 size_flags_vertical = 4 @@ -71,3 +71,10 @@ offset_left = 2144.0 offset_top = 8.0 offset_right = -80.0 offset_bottom = -1384.0 + +[node name="TopPanel" parent="UI" instance=ExtResource("8_0pfb5")] +offset_left = -18.0 +offset_top = -26.0 +offset_right = 2022.0 +offset_bottom = 78.0 +size_flags_horizontal = 0 diff --git a/scenes/menu.tscn b/scenes/menu.tscn index c60a390..ae1a2ca 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -139,22 +139,6 @@ tracks/1/keys = { "values": [Vector2(159, 559)] } -[sub_resource type="Animation" id="Animation_i42df"] -resource_name = "ship_move" -length = 400.0 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:position") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 400), -"transitions": PackedFloat32Array(1, 1), -"update": 0, -"values": [Vector2(334, 276), Vector2(627.99994, 274)] -} - [sub_resource type="Animation" id="Animation_3dmrc"] resource_name = "moon_move" length = 360.0 @@ -187,6 +171,22 @@ tracks/0/keys = { "values": [Vector2(159, 559), Vector2(1580, 544)] } +[sub_resource type="Animation" id="Animation_i42df"] +resource_name = "ship_move" +length = 400.0 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:position") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 400), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [Vector2(334, 276), Vector2(627.99994, 274)] +} + [sub_resource type="AnimationLibrary" id="AnimationLibrary_mxgkd"] _data = { &"RESET": SubResource("Animation_7jp70"), @@ -294,9 +294,9 @@ offset_left = 6.6666603 offset_top = 6.6665955 offset_right = 1986.6665 offset_bottom = 293.3331 -theme_override_colors/font_color = Color(0.073123895, 0.0037705752, 0.025873708, 1) +theme_override_colors/font_color = Color(0.8332006, 0.92088926, 0.87072945, 1) theme_override_colors/font_shadow_color = Color(0.7570387, 0.75415635, 0.7885611, 0) -theme_override_colors/font_outline_color = Color(0.02877314, 0.7656168, 0.72319645, 0.53333336) +theme_override_colors/font_outline_color = Color(0.48479164, 0.1642021, 0.09600546, 0.53333336) theme_override_constants/shadow_offset_y = 0 theme_override_constants/outline_size = 23 theme_override_fonts/font = ExtResource("6_i6lef") @@ -322,9 +322,9 @@ offset_left = 6.6666718 offset_top = 6.6664734 offset_right = 1999.9999 offset_bottom = 293.33298 -theme_override_colors/font_color = Color(0.073123895, 0.0037705752, 0.025873708, 1) +theme_override_colors/font_color = Color(0.8332006, 0.92088926, 0.87072945, 1) theme_override_colors/font_shadow_color = Color(0.7570387, 0.75415635, 0.7885611, 0) -theme_override_colors/font_outline_color = Color(0.02877314, 0.7656168, 0.72319645, 0.53333336) +theme_override_colors/font_outline_color = Color(0.48479164, 0.1642021, 0.09600546, 0.53333336) theme_override_constants/shadow_offset_y = 0 theme_override_constants/outline_size = 23 theme_override_fonts/font = ExtResource("6_i6lef") @@ -357,9 +357,9 @@ offset_right = 993.33325 offset_bottom = 143.33337 grow_horizontal = 2 grow_vertical = 2 -theme_override_colors/font_color = Color(0.073123895, 0.0037705752, 0.025873708, 1) +theme_override_colors/font_color = Color(0.8332006, 0.92088926, 0.87072945, 1) theme_override_colors/font_shadow_color = Color(0, 0, 0, 0) -theme_override_colors/font_outline_color = Color(0.02877314, 0.7656168, 0.72319645, 0.53333336) +theme_override_colors/font_outline_color = Color(0.48479164, 0.1642021, 0.09600546, 0.53333336) theme_override_constants/outline_size = 23 theme_override_fonts/font = ExtResource("6_i6lef") theme_override_font_sizes/font_size = 200 @@ -391,9 +391,9 @@ offset_right = 986.6666 offset_bottom = 143.33337 grow_horizontal = 2 grow_vertical = 2 -theme_override_colors/font_color = Color(0.073123895, 0.0037705752, 0.025873708, 1) +theme_override_colors/font_color = Color(0.8332006, 0.92088926, 0.87072945, 1) theme_override_colors/font_shadow_color = Color(0.7570387, 0.75415635, 0.7885611, 0) -theme_override_colors/font_outline_color = Color(0.02877314, 0.7656168, 0.72319645, 0.53333336) +theme_override_colors/font_outline_color = Color(0.48479164, 0.1642021, 0.09600546, 0.53333336) theme_override_constants/shadow_offset_y = 0 theme_override_constants/outline_size = 23 theme_override_fonts/font = ExtResource("6_i6lef") @@ -426,9 +426,9 @@ offset_right = 993.33325 offset_bottom = 143.33337 grow_horizontal = 2 grow_vertical = 2 -theme_override_colors/font_color = Color(0.073123895, 0.0037705752, 0.025873708, 1) +theme_override_colors/font_color = Color(0.8332006, 0.92088926, 0.87072945, 1) theme_override_colors/font_shadow_color = Color(0.7570387, 0.75415635, 0.7885611, 0) -theme_override_colors/font_outline_color = Color(0.02877314, 0.7656168, 0.72319645, 0.53333336) +theme_override_colors/font_outline_color = Color(0.48479164, 0.1642021, 0.09600546, 0.53333336) theme_override_constants/shadow_offset_y = 0 theme_override_constants/outline_size = 23 theme_override_fonts/font = ExtResource("6_i6lef") @@ -461,9 +461,9 @@ offset_right = 993.33325 offset_bottom = 156.66672 grow_horizontal = 2 grow_vertical = 2 -theme_override_colors/font_color = Color(0.073123895, 0.0037705752, 0.025873708, 1) +theme_override_colors/font_color = Color(0.8332006, 0.92088926, 0.87072945, 1) theme_override_colors/font_shadow_color = Color(0.7570387, 0.75415635, 0.7885611, 0) -theme_override_colors/font_outline_color = Color(0.02877314, 0.7656168, 0.72319645, 0.53333336) +theme_override_colors/font_outline_color = Color(0.48479164, 0.1642021, 0.09600546, 0.53333336) theme_override_constants/shadow_offset_y = 0 theme_override_constants/outline_size = 23 theme_override_fonts/font = ExtResource("6_i6lef") diff --git a/scenes/planet.tscn b/scenes/planet.tscn index 94e9d46..f42df65 100644 --- a/scenes/planet.tscn +++ b/scenes/planet.tscn @@ -37,10 +37,10 @@ vertical_alignment = 1 [node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="Info" type="Label" parent="CanvasLayer"] -offset_left = 16.0 -offset_top = 32.0 -offset_right = 375.0 -offset_bottom = 215.0 +offset_left = 14.0 +offset_top = 114.0 +offset_right = 373.0 +offset_bottom = 297.0 theme_override_colors/font_outline_color = Color(0, 0, 0, 1) theme_override_constants/outline_size = 1 theme_override_fonts/font = ExtResource("3_ggt7d") diff --git a/scenes/planet_panel.tscn b/scenes/planet_panel.tscn index c3a15f7..a6b395a 100644 --- a/scenes/planet_panel.tscn +++ b/scenes/planet_panel.tscn @@ -23,8 +23,8 @@ anchor_right = 0.499 anchor_bottom = 0.37300003 offset_left = -612.44006 offset_top = -241.70401 -offset_right = -186.44006 -offset_bottom = 259.87994 +offset_right = 47.559937 +offset_bottom = 259.88 grow_vertical = 2 size_flags_horizontal = 0 size_flags_vertical = 0 @@ -46,7 +46,7 @@ horizontal_alignment = 1 layout_mode = 0 offset_left = 5.0 offset_top = 23.0 -offset_right = 419.0 +offset_right = 373.0 offset_bottom = 305.58395 theme_override_fonts/font = ExtResource("2_sqypy") theme_override_font_sizes/font_size = 16 @@ -80,4 +80,12 @@ grow_horizontal = 0 theme_override_font_sizes/font_size = 7 text = "X" +[node name="SendButton" type="Button" parent="."] +layout_mode = 0 +offset_left = 495.0 +offset_top = 5.583954 +offset_right = 617.0 +offset_bottom = 36.583954 +text = "Wyślij surowce" + [connection signal="pressed" from="Button" to="." method="_on_button_pressed"] diff --git a/scenes/top_panel.tscn b/scenes/top_panel.tscn new file mode 100644 index 0000000..fd3877b --- /dev/null +++ b/scenes/top_panel.tscn @@ -0,0 +1,36 @@ +[gd_scene load_steps=2 format=3 uid="uid://c405r414rsut2"] + +[ext_resource type="Script" uid="uid://c5s1b0ctj8pvl" path="res://scripts/top_panel.gd" id="1_85l1y"] + +[node name="TopPanel" type="Control"] +layout_mode = 3 +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("1_85l1y") + +[node name="HBoxContainer" type="HBoxContainer" parent="."] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +theme_override_constants/separation = 10 + +[node name="PlayerName" type="Label" parent="HBoxContainer"] +layout_mode = 2 +text = "Player name" + +[node name="IronLabel" type="Label" parent="HBoxContainer"] +layout_mode = 2 +text = "ddfdf" + +[node name="WaterLabel" type="Label" parent="HBoxContainer"] +layout_mode = 2 +text = "ddfdf" + +[node name="CopperLabel" type="Label" parent="HBoxContainer"] +layout_mode = 2 +text = "ddfdf" + +[node name="Technologies" type="Button" parent="HBoxContainer"] +layout_mode = 2 +text = "Technologies" diff --git a/scenes/ui/time_display.tscn b/scenes/ui/time_display.tscn index 6ec7ef1..cf093d3 100644 --- a/scenes/ui/time_display.tscn +++ b/scenes/ui/time_display.tscn @@ -28,9 +28,9 @@ text = "time_display" [node name="pause" type="Button" parent="."] layout_mode = 0 -offset_left = 7.0 +offset_left = -9.0 offset_top = 2.0 -offset_right = 34.0 +offset_right = 18.0 offset_bottom = 55.0 scale = Vector2(0.5, 0.5) theme_override_colors/font_color = Color(0.80287457, 0.40096578, 0.15050122, 1) @@ -40,9 +40,9 @@ text = "II" [node name="faster" type="Button" parent="."] layout_mode = 0 -offset_left = 24.0 +offset_left = 8.0 offset_top = 2.0 -offset_right = 50.0 +offset_right = 34.0 offset_bottom = 55.0 scale = Vector2(0.5, 0.5) theme_override_colors/font_color = Color(0.80287457, 0.40096578, 0.15050122, 1) @@ -52,9 +52,9 @@ text = ">" [node name="slower" type="Button" parent="."] layout_mode = 0 -offset_left = -8.0 +offset_left = -24.0 offset_top = 2.0 -offset_right = 18.0 +offset_right = 2.0 offset_bottom = 55.0 scale = Vector2(0.5, 0.5) theme_override_colors/font_color = Color(0.80287457, 0.40096578, 0.15050122, 1) diff --git a/scripts/PlayerData.gd b/scripts/PlayerData.gd new file mode 100644 index 0000000..6c5341c --- /dev/null +++ b/scripts/PlayerData.gd @@ -0,0 +1,45 @@ +extends Node + + +signal stats_changed +# Dane podstawowe +var PlayerName: String = "Tirith" +var race: String = "Ludzie" + +# Zasoby globalne +var resources := { + "iron": 0.0, + "copper": 0.0, + "water": 0.0, + "carbon": 0.0, + "aluminium": 0.0, + "silicon": 0.0, + "titanium": 0.0, + "uranium": 0.0, + "platinum": 0.0, + "helium_3": 0.0, + "neutronium": 0.0, + "quantium": 0.0, + "aetherium": 0.0, + "stardust": 0.0, + "xenonite": 0.0, + "solarium": 0.0, + "chronite": 0.0, +} + +var science_points: float = 0.0 + +# Technologie odkryte +var discovered_technologies: Array = [] + +# Lista skolonizowanych planet +var planets: Array = [] + + + +# Możesz też trzymać globalne modyfikatory +var global_modifiers = { + "water_efficiency": 1.0, + "population_growth": 1.0, + "resource_bonus": 1.0, +} diff --git a/scripts/PlayerData.gd.uid b/scripts/PlayerData.gd.uid new file mode 100644 index 0000000..d387791 --- /dev/null +++ b/scripts/PlayerData.gd.uid @@ -0,0 +1 @@ +uid://bvcecdv1r6plv diff --git a/scripts/planet_panel.gd b/scripts/planet_panel.gd index 0c5cc9c..31cc1ee 100644 --- a/scripts/planet_panel.gd +++ b/scripts/planet_panel.gd @@ -3,7 +3,13 @@ extends Panel @onready var name_label = $Name_Label @onready var info_label = $Info_Label @onready var buildings_container = $Buildings +@onready var send_button = $SendButton + +func _ready(): + send_button.connect("pressed", Callable(self, "_on_send_resources_pressed")) + + var planet: Planet = null func _process(delta: float) -> void: _update_info() @@ -85,3 +91,23 @@ func _on_building_pressed(b_id): func _on_button_pressed() -> void: hide_panel() +#do usuniecia po testach +func _on_send_resources_pressed(): + + if not planet: + return + + for res_name in planet.resources.keys(): + var res = planet.resources[res_name] + if res.has("amount") and res["amount"] > 0: + # Jeżeli gracz ma ten typ zasobu, dodaj + if PlayerData.resources.has(res_name): + PlayerData.resources[res_name] += res["amount"] + res["amount"] = 0 + planet.resources[res_name] = res + PlayerData.emit_signal("stats_changed") +# Emituj sygnał tylko raz, po zakończeniu pętli + + + + diff --git a/scripts/technologies.gd b/scripts/technologies.gd new file mode 100644 index 0000000..7bf2dad --- /dev/null +++ b/scripts/technologies.gd @@ -0,0 +1,28 @@ +extends Node + +const TECHNOLOGIES = { + "advance_mining": { + "name": "Advance Mining", + "description": "Allow mining resources", + "cost": { + "science": 100, + "iron": 50 + }, + "unlock_effects": { + + }, + "unlocks_buildings": ["uran_mine", "copper_mine", "aluminium_mine"], + "requires": [] + }, + "hydro_engineering": { + "name": "Inżynieria Hydrotermalna", + "description": "Zwiększa wydobycie wody o 15%.", + "cost": { + "science": 200 + }, + "unlock_effects": { + "water_efficiency": 1.15 + }, + "requires": ["bio_dome"] + } +} diff --git a/scripts/technologies.gd.uid b/scripts/technologies.gd.uid new file mode 100644 index 0000000..51b8878 --- /dev/null +++ b/scripts/technologies.gd.uid @@ -0,0 +1 @@ +uid://cj2qqev44b84d diff --git a/scripts/top_panel.gd b/scripts/top_panel.gd new file mode 100644 index 0000000..99c71bd --- /dev/null +++ b/scripts/top_panel.gd @@ -0,0 +1,27 @@ +extends Control + +@onready var label_player_name = $HBoxContainer/PlayerName +#@onready var label_science = $HBoxContainer/LabelScience +@onready var label_iron = $HBoxContainer/IronLabel +@onready var label_water = $HBoxContainer/WaterLabel +@onready var label_copper = $HBoxContainer/CopperLabel +#@onready var label_population = $HBoxContainer/LabelPopulation + +func update_info(): + + label_player_name.text = "Gracz: %s" % PlayerData.PlayerName +#label_science.text = "🔬 Nauka: %s" % player.science + + label_iron.text = "%s: %.2f" % [tr("Iron"), PlayerData.resources.iron] + label_water.text = "%s: %.2f" % [tr("Water"), PlayerData.resources.water] + label_copper.text = "%s: %.2f" % [tr("Copper"), PlayerData.resources.copper] + + + #label_population.text = "👥 Populacja: %s" % GameData.format_number(player.total_population) + +func _ready(): + PlayerData.connect("stats_changed", Callable(self, "update_info")) + update_info() + +func _on_stats_changed(): + update_info() diff --git a/scripts/top_panel.gd.uid b/scripts/top_panel.gd.uid new file mode 100644 index 0000000..1d14efc --- /dev/null +++ b/scripts/top_panel.gd.uid @@ -0,0 +1 @@ +uid://c5s1b0ctj8pvl