-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.gd
More file actions
104 lines (80 loc) · 2.96 KB
/
Game.gd
File metadata and controls
104 lines (80 loc) · 2.96 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Responsible for transitions between the main game screens:
# combat, game over, and the map
extends Node
signal combat_started
const combat_arena_scene = preload("res://src/combat/CombatArena.tscn")
var scenes = {
"battle_scene": load("res://scenes/combat.tscn")
}
#onready var transition = $Overlays/TransitionColor
onready var local_map = $level
onready var party = $Party as Party
#onready var music_player = $MusicPlayer
#onready var game_over_interface := $GameOverInterface
#onready var gui := $GUI
var transitioning = false
var combat_arena: CombatArena
func _ready():
# QuestSystem.initialize(self, party)
# local_map.spawn_party(party)
local_map.visible = true
#local_map.connect("enemies_encountered", self, "enter_battle")
local_map.connect("enemies_encountered", self, "battle")
func battle(new_scene_key):
#get_tree().change_scene("res://scenes/level/combat.tscn")
get_tree().change_scene("res://src/scenes/BattleScene.tscn")
#if scenes.has(new_scene_key):
#for scene in $CurrentScene.get_children():
# scene.queue_free()
#var new_scene = scenes["battle_scene"].instance()
#combat_arena = combat_arena_scene.instance()
#add_child(combat_arena)
#new_scene.connect("change_scene", self, "_load_scene")
#$CurrentScene.add_child(new_scene)
emit_signal("combat_started")
func enter_battle(formation: Formation):
# Plays the combat transition animation and initializes the combat scene
if transitioning:
return
#gui.hide()
# music_player.play_battle_theme()
transitioning = false
#yield(transition.fade_to_color(), "completed")
# remove_child(local_map)
combat_arena = combat_arena_scene.instance()
add_child(combat_arena)
combat_arena.connect("victory", self, "_on_CombatArena_player_victory")
combat_arena.connect("game_over", self, "_on_CombatArena_game_over")
combat_arena.connect(
"battle_completed", self, "_on_CombatArena_battle_completed", [combat_arena]
)
#combat_arena.initialize(formation, party.get_active_members())
# yield(transition.fade_from_color(), "completed")
transitioning = false
combat_arena.battle_start()
emit_signal("combat_started")
func _on_CombatArena_battle_completed(arena):
# At the end of an encounter, fade the screen, remove the combat arena
# and add the local map back
#gui.show()
transitioning = true
# yield(transition.fade_to_color(), "completed")
combat_arena.queue_free()
add_child(local_map)
# yield(transition.fade_from_color(), "completed")
transitioning = false
# music_player.stop()
#func _on_CombatArena_player_victory():
#gui.show()
# music_player.play_victory_fanfare()
func _on_CombatArena_game_over() -> void:
transitioning = true
# yield(transition.fade_to_color(), "completed")
# game_over_interface.display(GameOverInterface.Reason.PARTY_DEFEATED)
# yield(transition.fade_from_color(), "completed")
transitioning = false
func _on_GameOverInterface_restart_requested():
# game_over_interface.hide()
var formation = combat_arena.initial_formation
combat_arena.queue_free()
enter_battle(formation)