Added a game timer and put it on the game manager to handle day end events
This commit is contained in:
parent
8d313b8a71
commit
eeb34f9372
@ -44,7 +44,8 @@
|
|||||||
"timeline-1660443870.json",
|
"timeline-1660443870.json",
|
||||||
"timeline-1660444277.json",
|
"timeline-1660444277.json",
|
||||||
"timeline-1660454153.json",
|
"timeline-1660454153.json",
|
||||||
"timeline-1660463789.json"
|
"timeline-1660463789.json",
|
||||||
|
"timeline-1660696967.json"
|
||||||
],
|
],
|
||||||
"folders": {
|
"folders": {
|
||||||
|
|
||||||
|
26
dialogic/timelines/timeline-1660696967.json
Normal file
26
dialogic/timelines/timeline-1660696967.json
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
@ -4,3 +4,25 @@
|
|||||||
|
|
||||||
[node name="game_manager" type="Node"]
|
[node name="game_manager" type="Node"]
|
||||||
script = ExtResource( 1 )
|
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"]
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
|
export var time_per_day : float = 600.0
|
||||||
|
|
||||||
onready var player = get_tree().get_nodes_in_group("player")[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():
|
func _ready():
|
||||||
player.connect("starved_to_death", self, "_on_player_starved_to_death")
|
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():
|
func _on_player_starved_to_death():
|
||||||
var node = Dialogic.start("starve")
|
var node = Dialogic.start("starve")
|
||||||
@ -13,3 +25,16 @@ func _on_player_starved_to_death():
|
|||||||
yield(node, "timeline_end")
|
yield(node, "timeline_end")
|
||||||
get_tree().paused = false
|
get_tree().paused = false
|
||||||
get_tree().quit() # go back to main menu when such a thing exists
|
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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user