bodypartfighter/Controllers/GameStateController.gd

42 lines
1.0 KiB
GDScript3
Raw Normal View History

2020-02-01 15:09:11 +01:00
extends Node
var _win_screen_scene
var _fighting_scene_path = "res://Ingame/Testing.tscn"
2020-02-01 16:54:53 +01:00
var _fighting_scene
var _body_build_scene
2020-02-01 15:09:11 +01:00
func _ready():
_win_screen_scene = preload("res://UI/WinScreen.tscn").instance()
2020-02-01 16:54:53 +01:00
_body_build_scene = preload("res://BodyConfig/bodyBuilderMenu.tscn").instance()
_fighting_scene = preload("res://Ingame/Testing.tscn").instance()
2020-02-01 15:09:11 +01:00
2020-02-01 16:54:53 +01:00
InGameState.connect("player_win", self, "_switch_to_win")
_body_build_scene.connect("start_fight", self, "_switch_to_fighting")
_win_screen_scene.connect("build_body", self, "_switch_to_body_build")
2020-02-01 15:09:11 +01:00
func _switch_scene(scene):
#delete children
for child in get_children():
child.queue_free()
#append win scene
add_child(scene)
func _switch_to_win(player_id):
_switch_scene(_win_screen_scene)
#call win message in win scene
_win_screen_scene.set_win_message(player_id)
func _switch_to_fighting():
2020-02-01 16:54:53 +01:00
print("oh fuck")
_switch_scene(_fighting_scene)
#get_tree().reload_current_scene()
func _switch_to_body_build():
_switch_scene(_body_build_scene)