school-game/godot/GameTimer.gd

61 lines
1.3 KiB
GDScript

extends Node
@onready var player_vars = get_node("/root/PlayerVariables")
var game_timer = 0
var wait_time = 6
var paused = 0
signal heartbeat
signal week_heartbeat
signal month_heartbeat
signal season_heartbeat
signal year_heartbeat
# Dialogues
signal josephine_dialog1
# Called when the node enters the scene tree for the first time.
func _ready():
# warning-ignore:return_value_discarded
connect("heartbeat", Callable(self, "on_heartbeat"))
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
game_timer += delta
if game_timer > wait_time:
if paused == 0:
game_timer = 0
emit_signal("heartbeat")
if paused == 1:
game_timer = 0
func on_heartbeat():
player_vars.day += 1
player_vars.total_day += 1
if player_vars.day == 6:
player_vars.day = 1
player_vars.week += 1
emit_signal("week_heartbeat")
if player_vars.week == 5:
player_vars.week = 1
player_vars.month += 1
emit_signal("month_heartbeat")
if player_vars.month == 3:
player_vars.month = 1
player_vars.season += 1
emit_signal("season_heartbeat")
if player_vars.season == 6:
player_vars.season = 1
player_vars.year += 1
emit_signal("year_heartbeat")
# Unique Day Events
if player_vars.total_day == 2:
emit_signal("josephine_dialog1")