diff --git a/dialogic/folder_structure.json b/dialogic/folder_structure.json index f0685de..e7f624d 100644 --- a/dialogic/folder_structure.json +++ b/dialogic/folder_structure.json @@ -44,7 +44,8 @@ "timeline-1660443870.json", "timeline-1660444277.json", "timeline-1660454153.json", - "timeline-1660463789.json" + "timeline-1660463789.json", + "timeline-1660696967.json" ], "folders": { diff --git a/dialogic/timelines/timeline-1660696967.json b/dialogic/timelines/timeline-1660696967.json new file mode 100644 index 0000000..fd5f42c --- /dev/null +++ b/dialogic/timelines/timeline-1660696967.json @@ -0,0 +1,26 @@ +{ + "events": [ + { + "character": "character-1660444172.json", + "event_id": "dialogic_001", + "portrait": "", + "text": "Oh boy! I gotta go to bed. That was tiring!" + }, + { + "event_id": "dialogic_023", + "hide_dialogbox": true, + "wait_seconds": 1 + }, + { + "character": "character-1660444172.json", + "event_id": "dialogic_001", + "portrait": "", + "text": "*yawn* Ah! What a good day it is to be stranded on this moon." + } + ], + "metadata": { + "dialogic-version": "1.4.4", + "file": "timeline-1660696967.json", + "name": "day_end" + } +} diff --git a/scenes/game_manager.tscn b/scenes/game_manager.tscn index 5b81b16..3830168 100644 --- a/scenes/game_manager.tscn +++ b/scenes/game_manager.tscn @@ -4,3 +4,25 @@ [node name="game_manager" type="Node"] script = ExtResource( 1 ) + +[node name="UI" type="Control" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +rect_pivot_offset = Vector2( 1024, 600 ) + +[node name="day_timer_text" type="Label" parent="UI"] +unique_name_in_owner = true +anchor_left = 0.752 +anchor_right = 0.808 +anchor_bottom = 0.016 +margin_left = -67.8719 +margin_right = -68.5601 +margin_bottom = 0.199999 +rect_scale = Vector2( 5, 5 ) +text = "Time Left: " +uppercase = true + +[node name="day_timer" type="Timer" parent="."] +unique_name_in_owner = true + +[connection signal="timeout" from="day_timer" to="." method="_on_day_timer_timeout"] diff --git a/scripts/game_manager.gd b/scripts/game_manager.gd index f7b782b..41a640b 100644 --- a/scripts/game_manager.gd +++ b/scripts/game_manager.gd @@ -1,9 +1,21 @@ extends Node +export var time_per_day : float = 600.0 + onready var player = get_tree().get_nodes_in_group("player")[0] +onready var day_timer = $"%day_timer" +onready var day_timer_text = $"%day_timer_text" func _ready(): player.connect("starved_to_death", self, "_on_player_starved_to_death") + day_timer.wait_time = time_per_day + day_timer.start() + +func _process(delta): + var time_left : int = day_timer.time_left + var minutes : int = time_left / 60 + var seconds : int = time_left % 60 + day_timer_text.text = "Time Left: %0*d:%0*d" % [2, minutes, 2, seconds] func _on_player_starved_to_death(): var node = Dialogic.start("starve") @@ -13,3 +25,16 @@ func _on_player_starved_to_death(): yield(node, "timeline_end") get_tree().paused = false get_tree().quit() # go back to main menu when such a thing exists + +func _on_day_timer_timeout(): + player.health -= 1 + if player.health <= 0: + _on_player_starved_to_death() + return + var node = Dialogic.start("day_end") + node.pause_mode = PAUSE_MODE_PROCESS + add_child(node) + get_tree().paused = true + yield(node, "timeline_end") + get_tree().paused = false +