Wstep do technolgi i wymagan budynkow

This commit is contained in:
Tomasz Boruc 2025-11-07 21:24:36 +01:00
parent ad414a9232
commit 2f5067d7e5
6 changed files with 59 additions and 23 deletions

View File

@ -3,10 +3,10 @@
"name": "Aluminium ore mine", "name": "Aluminium ore mine",
"description": "Wydobywa boksyt.", "description": "Wydobywa boksyt.",
"resource": "aluminium", "resource": "aluminium",
"cost": {"iron": 500, "carbon": 200, "uranium": 50}, "cost": {"iron": 100, "copper": 100},
"bonuses": {"biosfere": 0.1}, "bonuses": {"biosfere": 0.1},
"build_time": 15.0, "build_time": 15.0,
"texture": "res://assets/buildings/aluminium_ore_mine.png", "texture": "res://assets/buildings/aluminium_ore_mine.png",
"required_tech": "fusion_power" "required_tech": "advanced_mining"
} }
} }

View File

@ -45,6 +45,7 @@ offset = Vector2(50, 50)
transform = Transform2D(1, 0, 0, 1, 50, 50) transform = Transform2D(1, 0, 0, 1, 50, 50)
[node name="PlanetPanel" parent="UI" instance=ExtResource("7_xhm0b")] [node name="PlanetPanel" parent="UI" instance=ExtResource("7_xhm0b")]
visible = false
show_behind_parent = true show_behind_parent = true
anchors_preset = 0 anchors_preset = 0
anchor_left = 0.0 anchor_left = 0.0

View File

