ArkSol/scripts/GameData.gd
2025-10-27 19:09:46 +01:00

67 lines
2.1 KiB
GDScript

extends Node
# Podstawowe dane gry
var player_data = null
var sectors = []
var fleets = []
# Funkcja inicjalizująca dane nowej gry
func new_game():
print("🔹 Tworzenie nowej gry...")
player_data = null
sectors.clear()
fleets.clear()
func generate_sectors(sector_count: int = 10):
sectors.clear()
for i in range(sector_count):
# Tworzymy sektor
var s = SectorData.new()
s.id = "sector_" + str(i)
s.name = ObjectNames.sector_names[randi() % ObjectNames.sector_names.size()]
s.position = Vector2(randi() % 1000, randi() % 600)
# Losowa liczba planet (1-5)
var planet_count = randi_range(Settings.min_planets_per_sector, Settings.max_planets_per_sector )
var planet_size = randi_range(Settings.min_planet_size, Settings.max_planet_size)
for j in range(planet_count):
var p = PlanetData.new()
p.name = ObjectNames.planet_names[randi() % ObjectNames.planet_names.size()]
p.size = planet_size # rozmiar 50-200
p.rotation_speed = randf() * 5 # prędkość obrotu 0-5
p.biosfere = randf() # 0.0 - 1.0
p.orbit_radius = randi() % 200 + 50 # 50-250
p.resource_rich = randf() # 0.0 - 1.0
# Generowanie surowców dla planety
p.resources.clear()
for res_name in ObjectNames.resources:
var r = ResourcesData.new()
r.name = res_name
r.exist = randi() % 2 == 0 # 50% szans, że surowiec wystąpi
#r.amount = (randi() % 200 + 50) if r.exist else 0 # jeśli istnieje, losowa ilość
p.resources.append(r)
s.planets.append(p)
# Dodajemy sektor do listy GameData
sectors.append(s)
func _ready():
generate_sectors(Settings.sector_count)
for s in sectors:
print("Sektor:", s.name, "ID:", s.id, "Pozycja:", s.position, "Planety:", s.planets.size())
for p in s.planets:
print(" Planeta:", p.name,
" Rozmiar: ", p.size,
" Orbit: ", p.orbit_radius,
" Rotation: ", round(p.rotation_speed*100)/100,
" Biosfere: ", round(p.biosfere*100)/100,
" Resource Rich: ", round(p.resource_rich*100)/100)
for res in p.resources:
if res.exist:
print(" Surowiec:", res.name)