diff --git a/assets/ships/fregata.png b/assets/ships/fregata.png new file mode 100644 index 0000000..1751191 Binary files /dev/null and b/assets/ships/fregata.png differ diff --git a/assets/ships/fregata.png.import b/assets/ships/fregata.png.import new file mode 100644 index 0000000..083593f --- /dev/null +++ b/assets/ships/fregata.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d35tsxrdu12mi" +path="res://.godot/imported/fregata.png-db9b929ff88fcab21e463787d5bfafbd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ships/fregata.png" +dest_files=["res://.godot/imported/fregata.png-db9b929ff88fcab21e463787d5bfafbd.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/ships/transport.png b/assets/ships/transport.png new file mode 100644 index 0000000..2293145 Binary files /dev/null and b/assets/ships/transport.png differ diff --git a/assets/ships/transport.png.import b/assets/ships/transport.png.import new file mode 100644 index 0000000..a55e0a5 --- /dev/null +++ b/assets/ships/transport.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://isv0twji5ech" +path="res://.godot/imported/transport.png-0c67e23931680d08182c4c1f33f70fef.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/ships/transport.png" +dest_files=["res://.godot/imported/transport.png-0c67e23931680d08182c4c1f33f70fef.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/project.godot b/project.godot index a8f8f01..b1e22e4 100644 --- a/project.godot +++ b/project.godot @@ -25,6 +25,7 @@ GameData="*res://scripts/GameData.gd" BuildingsList="*res://scripts/BuildingsList.gd" PlayerData="*res://scripts/PlayerData.gd" Technologies="*res://scripts/technologies.gd" +ShipsType="*res://scripts/ships_type.gd" [display] diff --git a/scenes/galaxy.tscn b/scenes/galaxy.tscn index ee2eb8f..3efdc78 100644 --- a/scenes/galaxy.tscn +++ b/scenes/galaxy.tscn @@ -83,28 +83,32 @@ offset_bottom = 142.0 size_flags_horizontal = 0 [node name="TechPanel" parent="UI" instance=ExtResource("9_lwv00")] -offset_left = -1031.4401 -offset_top = -379.12006 -offset_right = -375.44006 -offset_bottom = -203.12006 +visible = false +offset_left = -1265.4401 +offset_top = -430.12006 +offset_right = -609.44006 +offset_bottom = -254.12006 [node name="StationPanel" parent="UI" instance=ExtResource("10_ntfcv")] visible = false -offset_left = 989.0 -offset_top = 158.0 -offset_right = 1633.0 -offset_bottom = 727.0 +offset_left = 17.0 +offset_top = 394.0 +offset_right = 661.0 +offset_bottom = 963.0 [node name="Label" parent="UI/StationPanel" index="0"] offset_right = 636.0 [node name="Button" parent="UI/StationPanel" index="1"] -offset_left = 205.0 -offset_top = 216.0 -offset_right = 442.0 -offset_bottom = 363.0 +offset_left = 38.0 +offset_top = 98.0 +offset_right = 257.0 +offset_bottom = 138.0 -[node name="Button2" parent="UI/StationPanel" index="2"] +[node name="Button3" parent="UI/StationPanel" index="2"] +offset_right = 257.0 + +[node name="Button2" parent="UI/StationPanel" index="3"] offset_left = 607.0 offset_top = 9.0 offset_right = 636.0 diff --git a/scenes/ship.tscn b/scenes/ship.tscn new file mode 100644 index 0000000..0bae8a7 --- /dev/null +++ b/scenes/ship.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://ctvmetux3loj7"] + +[ext_resource type="Script" uid="uid://d4adbk672ye2t" path="res://scripts/ship.gd" id="1_q631a"] + +[node name="ship" type="Node2D"] +script = ExtResource("1_q631a") + +[node name="Sprite2D" type="Sprite2D" parent="."] +scale = Vector2(0.03125, 0.035156246) diff --git a/scenes/station_panel.tscn b/scenes/station_panel.tscn index cd7e283..a1af120 100644 --- a/scenes/station_panel.tscn +++ b/scenes/station_panel.tscn @@ -30,12 +30,20 @@ horizontal_alignment = 1 [node name="Button" type="Button" parent="."] layout_mode = 0 -offset_left = 287.0 -offset_top = 220.0 -offset_right = 524.0 -offset_bottom = 367.0 +offset_left = 40.0 +offset_top = 100.0 +offset_right = 221.0 +offset_bottom = 140.0 text = "Zbuduj fregatę" +[node name="Button3" type="Button" parent="."] +layout_mode = 0 +offset_left = 38.0 +offset_top = 152.0 +offset_right = 195.0 +offset_bottom = 192.0 +text = "Zbuduj transportowiec" + [node name="Button2" type="Button" parent="."] layout_mode = 0 offset_left = 770.0 @@ -44,4 +52,6 @@ offset_right = 799.0 offset_bottom = 39.0 text = "X" +[connection signal="pressed" from="Button" to="." method="_on_button_pressed"] +[connection signal="pressed" from="Button3" to="." method="_on_button_3_pressed"] [connection signal="pressed" from="Button2" to="." method="_on_button_2_pressed"] diff --git a/scripts/PlayerData.gd b/scripts/PlayerData.gd index e526f88..ca36f63 100644 --- a/scripts/PlayerData.gd +++ b/scripts/PlayerData.gd @@ -8,7 +8,7 @@ var race: String = "Ludzie" # Zasoby globalne var resources := { - "iron": 11.0, + "iron": 18.0, "copper": 0.0, "water": 0.0, "carbon": 0.0, diff --git a/scripts/galaxy.gd b/scripts/galaxy.gd index 7f6bb39..f6142ac 100644 --- a/scripts/galaxy.gd +++ b/scripts/galaxy.gd @@ -61,7 +61,7 @@ func _generate_galaxy(count: int): var planet = PlanetScene.instantiate() planet.parent_star = star planet.pname = Names.planet_names[randi() % Names.planet_names.size()] - planet.orbit_radius = 65 + j * 40 + planet.orbit_radius = 70 + 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/settings.gd b/scripts/settings.gd index 33b0c1b..86e52b3 100644 --- a/scripts/settings.gd +++ b/scripts/settings.gd @@ -9,13 +9,13 @@ var map_speed = 0.02 #ustawienia mapy var x = 12000 var y = 12000 -const MIN_DISTANCE: float = 900 +const MIN_DISTANCE: float = 1000 const MAX_PLACEMENT_ATTEMPTS: int = 50 const MARGIN: float = 50.0 -var NUMBER_OF_SYSTEMS: int = 100 +var NUMBER_OF_SYSTEMS: int = 50 #Ilosc systemów var min_planet = 1 -var max_planet = 5 +var max_planet = 6 #Zmiana upływu czasu #var TIME_SCALE = 1 diff --git a/scripts/ship.gd b/scripts/ship.gd new file mode 100644 index 0000000..f155442 --- /dev/null +++ b/scripts/ship.gd @@ -0,0 +1,15 @@ +extends Node2D +class_name Ship + +var ship_type : String +var speed := 100.0 +var target_position + + +func setup(type): + ship_type = type + speed = ShipsType.SHIP_TYPES[type].speed + # Ustawienie tekstury ze słownika + var tex_path = ShipsType.SHIP_TYPES[type]["texture"] + var texture = load(tex_path) + $Sprite2D.texture = texture diff --git a/scripts/ship.gd.uid b/scripts/ship.gd.uid new file mode 100644 index 0000000..a0c4993 --- /dev/null +++ b/scripts/ship.gd.uid @@ -0,0 +1 @@ +uid://d4adbk672ye2t diff --git a/scripts/ships_type.gd b/scripts/ships_type.gd new file mode 100644 index 0000000..d903d96 --- /dev/null +++ b/scripts/ships_type.gd @@ -0,0 +1,17 @@ +const SHIP_TYPES = { + "transport": { + "name": "Transportowiec", + "cost": {"iron": 10}, + "speed": 80, + "cargo_capacity": 50, + "texture": "res://assets/ships/transport.png" + }, + "frigate": { + "name": "Fregata", + "cost": {"iron": 10, "copper": 10}, + "speed": 120, + "attack": 10, + "hp": 50, + "texture": "res://assets/ships/fregata.png" + } +} diff --git a/scripts/ships_type.gd.uid b/scripts/ships_type.gd.uid new file mode 100644 index 0000000..111b60d --- /dev/null +++ b/scripts/ships_type.gd.uid @@ -0,0 +1 @@ +uid://b0jcuf156wbp diff --git a/scripts/star.gd b/scripts/star.gd index 4881393..5c103e0 100644 --- a/scripts/star.gd +++ b/scripts/star.gd @@ -1,7 +1,7 @@ extends Node2D class_name Star # Parametry ustawiane w Inspektorze (łatwe do edycji!) -@export var radius: float = 400.0 # Promień okręgu +@export var radius: float = 500.0 # Promień okręgu @export var color: Color = Color.GRAY @export var thickness: float = 0.5 # Grubość linii konturu @export var segments: int = 64 diff --git a/scripts/station_panel.gd b/scripts/station_panel.gd index 9f44c01..b532ead 100644 --- a/scripts/station_panel.gd +++ b/scripts/station_panel.gd @@ -19,10 +19,51 @@ func _gui_input(event): position += event.relative +var current_station = null + func show_for_station(station): self.visible = true - #planet_name_label.text = planet.name + current_station = station func _on_button_2_pressed() -> void: self.visible = false + + +func _on_button_pressed() -> void: + build_ship("frigate") + +func _on_button_3_pressed() -> void: + build_ship("transport") + + + +func build_ship(type: String): + if current_station == null: + print("Brak stacji – nie można budować statku") + return + + var cost = ShipsType.SHIP_TYPES[type].cost + + # 1. Sprawdź zasoby gracza + for res in cost.keys(): + if PlayerData.resources[res] < cost[res]: + print("Brakuje:", res) + return + + # 2. Odejmij zasoby gracza + for res in cost.keys(): + PlayerData.resources[res] -= cost[res] + PlayerData.emit_signal("stats_changed") + # 3. Stwórz statek + var ship = preload("res://scenes/ship.tscn").instantiate() + ship.setup(type) + + # POZYCJA SPAWNU — np. obok stacji + ship.position = current_station.position + Vector2(15, 15) + + + # Dodaj do sceny + get_tree().root.get_node("Galaxy").add_child(ship) + + print("Zbudowano statek:", type)