001-004
Poprawiono brak przyrostu statsystyk
This commit is contained in:
parent
24ec59007f
commit
9037679f75
94
Manager.gd
94
Manager.gd
@ -2,39 +2,24 @@ extends Node
|
|||||||
# Autoload: Manager
|
# Autoload: Manager
|
||||||
|
|
||||||
# --- KONFIGURACJA ---
|
# --- KONFIGURACJA ---
|
||||||
@export var SECTOR_COUNT: int = 5
|
@export var SECTOR_COUNT: int = 10
|
||||||
@export var PLANETS_PER_SECTOR_RANGE: Vector2 = Vector2(1, 5)
|
@export var PLANETS_PER_SECTOR_RANGE: Vector2 = Vector2(1, 5)
|
||||||
|
const UPDATE_INTERVAL := 2.0
|
||||||
|
|
||||||
# --- DANE ---
|
# --- DANE ---
|
||||||
var sectors_data: Array = [] # Każdy element: {"name": str, "position": Vector2, "planets": Array, "star": Dictionary}
|
var sectors_data: Array = [] # Każdy element: {"name", "position", "planets", "star"}
|
||||||
var current_sector: int = -1
|
var current_sector: int = -1
|
||||||
|
|
||||||
|
# Timer aktualizacji
|
||||||
|
var update_timer := 0.0
|
||||||
|
|
||||||
# Nazwy sektorów i planet
|
# Nazwy sektorów i planet
|
||||||
var sector_names = [
|
var sector_names = [
|
||||||
"Aetherion", "Altaris", "Andur System", "Artemis Reach", "Astrion",
|
"Aetherion", "Altaris", "Andur System", "Artemis Reach", "Astrion",
|
||||||
"Azura Prime", "Borealis Expanse", "Caldris Belt", "Canthar System", "Celion Verge",
|
"Azura Prime", "Borealis Expanse", "Caldris Belt", "Canthar System", "Celion Verge",
|
||||||
"Corvax Sector", "Cygnera Rift", "Daedalus Reach", "Darnis Cluster", "Dravon Expanse",
|
"Corvax Sector", "Cygnera Rift", "Daedalus Reach", "Darnis Cluster", "Dravon Expanse"
|
||||||
"Eclipta Prime", "Erevos System", "Eryndor Belt", "Ethon Reach", "Epsilon Mare",
|
|
||||||
"Falcoris Rim", "Feron Cluster", "Gaelis System", "Galmar Belt", "Gryphon Reach",
|
|
||||||
"Halion Expanse", "Helios Verge", "Hespera Sector", "Hyden Reach", "Icarion System",
|
|
||||||
"Illun Belt", "Istris Cluster", "Jorath System", "Kaelor Expanse", "Kassian Reach",
|
|
||||||
"Koralis Rim", "Krynn Sector", "Lunaris Reach", "Lysara System", "Maelor Verge",
|
|
||||||
"Magnor Belt", "Mareth Cluster", "Meridian Expanse", "Morthal System", "Myrris Reach",
|
|
||||||
"Nadir Verge", "Naos Sector", "Nerath Cluster", "Norian Belt", "Nova Thal",
|
|
||||||
"Oblivis Reach", "Odessa Expanse", "Orionis Verge", "Orryx System", "Pallas Belt",
|
|
||||||
"Parallax Rim", "Perion Sector", "Pharos System", "Phoenix Reach", "Primis Expanse",
|
|
||||||
"Pyra Cluster", "Quaron Belt", "Quiris System", "Ragnar Verge", "Rathor Expanse",
|
|
||||||
"Ravenna Sector", "Regalis System", "Remora Reach", "Rydan Belt", "Saren Cluster",
|
|
||||||
"Selena Verge", "Seraphis System", "Shadow Rift", "Silvar Reach", "Solara Expanse",
|
|
||||||
"Starnis Belt", "Syrion Cluster", "Talion System", "Tarsis Verge", "Tauren Expanse",
|
|
||||||
"Tenebris Rim", "Thalassa Reach", "Tharon Belt", "Tirion Sector", "Tritonis Expanse",
|
|
||||||
"Umbra Verge", "Valis Reach", "Varon Cluster", "Velora System", "Verrin Belt",
|
|
||||||
"Veyra Expanse", "Viridis Rim", "Volnar Sector", "Vortex Reach", "Vulcaris System",
|
|
||||||
"Wraith Expanse", "Xandor Cluster", "Xerion Verge", "Ymir Belt", "Zephyra System",
|
|
||||||
"Zerath Expanse", "Zyra Prime", "Zyneth Reach", "Zorath System", "Zyphon Rim"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
var planet_names = [
|
var planet_names = [
|
||||||
"Arcturus","Betelgeuse","Canopus","Deneb","Elnath",
|
"Arcturus","Betelgeuse","Canopus","Deneb","Elnath",
|
||||||
"Fomalhaut","Gacrux","Hadar","Izar","Jabbah",
|
"Fomalhaut","Gacrux","Hadar","Izar","Jabbah",
|
||||||
@ -47,6 +32,13 @@ var planet_names = [
|
|||||||
func _ready():
|
func _ready():
|
||||||
randomize()
|
randomize()
|
||||||
_initialize_sectors()
|
_initialize_sectors()
|
||||||
|
print("[Manager] Initialized with %d sectors" % SECTOR_COUNT)
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
update_timer += delta
|
||||||
|
if update_timer >= UPDATE_INTERVAL:
|
||||||
|
update_timer = 0.0
|
||||||
|
_update_planets()
|
||||||
|
|
||||||
# --- LOSOWANIE UNIKALNEJ NAZWY SEKTORA ---
|
# --- LOSOWANIE UNIKALNEJ NAZWY SEKTORA ---
|
||||||
func get_unique_sector_name() -> String:
|
func get_unique_sector_name() -> String:
|
||||||
@ -65,20 +57,20 @@ func _initialize_sectors():
|
|||||||
if sectors_data.size() <= i:
|
if sectors_data.size() <= i:
|
||||||
sectors_data.resize(i + 1)
|
sectors_data.resize(i + 1)
|
||||||
if sectors_data[i] == null:
|
if sectors_data[i] == null:
|
||||||
# Losowa pozycja
|
# Pozycja sektora
|
||||||
var pos = Vector2(
|
var pos = Vector2(
|
||||||
randf_range(100, screen_size.x - 200),
|
randf_range(100, screen_size.x - 200),
|
||||||
randf_range(100, screen_size.y - 200)
|
randf_range(100, screen_size.y - 200)
|
||||||
)
|
)
|
||||||
|
|
||||||
# Unikalna nazwa
|
# Nazwa sektora
|
||||||
var name = get_unique_sector_name()
|
var name = get_unique_sector_name()
|
||||||
|
|
||||||
# Losowa gwiazda
|
# Losowa gwiazda
|
||||||
var star_texture = _random_star_texture()
|
var star_texture = _random_star_texture()
|
||||||
var star_scale = randf_range(0.05, 0.05)
|
var star_scale = randf_range(0.05, 0.08)
|
||||||
|
|
||||||
# Utwórz sektor
|
# Utworzenie sektora
|
||||||
sectors_data[i] = {
|
sectors_data[i] = {
|
||||||
"name": name,
|
"name": name,
|
||||||
"position": pos,
|
"position": pos,
|
||||||
@ -89,9 +81,13 @@ func _initialize_sectors():
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Losowe planety
|
# Planety
|
||||||
var planet_count = randi_range(PLANETS_PER_SECTOR_RANGE.x, PLANETS_PER_SECTOR_RANGE.y)
|
var planet_count = randi_range(PLANETS_PER_SECTOR_RANGE.x, PLANETS_PER_SECTOR_RANGE.y)
|
||||||
for j in range(planet_count):
|
for j in range(planet_count):
|
||||||
|
_add_random_planet(i)
|
||||||
|
|
||||||
|
# --- FUNKCJE PLANET ---
|
||||||
|
func _add_random_planet(sector_index: int):
|
||||||
var size = randi_range(1, 3)
|
var size = randi_range(1, 3)
|
||||||
var growth_rate = randf_range(0.1, 1.0)
|
var growth_rate = randf_range(0.1, 1.0)
|
||||||
var texture_planet: String
|
var texture_planet: String
|
||||||
@ -113,12 +109,20 @@ func _initialize_sectors():
|
|||||||
"rotation_speed": randf_range(0.001, 0.02),
|
"rotation_speed": randf_range(0.001, 0.02),
|
||||||
"texture_path": texture_planet
|
"texture_path": texture_planet
|
||||||
}
|
}
|
||||||
sectors_data[i]["planets"].append(planet)
|
sectors_data[sector_index]["planets"].append(planet)
|
||||||
|
|
||||||
# --- FUNKCJE POMOCNICZE ---
|
func _update_planets():
|
||||||
func _random_star_texture() -> String:
|
for sector in sectors_data:
|
||||||
var id = randi_range(1, 8)
|
if sector == null:
|
||||||
return "res://assets/stars/s%d.png" % id
|
continue
|
||||||
|
for planet in sector["planets"]:
|
||||||
|
if planet["is_colonized"]:
|
||||||
|
var growth = int(max(1, planet["population"] * 0.05 * planet["growth_rate"]))
|
||||||
|
planet["population"] = min(planet["population"] + growth, planet["max_population"])
|
||||||
|
planet["resources"] += get_mined_per_cycle(planet)
|
||||||
|
|
||||||
|
func get_mined_per_cycle(planet: Dictionary) -> float:
|
||||||
|
return planet["mining_rate"] * pow(planet["population"], 0.5) * 0.05
|
||||||
|
|
||||||
func get_max_population(size: int) -> int:
|
func get_max_population(size: int) -> int:
|
||||||
match size:
|
match size:
|
||||||
@ -128,6 +132,7 @@ func get_max_population(size: int) -> int:
|
|||||||
4: return 30000
|
4: return 30000
|
||||||
return 1000
|
return 1000
|
||||||
|
|
||||||
|
# --- DOSTĘP DO SEKTORÓW I PLANET ---
|
||||||
func get_sector(index: int) -> Dictionary:
|
func get_sector(index: int) -> Dictionary:
|
||||||
if index >= 0 and index < sectors_data.size():
|
if index >= 0 and index < sectors_data.size():
|
||||||
return sectors_data[index]
|
return sectors_data[index]
|
||||||
@ -139,12 +144,29 @@ func get_planets(index: int) -> Array:
|
|||||||
return sector["planets"]
|
return sector["planets"]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
func register_planet(sector_index: int, planet_data: Dictionary):
|
func register_planet(sector_index: int, planet_name: String, size: int, mining_rate: float, growth_rate: float) -> Dictionary:
|
||||||
if sectors_data.size() <= sector_index:
|
if sectors_data.size() <= sector_index:
|
||||||
sectors_data.resize(sector_index + 1)
|
sectors_data.resize(sector_index + 1)
|
||||||
if sectors_data[sector_index] == null:
|
if sectors_data[sector_index] == null:
|
||||||
sectors_data[sector_index] = {"planets": [], "name":"Unknown", "position": Vector2.ZERO, "star":{}}
|
sectors_data[sector_index] = {"planets": [], "name":"Unknown", "position": Vector2.ZERO, "star":{}}
|
||||||
sectors_data[sector_index]["planets"].append(planet_data)
|
|
||||||
|
|
||||||
func get_mined_per_cycle(planet: Dictionary) -> float:
|
var planet = {
|
||||||
return planet["mining_rate"] * pow(planet["population"], 0.5) * 0.05
|
"name": planet_name,
|
||||||
|
"size": size,
|
||||||
|
"population": 0,
|
||||||
|
"max_population": get_max_population(size),
|
||||||
|
"resources": 0.0,
|
||||||
|
"mining_rate": mining_rate,
|
||||||
|
"growth_rate": growth_rate,
|
||||||
|
"is_colonized": false,
|
||||||
|
"angle": randf() * TAU,
|
||||||
|
"rotation_speed": randf_range(0.01, 0.04),
|
||||||
|
"texture_path": "res://assets/planets/p%d.png" % randi_range(1,18)
|
||||||
|
}
|
||||||
|
sectors_data[sector_index]["planets"].append(planet)
|
||||||
|
return planet
|
||||||
|
|
||||||
|
# --- LOSOWANIE GWIAZD ---
|
||||||
|
func _random_star_texture() -> String:
|
||||||
|
var id = randi_range(1, 8)
|
||||||
|
return "res://assets/stars/s%d.png" % id
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user