Ship scale, wymagania tech statków
This commit is contained in:
parent
5b48950451
commit
4291107c98
@ -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")
|
||||
|
||||
@ -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"
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user