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="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
rotation = 1.5707964
|
rotation = 1.5707964
|
||||||
scale = Vector2(0.03125, 0.035156246)
|
|
||||||
texture = ExtResource("2_2gnfn")
|
texture = ExtResource("2_2gnfn")
|
||||||
|
|||||||
@ -4,6 +4,7 @@ const SHIP_TYPES = {
|
|||||||
"name": "Transport",
|
"name": "Transport",
|
||||||
"cost": {"iron": 10},
|
"cost": {"iron": 10},
|
||||||
"speed": 2,
|
"speed": 2,
|
||||||
|
"scale": 0.028,
|
||||||
"cargo_capacity": 50,
|
"cargo_capacity": 50,
|
||||||
"required_tech": null,
|
"required_tech": null,
|
||||||
"texture": "res://assets/ships/transport.png"
|
"texture": "res://assets/ships/transport.png"
|
||||||
@ -12,10 +13,11 @@ const SHIP_TYPES = {
|
|||||||
"frigate": {
|
"frigate": {
|
||||||
"name": "Frigate",
|
"name": "Frigate",
|
||||||
"cost": {"iron": 10, "copper": 10},
|
"cost": {"iron": 10, "copper": 10},
|
||||||
"speed": 5,
|
"speed": 3,
|
||||||
|
"scale": 0.035,
|
||||||
"attack": 10,
|
"attack": 10,
|
||||||
"hp": 50,
|
"hp": 50,
|
||||||
"required_tech": null,
|
"required_tech": ["basic_shipbuilding"],
|
||||||
"texture": "res://assets/ships/fregata.png"
|
"texture": "res://assets/ships/fregata.png"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -24,9 +26,10 @@ const SHIP_TYPES = {
|
|||||||
"name": "Destroyer",
|
"name": "Destroyer",
|
||||||
"cost": {"iron": 20, "copper": 15},
|
"cost": {"iron": 20, "copper": 15},
|
||||||
"speed": 2,
|
"speed": 2,
|
||||||
|
"scale": 0.045,
|
||||||
"attack": 20,
|
"attack": 20,
|
||||||
"hp": 70,
|
"hp": 70,
|
||||||
"required_tech": null,
|
"required_tech": ["basic_shipbuilding", "advanced_weapons"],
|
||||||
"texture": "res://assets/ships/destroyer.png"
|
"texture": "res://assets/ships/destroyer.png"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -35,11 +38,12 @@ const SHIP_TYPES = {
|
|||||||
# 3. Battleship
|
# 3. Battleship
|
||||||
"battleship": {
|
"battleship": {
|
||||||
"name": "Battleship",
|
"name": "Battleship",
|
||||||
"cost": {"iron": 80, "copper": 40, "uranium": 20},
|
"cost": {"iron": 80, "copper": 40},
|
||||||
"speed": 2,
|
"speed": 1,
|
||||||
|
"scale": 0.050,
|
||||||
"attack": 80,
|
"attack": 80,
|
||||||
"hp": 400,
|
"hp": 400,
|
||||||
"required_tech": null,
|
"required_tech": ["basic_shipbuilding", "advanced_weapons","advanced_laser"],
|
||||||
"texture": "res://assets/ships/battleship.png"
|
"texture": "res://assets/ships/battleship.png"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -47,7 +51,8 @@ const SHIP_TYPES = {
|
|||||||
"colony_ship": {
|
"colony_ship": {
|
||||||
"name": "Colony Ship",
|
"name": "Colony Ship",
|
||||||
"cost": {"iron": 30},
|
"cost": {"iron": 30},
|
||||||
"speed": 9,
|
"speed": 5,
|
||||||
|
"scale": 0.040,
|
||||||
"cargo_capacity": 200,
|
"cargo_capacity": 200,
|
||||||
"required_tech": null,
|
"required_tech": null,
|
||||||
"texture": "res://assets/ships/colony.png"
|
"texture": "res://assets/ships/colony.png"
|
||||||
@ -58,6 +63,7 @@ const SHIP_TYPES = {
|
|||||||
"name": "Scout",
|
"name": "Scout",
|
||||||
"cost": {"iron": 5},
|
"cost": {"iron": 5},
|
||||||
"speed": 20,
|
"speed": 20,
|
||||||
|
"scale": 0.020,
|
||||||
"attack": 2,
|
"attack": 2,
|
||||||
"hp": 10,
|
"hp": 10,
|
||||||
"required_tech": null,
|
"required_tech": null,
|
||||||
@ -69,9 +75,10 @@ const SHIP_TYPES = {
|
|||||||
"name": "Mining Ship",
|
"name": "Mining Ship",
|
||||||
"cost": {"iron": 12, "copper": 5},
|
"cost": {"iron": 12, "copper": 5},
|
||||||
"speed": 3,
|
"speed": 3,
|
||||||
|
"scale": 0.030,
|
||||||
"cargo_capacity": 100,
|
"cargo_capacity": 100,
|
||||||
"mining_power": 5,
|
"mining_power": 5,
|
||||||
"required_tech": null,
|
"required_tech": ["advanced_mining"],
|
||||||
"texture": "res://assets/ships/miner.png"
|
"texture": "res://assets/ships/miner.png"
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -82,6 +89,7 @@ const SHIP_TYPES = {
|
|||||||
"name": "Fighter",
|
"name": "Fighter",
|
||||||
"cost": {"iron": 3, "copper": 1},
|
"cost": {"iron": 3, "copper": 1},
|
||||||
"speed": 14,
|
"speed": 14,
|
||||||
|
"scale": 0.015,
|
||||||
"attack": 8,
|
"attack": 8,
|
||||||
"hp": 15,
|
"hp": 15,
|
||||||
"required_tech": null,
|
"required_tech": null,
|
||||||
@ -92,7 +100,8 @@ const SHIP_TYPES = {
|
|||||||
"science_ship": {
|
"science_ship": {
|
||||||
"name": "Science Ship",
|
"name": "Science Ship",
|
||||||
"cost": {"iron": 15},
|
"cost": {"iron": 15},
|
||||||
"speed": 11,
|
"speed": 8,
|
||||||
|
"scale": 0.024,
|
||||||
"research_bonus": 10,
|
"research_bonus": 10,
|
||||||
"required_tech": null,
|
"required_tech": null,
|
||||||
"texture": "res://assets/ships/science.png"
|
"texture": "res://assets/ships/science.png"
|
||||||
|
|||||||
@ -24,6 +24,11 @@ var current_station = null
|
|||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
generate_ship_buttons()
|
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():
|
func generate_ship_buttons():
|
||||||
# Usuwamy stare guziki
|
# Usuwamy stare guziki
|
||||||
@ -40,9 +45,17 @@ func generate_ship_buttons():
|
|||||||
var data = all_ships[ship_id]
|
var data = all_ships[ship_id]
|
||||||
|
|
||||||
# 1. Sprawdzenie technologii
|
# 1. Sprawdzenie technologii
|
||||||
if data.required_tech != null and not unlocked.has(data.required_tech):
|
if data.required_tech != null:
|
||||||
|
var req = data.required_tech
|
||||||
|
|
||||||
|
if req is String and not unlocked.has(req):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if req is Array:
|
||||||
|
if req.any(func(t): return not unlocked.has(t)):
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
# 2. Tworzymy guzik
|
# 2. Tworzymy guzik
|
||||||
var btn = Button.new()
|
var btn = Button.new()
|
||||||
btn.text = data.name
|
btn.text = data.name
|
||||||
@ -97,6 +110,7 @@ func build_ship(type: String):
|
|||||||
ship.position = current_station.position + Vector2(15, 15)
|
ship.position = current_station.position + Vector2(15, 15)
|
||||||
# Ustawiamy prędkość z listy statków
|
# Ustawiamy prędkość z listy statków
|
||||||
ship.speed = ShipsType.SHIP_TYPES[type].speed
|
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)
|
# Nadajemy kierunek (np. losowy)
|
||||||
ship.direction = Vector2(randf() * 2 - 1, randf() * 2 - 1).normalized()
|
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 dragging := false
|
||||||
var drag_offset := Vector2.ZERO
|
var drag_offset := Vector2.ZERO
|
||||||
signal building_buttons_update
|
signal building_buttons_update
|
||||||
|
signal ships_buttons_update
|
||||||
|
|
||||||
func _gui_input(event):
|
func _gui_input(event):
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
@ -130,6 +131,7 @@ func _on_technology_pressed(tech_id):
|
|||||||
PlayerData.unlocked_techs.append(tech_id)
|
PlayerData.unlocked_techs.append(tech_id)
|
||||||
print("Odblokowano technologię:", tech.name)
|
print("Odblokowano technologię:", tech.name)
|
||||||
emit_signal("building_buttons_update")
|
emit_signal("building_buttons_update")
|
||||||
|
emit_signal("ships_buttons_update")
|
||||||
|
|
||||||
|
|
||||||
# Opcjonalnie: powiadom o zmianach
|
# Opcjonalnie: powiadom o zmianach
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user