brackeys-12/storm/storm_manager.gd
2024-09-15 04:43:56 -04:00

28 lines
739 B
GDScript

extends Node
@onready var globals = Data.data.globals
var game_time = 0
var last_flood_time = 0
var current_flood_state = 0
func _process(delta: float) -> void:
if not Persister.get_value("game_started") or Persister.get_value("win") or Persister.get_value("lose"):
return
game_time += delta
Persister.persist_data("game_time", int(game_time * 1000))
if last_flood_time + globals.time_to_flood_change < game_time:
last_flood_time += globals.time_to_flood_change
current_flood_state += 1
Persister.change_value("days", 1)
if current_flood_state > globals.flood_levels.size():
Persister.persist_data("win", true)
return
Persister.persist_data("flood_level", globals.flood_levels[current_flood_state])