ugly win screen completed

This commit is contained in:
Leon Palluch 2020-02-01 15:09:11 +01:00
parent 7d4d0254d9
commit 677138d145
4 changed files with 98 additions and 15 deletions

View File

@ -0,0 +1,49 @@
extends Node
var _win_screen_scene
var _fighting_scene_path = "res://Ingame/Testing.tscn"
#test vars
var test = 0
var tested = false
signal player_win(player_id)
func _ready():
_win_screen_scene = preload("res://UI/WinScreen.tscn").instance()
#_fighting_scene = preload("res://Ingame/Testing.tscn").instance()
connect("player_win", self, "_switch_to_win")
_win_screen_scene.connect("start_fight", self, "_switch_to_fighting")
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():
#_switch_scene(_fighting_scene)
get_tree().reload_current_scene()
# test
#func _process(delta):
#if test > 3 and not tested:
#tested = true
#test = 0
#emit_signal("player_win", 1)
#else:
#test += delta

View File

@ -0,0 +1,9 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Controllers/GameStateController.gd" type="Script" id=1]
[ext_resource path="res://Ingame/Testing.tscn" type="PackedScene" id=2]
[node name="GameStateController" type="Node"]
script = ExtResource( 1 )
[node name="InGame" parent="." instance=ExtResource( 2 )]

View File

@ -10,28 +10,52 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
labelPath = NodePath("MarginContainer/VBoxContainer/PlayerWon") labelPath = NodePath("MarginContainer/VBoxContainer/PlayerWon")
continuePath = NodePath("MarginContainer/VBoxContainer/Control/Continue")
[node name="MarginContainer" type="MarginContainer" parent="."] [node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
margin_right = 1024.0 margin_right = 1024.0
margin_bottom = 600.0 margin_bottom = 600.0
[node name="Congratz" type="Label" parent="MarginContainer/VBoxContainer"] [node name="Congratz" type="Label" parent="MarginContainer/VBoxContainer"]
margin_top = -1.0
margin_right = 1024.0 margin_right = 1024.0
margin_bottom = 249.0 margin_bottom = 250.0
rect_min_size = Vector2( 0, 250 ) rect_min_size = Vector2( 0, 250 )
text = "CONGRATULATIONS!" text = "CONGRATULATIONS!"
align = 1 align = 1
valign = 2 valign = 2
[node name="PlayerWon" type="Label" parent="MarginContainer/VBoxContainer"] [node name="PlayerWon" type="Label" parent="MarginContainer/VBoxContainer"]
margin_top = 254.0 margin_top = 253.0
margin_right = 1024.0 margin_right = 1024.0
margin_bottom = 404.0 margin_bottom = 503.0
rect_min_size = Vector2( 0, 150 ) rect_min_size = Vector2( 0, 250 )
align = 1 align = 1
valign = 1 valign = 1
[node name="Control" type="Control" parent="MarginContainer/VBoxContainer"]
margin_top = 508.0
margin_right = 1024.0
margin_bottom = 508.0
[node name="Continue" type="Button" parent="MarginContainer/VBoxContainer/Control"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -100.0
margin_top = -10.0
margin_right = 100.0
margin_bottom = 15.0
rect_min_size = Vector2( 200, 25 )
text = "Continue"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="pressed" from="MarginContainer/VBoxContainer/Control/Continue" to="." method="_on_Continue_pressed"]

View File

@ -1,22 +1,23 @@
extends Control extends Control
export(NodePath) var labelPath export(NodePath) var labelPath
export(NodePath) var continuePath
#signal player_win(player_id) signal start_fight()
var _playerWonLabel var _playerWonLabel
var _continueButton
# Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
_playerWonLabel = get_node(labelPath) as Label _playerWonLabel = get_node(labelPath) as Label
_continueButton = get_node(continuePath) as Label
#connect("player_win", self, "_win_message")
#emit_signal("player_win", 1)
func _win_message(player_id): func set_win_message(player_id):
_playerWonLabel.text = "test" _playerWonLabel.text = "Player " + str(player_id + 1) + " is victorious!"
#print("game won!")
#print(player_id) func _on_Continue_pressed():
print("test2")
emit_signal("start_fight")