@ -5,7 +5,7 @@ var BUILDINGS = {
"name": "Iron Mine", "name": "Iron Mine",
"description": "Pozwala wydobywać żelazo z powierzchni planety.", "description": "Pozwala wydobywać żelazo z powierzchni planety.",
"resource": "iron", "resource": "iron",
"cost": {"iron": 100, "carbon": 50}, "cost": {"iron": 0},
"bonuses": { "bonuses": {
}, },
@ -17,7 +17,7 @@ var BUILDINGS = {
"name": "Water Purifier", "name": "Water Purifier",
"description": "Pozwala wydobywać i oczyszczać wodę do użytku kolonii.", "description": "Pozwala wydobywać i oczyszczać wodę do użytku kolonii.",
"resource": "water", "resource": "water",
"cost": {"iron": 80, "carbon": 40}, "cost": {"iron": 10},
"bonuses": { "bonuses": {
}, },
@ -29,25 +29,25 @@ var BUILDINGS = {
"name": "Copper Mine", "name": "Copper Mine",
"description": "Pozwala wydobywać miedź.", "description": "Pozwala wydobywać miedź.",
"resource": "copper", "resource": "copper",
"cost": {"iron": 80, "carbon": 40}, "cost": {"iron": 10},
"bonuses": { "bonuses": {
}, },
"build_time": 20.0, "build_time": 20.0,
"texture": "res://assets/buildings/copper_mine.png", "texture": "res://assets/buildings/copper_mine.png",
"required_tech": null "required_tech": "advanced_mining"
}, },
"uran_mine": { "uran_mine": {
"name": "Uran Mine", "name": "Uran Mine",
"description": "Pozwala wydobywać uran.", "description": "Pozwala wydobywać uran.",
"resource": "uranium", "resource": "uranium",
"cost": {"iron": 80, "carbon": 40}, "cost": {"iron": 80},
"bonuses": { "bonuses": {
}, },
"build_time": 5.0, "build_time": 5.0,
"texture": "res://assets/buildings/uran_mine.png", "texture": "res://assets/buildings/uran_mine.png",
"required_tech": null "required_tech": "advanced_mining"
}, },
"residential_zone": { "residential_zone": {
"name": "Residential Zone", "name": "Residential Zone",
@ -56,7 +56,7 @@ var BUILDINGS = {
"total_pop_bonus": 25 "total_pop_bonus": 25
}, },
"resource": null, "resource": null,
"cost": {"iron": 80, "carbon": 40}, "cost": {"iron": 10},
"build_time": 5.0, "build_time": 5.0,
"texture": "res://assets/buildings/residential_zone.png", "texture": "res://assets/buildings/residential_zone.png",
"required_tech": null "required_tech": null
@ -68,7 +68,7 @@ var BUILDINGS = {
"biosfere": 0.5 "biosfere": 0.5
}, },
"resource": null, "resource": null,
"cost": {"iron": 80, "carbon": 40}, "cost": {"iron": 10},
"build_time": 5.0, "build_time": 5.0,
"texture": "res://assets/buildings/terraforming_center.png", "texture": "res://assets/buildings/terraforming_center.png",
"required_tech": null "required_tech": null

View File

@ -30,7 +30,8 @@ var resources := {
var science_points: float = 0.0 var science_points: float = 0.0
# Technologie odkryte # Technologie odkryte
var discovered_technologies: Array = [] var unlocked_techs = ["advanced_mining"]
# Lista skolonizowanych planet # Lista skolonizowanych planet
var planets: Array = [] var planets: Array = []

View File

@ -70,23 +70,57 @@ func _create_building_buttons():
# Tworzymy nowe przyciski dla wszystkich budynków w definicjach # Tworzymy nowe przyciski dla wszystkich budynków w definicjach
for b_id in BuildingsList.BUILDINGS.keys(): for b_id in BuildingsList.BUILDINGS.keys():
var b_data = BuildingsList.BUILDINGS[b_id] var b_data = BuildingsList.BUILDINGS[b_id]
var btn = TextureButton.new()
btn.texture_normal = load(b_data.texture)
#btn.stretch_mode = TextureButton.STRETCH_KEEP_ASPECT_COVERED # Sprawdź, czy budynek wymaga technologii
#btn.ignore_texture_size = true var required_tech = b_data.get("required_tech", null)
print("Tech unlocked:", PlayerData.unlocked_techs)
print("Building:", b_id, "requires:", required_tech)
# Jeżeli nie wymaga lub gracz ma już tę technologię
btn.connect("pressed", Callable(self, "_on_building_pressed").bind(b_id)) if not required_tech or required_tech in PlayerData.unlocked_techs:
buildings_container.add_child(btn) var btn = TextureButton.new()
btn.texture_normal = load(b_data.texture)
btn.connect("pressed", Callable(self, "_on_building_pressed").bind(b_id))
buildings_container.add_child(btn)
func _on_building_pressed(b_id): func _on_building_pressed(b_id):
if not planet: if not planet:
return return
var b_data = BuildingsList.BUILDINGS[b_id]
# Sprawdź czy planeta ma wymagany surowiec
if b_data.has("resource") and b_data["resource"] != null:
var required_resource = b_data["resource"]
if not planet.resources.has(required_resource):
print("❌ Planeta nie ma zasobu: %s" % required_resource)
return
var res_info = planet.resources[required_resource]
if not res_info.has("exist") or not res_info["exist"]:
print("❌ Surowiec %s nie występuje na planecie!" % required_resource)
return
# Sprawdź koszt budynku (czy planeta ma odpowiednie zasoby)
if b_data.has("cost"):
for cost_res in b_data.cost.keys():
var cost_val = b_data.cost[cost_res]
if not planet.resources.has(cost_res) or planet.resources[cost_res].get("amount", 0) < cost_val:
print("❌ Brak wystarczającej ilości surowca: %s (wymagane %s)" % [cost_res, cost_val])
return
# Odejmij koszt budowy z zasobów planety
for cost_res in b_data.cost.keys():
var cost_val = b_data.cost[cost_res]
planet.resources[cost_res]["amount"] -= cost_val
# Dodaj budynek
planet.add_building(b_id) planet.add_building(b_id)
_update_info() _update_info()
print("✅ Zbudowano budynek: %s" % b_data.name)
func _on_button_pressed() -> void: func _on_button_pressed() -> void:

View File

@ -12,9 +12,9 @@ func update_info():
label_player_name.text = "Gracz: %s" % PlayerData.PlayerName label_player_name.text = "Gracz: %s" % PlayerData.PlayerName
#label_science.text = "🔬 Nauka: %s" % player.science #label_science.text = "🔬 Nauka: %s" % player.science
label_iron.text = "%s: %.2f" % [tr("Iron"), PlayerData.resources.iron] label_iron.text = "%s: %.2f" % [tr("iron"), PlayerData.resources.iron]
label_water.text = "%s: %.2f" % [tr("Water"), PlayerData.resources.water] label_water.text = "%s: %.2f" % [tr("water"), PlayerData.resources.water]
label_copper.text = "%s: %.2f" % [tr("Copper"), PlayerData.resources.copper] label_copper.text = "%s: %.2f" % [tr("copper"), PlayerData.resources.copper]
#label_population.text = "👥 Populacja: %s" % GameData.format_number(player.total_population) #label_population.text = "👥 Populacja: %s" % GameData.format_number(player.total_population)