From be26043aaaf108ed5d4ae5f233c20d4c19e90c14 Mon Sep 17 00:00:00 2001 From: zcembbi Date: Mon, 9 Sep 2024 02:15:20 +0300 Subject: [PATCH 1/2] Add storm manager --- StormManager.tscn | 3 +++ parts/globals.txt | 0 storm_manager.gd | 1 + 3 files changed, 4 insertions(+) create mode 100644 StormManager.tscn create mode 100644 parts/globals.txt create mode 100644 storm_manager.gd diff --git a/StormManager.tscn b/StormManager.tscn new file mode 100644 index 0000000..46ed886 --- /dev/null +++ b/StormManager.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://n2lpy72tkyc8"] + +[node name="StormManager" type="Node"] diff --git a/parts/globals.txt b/parts/globals.txt new file mode 100644 index 0000000..e69de29 diff --git a/storm_manager.gd b/storm_manager.gd new file mode 100644 index 0000000..61510e1 --- /dev/null +++ b/storm_manager.gd @@ -0,0 +1 @@ +extends Node -- 2.45.2 From ce1f1f3900c6ae9acc0890806029ea0138b8d21c Mon Sep 17 00:00:00 2001 From: zcembbi Date: Mon, 9 Sep 2024 02:17:19 +0300 Subject: [PATCH 2/2] Add storm manager --- StormManager.tscn | 5 ++++- parts/globals.txt | 1 + storm_manager.gd | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/StormManager.tscn b/StormManager.tscn index 46ed886..f4721f0 100644 --- a/StormManager.tscn +++ b/StormManager.tscn @@ -1,3 +1,6 @@ -[gd_scene format=3 uid="uid://n2lpy72tkyc8"] +[gd_scene load_steps=2 format=3 uid="uid://n2lpy72tkyc8"] + +[ext_resource type="Script" path="res://storm_manager.gd" id="1_wwjtb"] [node name="StormManager" type="Node"] +script = ExtResource("1_wwjtb") diff --git a/parts/globals.txt b/parts/globals.txt index e69de29..eade4d8 100644 --- a/parts/globals.txt +++ b/parts/globals.txt @@ -0,0 +1 @@ +time_to_flood_change: 5 diff --git a/storm_manager.gd b/storm_manager.gd index 61510e1..61cc8ce 100644 --- a/storm_manager.gd +++ b/storm_manager.gd @@ -1 +1,33 @@ extends Node + +@onready var globals = Data.data.globals + + +var game_time = 0 +var last_flood_time = 0 +var current_flood_state = 0 + +var flood_levels = [ + 0, + 1, + 0, + 2, + 1, + 3, + 1, + 0, + 2, + 1, + 4, + 2, + 5 +] + +func _process(delta: float) -> void: + game_time += delta + + if last_flood_time + globals.time_to_flood_change < game_time: + last_flood_time += globals.time_to_flood_change + current_flood_state += 1 + + Persister.persist_data("flood_level", flood_levels[current_flood_state]) -- 2.45.2