diff --git a/assets/tech/terraforming.png b/assets/tech/terraforming.png new file mode 100644 index 0000000..c64fb3f Binary files /dev/null and b/assets/tech/terraforming.png differ diff --git a/assets/tech/terraforming.png.import b/assets/tech/terraforming.png.import new file mode 100644 index 0000000..9ba5824 --- /dev/null +++ b/assets/tech/terraforming.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://w5towk2sfjfo" +path="res://.godot/imported/terraforming.png-1954eff5d8d95abd1e9b21927440fa2d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/tech/terraforming.png" +dest_files=["res://.godot/imported/terraforming.png-1954eff5d8d95abd1e9b21927440fa2d.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 d859a81..dc88a3d 100644 --- a/scenes/galaxy.tscn +++ b/scenes/galaxy.tscn @@ -77,13 +77,12 @@ 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 +offset_right = 1574.0 +offset_bottom = 142.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 +offset_left = -1031.4401 +offset_top = -379.12006 +offset_right = -375.44006 +offset_bottom = -203.12006 diff --git a/scenes/star.tscn b/scenes/star.tscn index 821ae5e..19ec1fa 100644 --- a/scenes/star.tscn +++ b/scenes/star.tscn @@ -1,10 +1,13 @@ -[gd_scene load_steps=5 format=3 uid="uid://cvc0brcqh2rhu"] +[gd_scene load_steps=6 format=3 uid="uid://cvc0brcqh2rhu"] [ext_resource type="Script" uid="uid://c7l387xor12hx" path="res://scripts/star.gd" id="1_mcqwg"] [ext_resource type="Texture2D" uid="uid://dsfxgajg3jodv" path="res://assets/stars/s3.png" id="2_8d8bx"] [ext_resource type="Script" uid="uid://bgghdcbxp6o0k" path="res://scripts/star_sprite.gd" id="3_ef0hr"] [ext_resource type="FontFile" uid="uid://chk8jrn2ighpx" path="res://assets/fonts/main_font.ttf" id="4_8d8bx"] +[sub_resource type="CircleShape2D" id="CircleShape2D_8d8bx"] +radius = 614.64 + [node name="Star" type="Node2D"] script = ExtResource("1_mcqwg") @@ -13,6 +16,11 @@ scale = Vector2(0.0371471, 0.0371471) texture = ExtResource("2_8d8bx") script = ExtResource("3_ef0hr") +[node name="Area2D" type="Area2D" parent="Sprite2D"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Sprite2D/Area2D"] +shape = SubResource("CircleShape2D_8d8bx") + [node name="Label" type="Label" parent="."] offset_left = -53.0 offset_top = 34.0 diff --git a/scenes/station.tscn b/scenes/station.tscn new file mode 100644 index 0000000..31457c4 --- /dev/null +++ b/scenes/station.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://bhuvrdvcm6exi"] + +[ext_resource type="Texture2D" uid="uid://c1npf2gngyyxp" path="res://assets/buildings/starbase.png" id="1_rod8h"] + +[node name="Station" type="Node2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(0.023437498, 0.023437498) +texture = ExtResource("1_rod8h") diff --git a/scenes/tech_panel.tscn25828147014.tmp b/scenes/tech_panel.tscn25828147014.tmp new file mode 100644 index 0000000..69382f8 --- /dev/null +++ b/scenes/tech_panel.tscn25828147014.tmp @@ -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/scenes/top_panel.tscn b/scenes/top_panel.tscn index fe5d9ea..55689f2 100644 --- a/scenes/top_panel.tscn +++ b/scenes/top_panel.tscn @@ -19,15 +19,17 @@ theme_override_constants/separation = 10 layout_mode = 2 text = "Player name" -[node name="IronLabel" type="Label" parent="HBoxContainer"] +[node name="ResLabel" type="Label" parent="HBoxContainer"] layout_mode = 2 text = "ddfdf" [node name="WaterLabel" type="Label" parent="HBoxContainer"] +visible = false layout_mode = 2 text = "ddfdf" [node name="CopperLabel" type="Label" parent="HBoxContainer"] +visible = false layout_mode = 2 text = "ddfdf" @@ -36,5 +38,6 @@ layout_mode = 2 text = "Technologies" [node name="SinceLabel" type="Label" parent="HBoxContainer"] +visible = false layout_mode = 2 text = "ddfdf" diff --git a/scenes/top_panel.tscn22481600950.tmp b/scenes/top_panel.tscn22481600950.tmp new file mode 100644 index 0000000..55689f2 --- /dev/null +++ b/scenes/top_panel.tscn22481600950.tmp @@ -0,0 +1,43 @@ +[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="ResLabel" type="Label" parent="HBoxContainer"] +layout_mode = 2 +text = "ddfdf" + +[node name="WaterLabel" type="Label" parent="HBoxContainer"] +visible = false +layout_mode = 2 +text = "ddfdf" + +[node name="CopperLabel" type="Label" parent="HBoxContainer"] +visible = false +layout_mode = 2 +text = "ddfdf" + +[node name="Technologies" type="Button" parent="HBoxContainer"] +layout_mode = 2 +text = "Technologies" + +[node name="SinceLabel" type="Label" parent="HBoxContainer"] +visible = false +layout_mode = 2 +text = "ddfdf" diff --git a/scripts/BuildingsList.gd b/scripts/BuildingsList.gd index 3564953..e8ceb31 100644 --- a/scripts/BuildingsList.gd +++ b/scripts/BuildingsList.gd @@ -71,7 +71,7 @@ var BUILDINGS = { "cost": {"iron": 10}, "build_time": 5.0, "texture": "res://assets/buildings/terraforming_center.png", - "required_tech": null + "required_tech": "terraforming" }, "laboratory": { "name": "Laboratory", @@ -84,6 +84,17 @@ var BUILDINGS = { "build_time": 5.0, "texture": "res://assets/buildings/labolatory.png", "required_tech": null + }, + + "aluminium_ore_mine": { + "name": "Aluminium ore mine", + "description": "Wydobywa boksyt.", + "resource": "aluminium", + "cost": {"iron": 100, "copper": 100}, + "bonuses": {"biosfere": 0.1}, + "build_time": 15.0, + "texture": "res://assets/buildings/aluminium_ore_mine.png", + "required_tech": "advanced_mining" } } diff --git a/scripts/GameData.gd b/scripts/GameData.gd index 4641bea..2ee52ca 100644 --- a/scripts/GameData.gd +++ b/scripts/GameData.gd @@ -24,3 +24,4 @@ func format_number(num: int) -> String: if count % 3 == 0 and i != 0: result = "." + result return result + diff --git a/scripts/galaxy.gd b/scripts/galaxy.gd index f729496..bdf154c 100644 --- a/scripts/galaxy.gd +++ b/scripts/galaxy.gd @@ -60,7 +60,7 @@ func _generate_galaxy(count: int): for j in range(star.planet_count): var planet = PlanetScene.instantiate() planet.pname = Names.planet_names[randi() % Names.planet_names.size()] - planet.orbit_radius = 55 + j * 40 + planet.orbit_radius = 65 + j * 40 planet.orbit_speed = randf_range(0.004, 0.01) planet.since_potential = 0.1 + (2.0 - 0.1) * pow(randf(), 4.0) planet.size = randi_range(1, 3) diff --git a/scripts/planet_panel.gd b/scripts/planet_panel.gd index 47162eb..80d211a 100644 --- a/scripts/planet_panel.gd +++ b/scripts/planet_panel.gd @@ -5,6 +5,22 @@ extends Panel @onready var buildings_container = $Buildings @onready var send_button = $SendButton +var dragging := false +var drag_offset := Vector2.ZERO + +func _gui_input(event): + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_LEFT: + if event.pressed: + # Kliknięto na panel → zaczynamy drag + dragging = true + drag_offset = get_local_mouse_position() + else: + # Zwolniono przycisk → kończymy drag + dragging = false + elif event is InputEventMouseMotion and dragging: + # Przesuwamy panel względem pozycji myszy + position += event.relative func _ready(): send_button.connect("pressed", Callable(self, "_on_send_resources_pressed")) diff --git a/scripts/settings.gd b/scripts/settings.gd index d7f3c2d..33b0c1b 100644 --- a/scripts/settings.gd +++ b/scripts/settings.gd @@ -15,7 +15,7 @@ const MARGIN: float = 50.0 var NUMBER_OF_SYSTEMS: int = 100 #Ilosc systemów var min_planet = 1 -var max_planet = 7 +var max_planet = 5 #Zmiana upływu czasu #var TIME_SCALE = 1 diff --git a/scripts/star.gd b/scripts/star.gd index 229243a..2237f1a 100644 --- a/scripts/star.gd +++ b/scripts/star.gd @@ -6,6 +6,11 @@ class_name Star @export var thickness: float = 0.5 # Grubość linii konturu @export var segments: int = 64 @onready var label = $Label +@onready var system_owner = "" +@onready var station_scene = preload("res://scenes/Station.tscn") # scena stacji kosmicznej +var has_station: bool = false +var station_sprite: Sprite2D = null + @export var star_name: String = "" @export var planet_count: int = 0 var planets: Array = [] @@ -14,7 +19,8 @@ var texture: Texture2D func _ready(): #print("Gwiazda %s z %d planetami" % [star_name, planet_count]) label.text = star_name - + var area = $Sprite2D/Area2D + area.connect("input_event", Callable(self, "_on_area_input")) # Stała do rysowania pełnego okręgu const TAU = 6.2831853 # 2 * PI @@ -31,3 +37,19 @@ func _draw(): color, thickness ) + +func _on_area_input(viewport, event, shape_idx): + if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed: + capture_system(PlayerData.PlayerName) + print("System przejęty przez:", system_owner) + +func capture_system(player_name: String) -> void: + if system_owner != "": + return # już przejęty + system_owner = player_name + + # Dodaj stację kosmiczną obok gwiazdy + var station = station_scene.instantiate() + station.position = position + Vector2(35, 0) # obok gwiazdy + label.add_theme_color_override("font_color", Color(0.788, 0.332, 0.196, 1.0)) + get_parent().add_child(station) diff --git a/scripts/tech_panel.gd b/scripts/tech_panel.gd index e1d5053..945eb66 100644 --- a/scripts/tech_panel.gd +++ b/scripts/tech_panel.gd @@ -7,6 +7,23 @@ extends Panel # Ścieżka do tekstur technologii (tu możesz dać swoje grafiki) const DEFAULT_ICON = preload("res://assets/tech/Mining_Drill.png") +var dragging := false +var drag_offset := Vector2.ZERO + +func _gui_input(event): + if event is InputEventMouseButton: + if event.button_index == MOUSE_BUTTON_LEFT: + if event.pressed: + # Kliknięto na panel → zaczynamy drag + dragging = true + drag_offset = get_local_mouse_position() + else: + # Zwolniono przycisk → kończymy drag + dragging = false + elif event is InputEventMouseMotion and dragging: + # Przesuwamy panel względem pozycji myszy + position += event.relative + func _ready(): _create_technology_buttons() diff --git a/scripts/technologies.gd b/scripts/technologies.gd index 961ba4d..87dc014 100644 --- a/scripts/technologies.gd +++ b/scripts/technologies.gd @@ -28,5 +28,20 @@ const TECHNOLOGIES = { "water_efficiency": 1.15 }, "requires": ["advanced_mining"] + }, + "terraforming": { + "name": "Terraforming", + "description": "Allow terreforming planet", + "time": 10, + "cost": { + "science": 10, + "iron": 5, + "aluminium":10 + }, + "texture": "res://assets/tech/terraforming.png", + "unlock_effects": { + "water_efficiency": 1.15 + }, + "requires": ["hydro_engineering"] } } diff --git a/scripts/top_panel.gd b/scripts/top_panel.gd index 20e1f06..6affe05 100644 --- a/scripts/top_panel.gd +++ b/scripts/top_panel.gd @@ -2,7 +2,7 @@ extends Control @onready var label_player_name = $HBoxContainer/PlayerName #@onready var label_science = $HBoxContainer/LabelScience -@onready var label_iron = $HBoxContainer/IronLabel +@onready var ResLabel = $HBoxContainer/ResLabel @onready var label_water = $HBoxContainer/WaterLabel @onready var label_copper = $HBoxContainer/CopperLabel @onready var label_since = $HBoxContainer/SinceLabel @@ -13,10 +13,20 @@ 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_since.text = "%s: %.2f" % [tr("since"), PlayerData.since_doc] + var text = "" + + for res_name in PlayerData.resources.keys(): + var amount = PlayerData.resources[res_name] + # Pomiń surowce zerowe jeśli chcesz + if amount == 0: + continue + text += "%s: %.2f " % [tr(res_name.capitalize()), amount] + + # Dodaj też since_doc + text += "\n%s: %.2f" % [tr("since"), PlayerData.since_doc] + + # Przypisz do jednego labelka + ResLabel.text = text #label_population.text = "👥 Populacja: %s" % GameData.format_number(player.total_population)