extends Node const _body_build_path = "res://BodyConfig/bodyBuilderMenu.tscn" const _fighting_path = "res://Ingame/Testing.tscn" const _win_screen_path = "res://UI/WinScreen.tscn" var _body_build_scene var _fighting_scene var _win_screen_scene var _bodies : Array var _body_count = 0 var _body_positions = [Vector3(-30, 3, 0), Vector3(30, 3, 0), Vector3(0, 3, -30), Vector3(0, 3, 30)] func _ready(): InGameState.player_count = 2 _prep_scene("body_build") _prep_scene("fight_scene") _prep_scene("win_screen") _switch_scene(_body_build_scene, "body_build") func _prep_scene(scene_name) -> Node: if scene_name == "body_build": _body_build_scene = preload(_body_build_path).instance() _body_build_scene.connect("start_fight", self, "_switch_to_fighting") return _body_build_scene elif scene_name == "fight_scene": _fighting_scene = preload(_fighting_path).instance() InGameState.connect("player_win", self, "_switch_to_win") return _fighting_scene elif scene_name == "win_screen": _win_screen_scene = preload(_win_screen_path).instance() _win_screen_scene.connect("build_body", self, "_switch_to_body_build") return _win_screen_scene return null func _switch_scene(scene, scene_name): #delete children for child in get_children(): child.queue_free() #append win scene var new_scene = _prep_scene(scene_name) add_child(new_scene) func _switch_to_win(player_id): print("test win") _switch_scene(_win_screen_scene, "win_screen") #call win message in win scene _win_screen_scene.set_win_message(player_id) func _switch_to_fighting(torso): _body_build_scene.remove_child(torso) torso.global_transform.origin = Vector3.ZERO torso.translation += Vector3(0, 4, 0) torso.rotation = Vector3.ZERO _body_count += 1 if _body_count < InGameState.player_count: _bodies.append(torso) _switch_scene(_body_build_scene, "body_build") _body_build_scene.done_player_count = _body_count _body_build_scene.change_count_ui() else: _switch_scene(_fighting_scene, "fight_scene") for body in _bodies: _fighting_scene.add_child(body) _fighting_scene.add_child(torso) func _switch_to_body_build(): _switch_scene(_body_build_scene, "body_build")