-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameManager.gd
62 lines (45 loc) · 1.55 KB
/
GameManager.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
class_name GameManager
extends Node
signal gameover
export var first_event = "Mil_1"
var is_gameover = false
var event_ui: EventUI
onready var globals = $"/root/Globals"
func _ready():
randomize()
globals.game_mgr = self
if globals.events.events.empty():
globals.events.load_events("master_proxy_milestone.txt")
globals.events.load_events("event_null_final_1-14.txt")
globals.events.load_events("military_events.txt")
globals.events.load_events("event_repair_complete_icon-1-5.txt")
globals.events.load_events("event_dmg_final_1-7.txt")
globals.events.load_events("event_pick_complete_1-3.txt")
# DEBUG
# globals.events.load_events("test_events.txt")
# globals.events.debug_output_event_graph("events.dot")
var event_uis = get_tree().get_nodes_in_group("event_ui")
if len(event_uis) > 0:
event_ui = event_uis[0]
if event_ui != null:
event_ui.connect("choice_selected", self, "on_event_choice_selected")
else:
print("[WARNING] no event ui!")
call_deferred("run_master_event")
func run_master_event():
globals.run_event(first_event)
func _exit_tree():
if globals.game_mgr == self:
globals.game_mgr = null
func _process(delta):
if !is_gameover and globals.check_gameover() != Globals.Gameover_State.Not_Game_Over:
is_gameover = true
gameover()
return
func on_event_choice_selected(event: EventTypes.Event, n_choice: int):
var next_evt = globals.eval_event_choice_outcome(event.choices[n_choice], event)
if next_evt != "":
globals.run_event(next_evt)
func gameover():
get_tree().paused = true
emit_signal("gameover")