From 4291107c98e0e614ab3b6eb5ea5969ad3b61873b Mon Sep 17 00:00:00 2001 From: Tomasz Boruc Date: Sat, 22 Nov 2025 17:59:47 +0100 Subject: [PATCH] =?UTF-8?q?Ship=20scale,=20wymagania=20tech=20statk=C3=B3w?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scenes/ship.tscn | 1 - scripts/ships_type.gd | 27 ++++++++++++++++++--------- scripts/station_panel.gd | 18 ++++++++++++++++-- scripts/tech_panel.gd | 2 ++ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/scenes/ship.tscn b/scenes/ship.tscn index 284f80e..dc5377d 100644 --- a/scenes/ship.tscn +++ b/scenes/ship.tscn @@ -8,5 +8,4 @@ script = ExtResource("1_q631a") [node name="Sprite2D" type="Sprite2D" parent="."] rotation = 1.5707964 -scale = Vector2(0.03125, 0.035156246) texture = ExtResource("2_2gnfn") diff --git a/scripts/ships_type.gd b/scripts/ships_type.gd index c5b2638..b33f079 100644 --- a/scripts/ships_type.gd +++ b/scripts/ships_type.gd @@ -4,6 +4,7 @@ const SHIP_TYPES = { "name": "Transport", "cost": {"iron": 10}, "speed": 2, + "scale": 0.028, "cargo_capacity": 50, "required_tech": null, "texture": "res://assets/ships/transport.png" @@ -12,10 +13,11 @@ const SHIP_TYPES = { "frigate": { "name": "Frigate", "cost": {"iron": 10, "copper": 10}, - "speed": 5, + "speed": 3, + "scale": 0.035, "attack": 10, "hp": 50, - "required_tech": null, + "required_tech": ["basic_shipbuilding"], "texture": "res://assets/ships/fregata.png" }, @@ -24,9 +26,10 @@ const SHIP_TYPES = { "name": "Destroyer", "cost": {"iron": 20, "copper": 15}, "speed": 2, + "scale": 0.045, "attack": 20, "hp": 70, - "required_tech": null, + "required_tech": ["basic_shipbuilding", "advanced_weapons"], "texture": "res://assets/ships/destroyer.png" }, @@ -35,11 +38,12 @@ const SHIP_TYPES = { # 3. Battleship "battleship": { "name": "Battleship", - "cost": {"iron": 80, "copper": 40, "uranium": 20}, - "speed": 2, + "cost": {"iron": 80, "copper": 40}, + "speed": 1, + "scale": 0.050, "attack": 80, "hp": 400, - "required_tech": null, + "required_tech": ["basic_shipbuilding", "advanced_weapons","advanced_laser"], "texture": "res://assets/ships/battleship.png" }, @@ -47,7 +51,8 @@ const SHIP_TYPES = { "colony_ship": { "name": "Colony Ship", "cost": {"iron": 30}, - "speed": 9, + "speed": 5, + "scale": 0.040, "cargo_capacity": 200, "required_tech": null, "texture": "res://assets/ships/colony.png" @@ -58,6 +63,7 @@ const SHIP_TYPES = { "name": "Scout", "cost": {"iron": 5}, "speed": 20, + "scale": 0.020, "attack": 2, "hp": 10, "required_tech": null, @@ -69,9 +75,10 @@ const SHIP_TYPES = { "name": "Mining Ship", "cost": {"iron": 12, "copper": 5}, "speed": 3, + "scale": 0.030, "cargo_capacity": 100, "mining_power": 5, - "required_tech": null, + "required_tech": ["advanced_mining"], "texture": "res://assets/ships/miner.png" }, @@ -82,6 +89,7 @@ const SHIP_TYPES = { "name": "Fighter", "cost": {"iron": 3, "copper": 1}, "speed": 14, + "scale": 0.015, "attack": 8, "hp": 15, "required_tech": null, @@ -92,7 +100,8 @@ const SHIP_TYPES = { "science_ship": { "name": "Science Ship", "cost": {"iron": 15}, - "speed": 11, + "speed": 8, + "scale": 0.024, "research_bonus": 10, "required_tech": null, "texture": "res://assets/ships/science.png" diff --git a/scripts/station_panel.gd b/scripts/station_panel.gd index ad2fa9e..e28e02f 100644 --- a/scripts/station_panel.gd +++ b/scripts/station_panel.gd @@ -24,6 +24,11 @@ var current_station = null func _ready(): generate_ship_buttons() + var tech_panel = get_tree().root.get_node("Galaxy/UI/TechPanel") + tech_panel.connect("ships_buttons_update", Callable(self, "_on_ships_buttons_update")) + +func _on_ships_buttons_update(): + generate_ship_buttons() func generate_ship_buttons(): # Usuwamy stare guziki @@ -40,8 +45,16 @@ func generate_ship_buttons(): var data = all_ships[ship_id] # 1. Sprawdzenie technologii - if data.required_tech != null and not unlocked.has(data.required_tech): - continue + if data.required_tech != null: + var req = data.required_tech + + if req is String and not unlocked.has(req): + continue + + if req is Array: + if req.any(func(t): return not unlocked.has(t)): + continue + # 2. Tworzymy guzik var btn = Button.new() @@ -97,6 +110,7 @@ func build_ship(type: String): ship.position = current_station.position + Vector2(15, 15) # Ustawiamy prędkość z listy statków ship.speed = ShipsType.SHIP_TYPES[type].speed + ship.get_node("Sprite2D").scale = Vector2(ShipsType.SHIP_TYPES[type].scale,ShipsType.SHIP_TYPES[type].scale) # Nadajemy kierunek (np. losowy) ship.direction = Vector2(randf() * 2 - 1, randf() * 2 - 1).normalized() diff --git a/scripts/tech_panel.gd b/scripts/tech_panel.gd index 36a20e9..51de542 100644 --- a/scripts/tech_panel.gd +++ b/scripts/tech_panel.gd @@ -10,6 +10,7 @@ const DEFAULT_ICON = preload("res://assets/tech/Mining_Drill.png") var dragging := false var drag_offset := Vector2.ZERO signal building_buttons_update +signal ships_buttons_update func _gui_input(event): if event is InputEventMouseButton: @@ -130,6 +131,7 @@ func _on_technology_pressed(tech_id): PlayerData.unlocked_techs.append(tech_id) print("Odblokowano technologię:", tech.name) emit_signal("building_buttons_update") + emit_signal("ships_buttons_update") # Opcjonalnie: powiadom o zmianach