Update planet.gd
This commit is contained in:
parent
eaea2e9664
commit
6caa0c05c3
@ -4,7 +4,10 @@ class_name Planet
|
|||||||
|
|
||||||
@onready var info_label = $CanvasLayer/Info
|
@onready var info_label = $CanvasLayer/Info
|
||||||
@onready var area = $Area2D
|
@onready var area = $Area2D
|
||||||
var pop_timer: float = 0.0 # licznik czasu
|
# --- Timery ---
|
||||||
|
var pop_timer: float = 0.0
|
||||||
|
var res_timer: float = 0.0
|
||||||
|
var cons_timer: float = 0.0
|
||||||
|
|
||||||
var pname: String = ""
|
var pname: String = ""
|
||||||
var orbit_radius: float = 30.0
|
var orbit_radius: float = 30.0
|
||||||
@ -103,10 +106,10 @@ func _pop_growth(delta):
|
|||||||
population = max(population - 10, 100)
|
population = max(population - 10, 100)
|
||||||
pop_timer = 0.0
|
pop_timer = 0.0
|
||||||
func _res_growth(delta):
|
func _res_growth(delta):
|
||||||
pop_timer += delta
|
res_timer += delta
|
||||||
if pop_timer < Settings.UPDATE_INTERVAL:
|
if res_timer < Settings.UPDATE_INTERVAL:
|
||||||
return
|
return
|
||||||
pop_timer = 0.0
|
res_timer = 0.0
|
||||||
|
|
||||||
for res_name in resources.keys():
|
for res_name in resources.keys():
|
||||||
var res = resources[res_name]
|
var res = resources[res_name]
|
||||||
@ -124,10 +127,10 @@ func check_growth() -> float:
|
|||||||
func _res_consumption(delta):
|
func _res_consumption(delta):
|
||||||
|
|
||||||
var water_usage = population * 0.0002 # np. 0.002 jednostki wody na osobę
|
var water_usage = population * 0.0002 # np. 0.002 jednostki wody na osobę
|
||||||
pop_timer += delta
|
cons_timer += delta
|
||||||
if pop_timer >= Settings.UPDATE_INTERVAL:
|
if cons_timer >= Settings.UPDATE_INTERVAL:
|
||||||
if "water" in resources:
|
if "water" in resources:
|
||||||
resources["water"].amount -= water_usage
|
resources["water"].amount -= water_usage
|
||||||
if resources["water"].amount < 0:
|
if resources["water"].amount < 0:
|
||||||
resources["water"].amount = 0
|
resources["water"].amount = 0
|
||||||
pop_timer = 0.0
|
cons_timer = 0.0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user