diff --git a/assets/tech/Mining_Drill.png b/assets/tech/Mining_Drill.png new file mode 100644 index 0000000..59a9e88 Binary files /dev/null and b/assets/tech/Mining_Drill.png differ diff --git a/assets/tech/Mining_Drill.png.import b/assets/tech/Mining_Drill.png.import new file mode 100644 index 0000000..2b3bd96 --- /dev/null +++ b/assets/tech/Mining_Drill.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dplqsugnrtulx" +path="res://.godot/imported/Mining_Drill.png-965e33f1799d1fcba2eed57398f01552.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/tech/Mining_Drill.png" +dest_files=["res://.godot/imported/Mining_Drill.png-965e33f1799d1fcba2eed57398f01552.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/tech/hydro_engineering.png b/assets/tech/hydro_engineering.png new file mode 100644 index 0000000..0d8933c Binary files /dev/null and b/assets/tech/hydro_engineering.png differ diff --git a/assets/tech/hydro_engineering.png.import b/assets/tech/hydro_engineering.png.import new file mode 100644 index 0000000..b5a0c0e --- /dev/null +++ b/assets/tech/hydro_engineering.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b1oq5if3q10cl" +path="res://.godot/imported/hydro_engineering.png-e5e5223033b866912fa52717933d75b4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/tech/hydro_engineering.png" +dest_files=["res://.godot/imported/hydro_engineering.png-e5e5223033b866912fa52717933d75b4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/galaxy.tscn b/scenes/galaxy.tscn index 17a94ea..d859a81 100644 --- a/scenes/galaxy.tscn +++ b/scenes/galaxy.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=9 format=3 uid="uid://b1vxl6rs5odt1"] +[gd_scene load_steps=10 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"] @@ -8,6 +8,7 @@ [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"] +[ext_resource type="PackedScene" uid="uid://bitiuqh8lb0ga" path="res://scenes/tech_panel.tscn" id="9_lwv00"] [node name="Galaxy" type="Node2D"] script = ExtResource("1_jxn3g") @@ -79,3 +80,10 @@ offset_top = -26.0 offset_right = 2022.0 offset_bottom = 78.0 size_flags_horizontal = 0 + +[node name="TechPanel" parent="UI" instance=ExtResource("9_lwv00")] +visible = false +offset_left = -1023.44006 +offset_top = -507.12006 +offset_right = -367.44006 +offset_bottom = -331.12006 diff --git a/scenes/tech_panel.tscn b/scenes/tech_panel.tscn new file mode 100644 index 0000000..69382f8 --- /dev/null +++ b/scenes/tech_panel.tscn @@ -0,0 +1,67 @@ +[gd_scene load_steps=4 format=3 uid="uid://bitiuqh8lb0ga"] + +[ext_resource type="Script" uid="uid://bsdypct22eu23" path="res://scripts/tech_panel.gd" id="1_qc7t1"] +[ext_resource type="FontFile" uid="uid://chk8jrn2ighpx" path="res://assets/fonts/main_font.ttf" id="2_5new4"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_sqypy"] +bg_color = Color(0.69411767, 0.32156864, 0.08235294, 0.37254903) +border_width_left = 1 +border_width_top = 1 +border_width_right = 1 +border_width_bottom = 1 +border_color = Color(0.7988825, 0.55350196, 0.19976625, 1) +corner_radius_top_left = 2 +corner_radius_top_right = 2 +corner_radius_bottom_right = 2 +corner_radius_bottom_left = 2 + +[node name="TechPanel" type="Panel"] +anchors_preset = -1 +anchor_left = 0.499 +anchor_top = 0.37300003 +anchor_right = 0.499 +anchor_bottom = 0.37300003 +offset_left = -612.44006 +offset_top = -241.70401 +offset_right = 47.559937 +offset_bottom = 259.88 +grow_vertical = 2 +size_flags_horizontal = 0 +size_flags_vertical = 0 +theme_override_styles/panel = SubResource("StyleBoxFlat_sqypy") +script = ExtResource("1_qc7t1") + +[node name="Tech_Label" type="Label" parent="."] +layout_mode = 0 +offset_left = 5.0 +offset_top = 3.0 +offset_right = 393.0 +offset_bottom = 24.0 +theme_override_fonts/font = ExtResource("2_5new4") +theme_override_font_sizes/font_size = 16 +text = "Technologie" +horizontal_alignment = 1 + +[node name="Technologies" type="GridContainer" parent="."] +layout_mode = 1 +anchors_preset = 12 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 15.0 +offset_top = -56.0 +offset_right = -11.0 +offset_bottom = -8.0 +grow_horizontal = 2 +grow_vertical = 0 +columns = 4 + +[node name="Button" type="Button" parent="."] +layout_mode = 0 +offset_left = 614.0 +offset_top = 6.583954 +offset_right = 653.0 +offset_bottom = 39.167908 +text = "X" + +[connection signal="pressed" from="Button" to="." method="_on_button_pressed"] diff --git a/scripts/PlayerData.gd b/scripts/PlayerData.gd index bf6482a..e526f88 100644 --- a/scripts/PlayerData.gd +++ b/scripts/PlayerData.gd @@ -8,7 +8,7 @@ var race: String = "Ludzie" # Zasoby globalne var resources := { - "iron": 0.0, + "iron": 11.0, "copper": 0.0, "water": 0.0, "carbon": 0.0, @@ -27,10 +27,10 @@ var resources := { "chronite": 0.0, } -var since_doc: float = 0.0 +var since_doc: float = 2.0 # Technologie odkryte -var unlocked_techs = ["advanced_mining"] +var unlocked_techs = [] # Lista skolonizowanych planet diff --git a/scripts/galaxy.gd b/scripts/galaxy.gd index e9a6b3f..f729496 100644 --- a/scripts/galaxy.gd +++ b/scripts/galaxy.gd @@ -5,6 +5,9 @@ extends Node2D @onready var MenuScene = preload("res://scenes/menu.tscn") @onready var camera = $Camera2D @onready var TimeDispaly = $CanvasLayer2 +@onready var tech_button = $UI/TopPanel/HBoxContainer/Technologies + +@onready var tech_panel = $UI/TechPanel # to Twoja scena z technologiami var existing_star_positions: Array[Vector2] = [] @@ -17,6 +20,16 @@ func _ready(): GameData.game_lunched = true + tech_button.connect("pressed", Callable(self, "_on_technologies_button_pressed")) + tech_panel.hide() # domyślnie ukryty + +func _on_technologies_button_pressed(): + # Przełącz widoczność panelu + tech_panel.visible = not tech_panel.visible + + # (Opcjonalnie) odśwież listę technologii za każdym razem, gdy panel się pokazuje + if tech_panel.visible and tech_panel.has_method("_create_technology_buttons"): + tech_panel._create_technology_buttons() func _process(delta): var zoom_level = (camera.zoom.x + camera.zoom.y) / 2.0 diff --git a/scripts/tech_panel.gd b/scripts/tech_panel.gd new file mode 100644 index 0000000..e1d5053 --- /dev/null +++ b/scripts/tech_panel.gd @@ -0,0 +1,122 @@ +extends Panel + +@onready var tech_container = $Technologies + + + +# Ścieżka do tekstur technologii (tu możesz dać swoje grafiki) +const DEFAULT_ICON = preload("res://assets/tech/Mining_Drill.png") + +func _ready(): + _create_technology_buttons() + + +func _create_technology_buttons(): + # Wyczyść stare przyciski + for c in tech_container.get_children(): + c.queue_free() + + for tech_id in Technologies.TECHNOLOGIES.keys(): + var tech = Technologies.TECHNOLOGIES[tech_id] + var btn = TextureButton.new() + + # 🔹 Ustaw ikonę technologii z pola "texture" + if tech.has("texture") and tech.texture != "": + btn.texture_normal = load(tech.texture) + else: + # Fallback na domyślną ikonę, jeśli brak tekstury w danych + btn.texture_normal = DEFAULT_ICON + + btn.custom_minimum_size = Vector2(96, 96) + + btn.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT_CENTERED + + # 🔹 Tooltip z opisem i kosztami + var cost_text = "" + for cost_name in tech.cost.keys(): + cost_text += "%s: %d " % [tr(cost_name), tech.cost[cost_name]] + + btn.tooltip_text = "%s\n%s\n%s %s" % [ + tr(tech.name), + tr(tech.description), + tr("Koszt:"), + cost_text.strip_edges() + ] + + # 🔹 Jeśli gracz już ma tę technologię + if tech_id in PlayerData.unlocked_techs: + btn.modulate = Color(0.6, 0.6, 0.6) # wyszarz + btn.disabled = true + btn.tooltip_text += "\n[✓] " + tr("Odkryta") + + # 🔹 Jeśli brakuje wymaganych technologii + elif not _check_requirements(tech.requires): + btn.modulate = Color(0.5, 0.5, 0.5) + btn.disabled = true + btn.tooltip_text += "\n[!] " + tr("Wymagania niespełnione") + + else: + # 🔹 Po kliknięciu rozpocznij badanie technologii + btn.connect("pressed", Callable(self, "_on_technology_pressed").bind(tech_id)) + + tech_container.add_child(btn) + + + +func _check_requirements(requirements: Array) -> bool: + if requirements.is_empty(): + return true + for req in requirements: + if req not in PlayerData.unlocked_techs: + return false + return true + + +func _on_technology_pressed(tech_id): + var tech = Technologies.TECHNOLOGIES[tech_id] + + # Jeśli gracz już ma tę technologię — nic nie rób + if tech_id in PlayerData.unlocked_techs: + print("Gracz już ma technologię:", tech_id) + return + + # Sprawdź wymagania + for req in tech.requires: + if req not in PlayerData.unlocked_techs: + print("Brak wymaganej technologii:", req) + return + + # Sprawdź, czy gracz ma wystarczające zasoby i naukę + for cost_name in tech.cost.keys(): + var required_amount = tech.cost[cost_name] + var has_enough = false + + if cost_name == "science": + has_enough = PlayerData.since_doc >= required_amount + else: + if PlayerData.resources.has(cost_name): + has_enough = PlayerData.resources[cost_name] >= required_amount + + if not has_enough: + print("Brak zasobu:", cost_name) + return + + # Odejmij koszty + for cost_name in tech.cost.keys(): + if cost_name == "science": + PlayerData.since_doc -= tech.cost[cost_name] + else: + PlayerData.resources[cost_name] -= tech.cost[cost_name] + + # Dodaj technologię do odblokowanych + PlayerData.unlocked_techs.append(tech_id) + print("Odblokowano technologię:", tech.name) + + # Opcjonalnie: powiadom o zmianach + PlayerData.emit_signal("stats_changed") + + _create_technology_buttons() + + +func _on_button_pressed() -> void: + hide() diff --git a/scripts/tech_panel.gd.uid b/scripts/tech_panel.gd.uid new file mode 100644 index 0000000..48a4319 --- /dev/null +++ b/scripts/tech_panel.gd.uid @@ -0,0 +1 @@ +uid://bsdypct22eu23 diff --git a/scripts/technologies.gd b/scripts/technologies.gd index 6bd7541..961ba4d 100644 --- a/scripts/technologies.gd +++ b/scripts/technologies.gd @@ -1,14 +1,15 @@ extends Node const TECHNOLOGIES = { - "advance_mining": { - "name": "Advance Mining", + "advanced_mining": { + "name": "Advanced Mining", "description": "Allow mining resources", "time": 10, "cost": { - "science": 100, - "iron": 50 + "science": 1, + "iron": 5 }, + "texture": "res://assets/tech/Mining_Drill.png", "unlock_effects": { }, @@ -20,11 +21,12 @@ const TECHNOLOGIES = { "description": "Zwiększa wydobycie wody o 15%.", "time": 10, "cost": { - "science": 200 + "science": 1 }, + "texture": "res://assets/tech/hydro_engineering.png", "unlock_effects": { "water_efficiency": 1.15 }, - "requires": ["bio_dome"] + "requires": ["advanced_mining"] } }