scene transitions

This commit is contained in:
Leon Palluch 2020-02-01 18:36:42 +01:00
parent 07d2eb94ce
commit 1690239782
7 changed files with 1128 additions and 27 deletions

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,7 @@ collide_with_areas = true
collide_with_bodies = false collide_with_bodies = false
[node name="Torso" parent="." instance=ExtResource( 1 )] [node name="Torso" parent="." instance=ExtResource( 1 )]
[connection signal="pressed" from="GUI/HBoxC/VBoxC/Start" to="." method="_on_Button2_pressed"] [connection signal="pressed" from="GUI/HBoxC/VBoxC/Start" to="." method="_on_Start_pressed"]
[editable path="Torso"] [editable path="Torso"]

View File

@ -17,12 +17,15 @@ var _viewport : Viewport
var _velx = 0 var _velx = 0
var _vely = 0 var _vely = 0
var _attachment_point : Spatial var _attachment_point : Spatial
var _default_grav
signal start_fight()
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
_default_grav = PhysicsServer.area_get_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY)
PhysicsServer.area_set_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY, 0) PhysicsServer.area_set_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY, 0)
_torso = get_node(torsoPath) as RigidBody _torso = get_node(torsoPath) as RigidBody
_camera = get_node(cameraPath) as Camera _camera = get_node(cameraPath) as Camera
@ -115,3 +118,8 @@ func delete_body_part():
if body_part != null: if body_part != null:
body_part.queue_free() body_part.queue_free()
func _on_Start_pressed():
PhysicsServer.area_set_param(get_viewport().find_world().get_space(), PhysicsServer.AREA_PARAM_GRAVITY, _default_grav)
emit_signal("start_fight")

View File

@ -1,41 +1,77 @@
extends Node extends Node
var _win_screen_scene const _body_build_path = "res://BodyConfig/bodyBuilderMenu.tscn"
var _fighting_scene_path = "res://Ingame/Testing.tscn" const _fighting_path = "res://Ingame/Testing.tscn"
var _fighting_scene const _win_screen_path = "res://UI/WinScreen.tscn"
var _body_build_scene var _body_build_scene
var _fighting_scene
var _win_screen_scene
#test
var test = 0
var tested = false
signal player_win()
func _ready(): func _ready():
_win_screen_scene = preload("res://UI/WinScreen.tscn").instance() _prep_scene("body_build")
_body_build_scene = preload("res://BodyConfig/bodyBuilderMenu.tscn").instance() _prep_scene("fight_scene")
_fighting_scene = preload("res://Ingame/Testing.tscn").instance() _prep_scene("win_screen")
InGameState.connect("player_win", self, "_switch_to_win") #test
_body_build_scene.connect("start_fight", self, "_switch_to_fighting") connect("player_win", self, "_switch_to_win")
_win_screen_scene.connect("build_body", self, "_switch_to_body_build")
func _switch_scene(scene): _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 #delete children
for child in get_children(): for child in get_children():
child.queue_free() child.queue_free()
#append win scene #append win scene
add_child(scene) var new_scene = _prep_scene(scene_name)
add_child(new_scene)
func _switch_to_win(player_id): func _switch_to_win(player_id):
_switch_scene(_win_screen_scene) print("test win")
_switch_scene(_win_screen_scene, "win_screen")
#call win message in win scene #call win message in win scene
_win_screen_scene.set_win_message(player_id) _win_screen_scene.set_win_message(player_id)
func _switch_to_fighting(): func _switch_to_fighting():
print("oh fuck") test = 0
tested = false
_switch_scene(_fighting_scene) _switch_scene(_fighting_scene, "fight_scene")
#get_tree().reload_current_scene()
func _switch_to_body_build(): func _switch_to_body_build():
_switch_scene(_body_build_scene) _switch_scene(_body_build_scene, "body_build")
func _process(delta):
if not tested:
test += delta
if test > 3:
print("test2")
tested = true
emit_signal("player_win", 1)

View File

@ -1,9 +1,6 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=2 format=2]
[ext_resource path="res://Controllers/GameStateController.gd" type="Script" id=1] [ext_resource path="res://Controllers/GameStateController.gd" type="Script" id=1]
[ext_resource path="res://BodyConfig/bodyBuilderMenu.tscn" type="PackedScene" id=2]
[node name="GameStateController" type="Node"] [node name="GameStateController" type="Node"]
script = ExtResource( 1 ) script = ExtResource( 1 )
[node name="Body Builder Menu" parent="." instance=ExtResource( 2 )]

View File

@ -7,15 +7,15 @@
[ext_resource path="res://Resources/Styles/ButtonPressedStyle.tres" type="StyleBox" id=5] [ext_resource path="res://Resources/Styles/ButtonPressedStyle.tres" type="StyleBox" id=5]
[ext_resource path="res://Resources/Styles/ButtonNormalStyle.tres" type="StyleBox" id=6] [ext_resource path="res://Resources/Styles/ButtonNormalStyle.tres" type="StyleBox" id=6]
[node name="Spatial" type="Control"] [node name="WinScreen" type="Control"]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
script = ExtResource( 1 ) script = ExtResource( 1 )
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
labelPath = NodePath("MarginContainer/VBoxContainer/PlayerWon") labelPath = NodePath("../WinScreen/MarginContainer/VBoxContainer/PlayerWon")
continuePath = NodePath("MarginContainer/VBoxContainer/Control/Continue") continuePath = NodePath("../WinScreen/MarginContainer/VBoxContainer/Control/Continue")
[node name="MarginContainer" type="MarginContainer" parent="."] [node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0 anchor_right = 1.0

View File

@ -18,6 +18,4 @@ func set_win_message(player_id):
func _on_Continue_pressed(): func _on_Continue_pressed():
print("test2")
emit_signal("build_body") emit_signal("build_body")