Changed win/lose screen for multiplayer

This commit is contained in:
Kristofers Solo 2021-11-18 01:55:55 +02:00
parent 742ffd91f0
commit 9a31acda87
4 changed files with 64 additions and 60 deletions

View File

@ -3,21 +3,27 @@ extends CanvasLayer
# if 0, then singleplayer will work, if 1, then multiplayer only
var winner_amount = 1
onready var win_timer = $winner/win_timer
onready var winner = $winner
onready var loser = $loser
onready var win_timer = $win_lose_screen/win_timer
onready var label = $win_lose_screen/Panel/Label
onready var win_lose_screen = $win_lose_screen
var green = Color("61d6a8")
var red = Color("dd6673")
func _ready() -> void:
winner.hide()
loser.hide()
win_lose_screen.hide()
func _process(_delta: float) -> void:
if Global.alive_players.size() <= winner_amount and get_tree().has_network_peer():
if Global.alive_players[0].name == str(get_tree().get_network_unique_id()):
winner.show()
label.text = "You won!"
label.add_color_override("font_color", green)
win_lose_screen.show()
else:
loser.show()
label.text = "You died!"
label.add_color_override("font_color", red)
win_lose_screen.show()
if win_timer.time_left <= 0:
win_timer.start()

View File

@ -1,4 +1,4 @@
extends Label
extends Node2D
sync func return_to_lobby():
get_tree().change_scene("res://source/scenes/GUI/network_setup.tscn")

View File

@ -1,30 +1,22 @@
[gd_scene load_steps=18 format=2]
[gd_scene load_steps=17 format=2]
[ext_resource path="res://source/assets/scripts/server_handlers/trinity_site_level.gd" type="Script" id=1]
[ext_resource path="res://source/assets/scripts/ui_element_handlers/UI.gd" type="Script" id=2]
[ext_resource path="res://source/levels/trinity_site/images/trinity_site_level_layout_level_design_z_index_0.svg" type="Texture" id=3]
[ext_resource path="res://source/fonts/roboto/Roboto-Regular.ttf" type="DynamicFontData" id=4]
[ext_resource path="res://source/assets/scripts/ui_element_handlers/winner.gd" type="Script" id=5]
[ext_resource path="res://source/assets/scripts/ui_element_handlers/win_lose.gd" type="Script" id=5]
[ext_resource path="res://source/assets/scripts/ui_element_handlers/game_UI.gd" type="Script" id=6]
[ext_resource path="res://source/levels/trinity_site/images/trinity_site_level_layout_level_design_z_index_4.svg" type="Texture" id=7]
[ext_resource path="res://source/levels/trinity_site/images/trinity_site_level_layout_level_design_z_index_3.svg" type="Texture" id=8]
[ext_resource path="res://source/entities/grass/grass_node.tscn" type="PackedScene" id=9]
[ext_resource path="res://source/levels/trinity_site/images/trinity_site_level_layout_level_design_z_index_2.svg" type="Texture" id=10]
[ext_resource path="res://source/levels/trinity_site/images/trinity_site_level_layout_level_design_z_index_1.svg" type="Texture" id=11]
[ext_resource path="res://source/scenes/OVERLAY/elements/win_lose_screen.tscn" type="PackedScene" id=12]
[ext_resource path="res://source/scenes/OVERLAY/elements/menu_button.tscn" type="PackedScene" id=13]
[ext_resource path="res://source/scenes/OVERLAY/elements/trajectory_control.tscn" type="PackedScene" id=14]
[ext_resource path="res://source/scenes/OVERLAY/elements/user_input.tscn" type="PackedScene" id=15]
[ext_resource path="res://source/scenes/OVERLAY/elements/timer.tscn" type="PackedScene" id=16]
[ext_resource path="res://source/assets/scripts/trinity_site_body_handler.gd" type="Script" id=46]
[sub_resource type="DynamicFont" id=1]
size = 120
outline_size = 7
outline_color = Color( 0, 0, 0, 1 )
use_mipmaps = true
use_filter = true
font_data = ExtResource( 4 )
[node name="trinity-site" type="Node2D"]
script = ExtResource( 1 )
@ -152,55 +144,20 @@ script = ExtResource( 2 )
[node name="game_UI" type="CanvasLayer" parent="."]
script = ExtResource( 6 )
[node name="winner" type="Label" parent="game_UI"]
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = 2.37842
margin_top = -35.5
margin_right = 2.37842
margin_bottom = 106.5
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_constants/shadow_offset_x = 6
custom_constants/shadow_offset_y = 6
custom_fonts/font = SubResource( 1 )
text = "You are the winner"
align = 1
valign = 1
[node name="win_lose_screen" parent="game_UI" instance=ExtResource( 12 )]
visible = false
position = Vector2( 0, 360 )
script = ExtResource( 5 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="win_timer" type="Timer" parent="game_UI/winner"]
[node name="win_timer" type="Timer" parent="game_UI/win_lose_screen"]
wait_time = 4.0
[node name="loser" type="Label" parent="game_UI"]
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = 2.37842
margin_top = -35.5
margin_right = 2.37842
margin_bottom = 106.5
custom_fonts/font = SubResource( 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_constants/shadow_offset_x = 6
custom_constants/shadow_offset_y = 6
text = "You lost"
align = 1
valign = 1
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="controls" type="Control" parent="."]
margin_left = -2.1189
margin_right = 1917.88
margin_bottom = 1080.0
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
@ -230,4 +187,4 @@ anchor_right = 0.5
margin_left = -225.0
margin_right = 225.0
[connection signal="timeout" from="game_UI/winner/win_timer" to="game_UI/winner" method="_on_win_timer_timeout"]
[connection signal="timeout" from="game_UI/win_lose_screen/win_timer" to="game_UI/win_lose_screen" method="_on_win_timer_timeout"]

View File

@ -0,0 +1,41 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://source/fonts/oxygen/Oxygen-Bold.ttf" type="DynamicFontData" id=1]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0, 0, 0, 0.588235 )
[sub_resource type="DynamicFont" id=2]
size = 144
use_mipmaps = true
use_filter = true
font_data = ExtResource( 1 )
[node name="win_lose_screen" type="Node2D"]
[node name="Panel" type="Panel" parent="."]
margin_right = 1920.0
margin_bottom = 360.0
rect_scale = Vector2( 1.00112, 1 )
custom_styles/panel = SubResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Panel"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -492.5
margin_top = -91.0
margin_right = 492.5
margin_bottom = 91.0
custom_fonts/font = SubResource( 2 )
text = "null"
align = 1
valign = 1
uppercase = true
__meta__ = {
"_edit_use_anchors_": false
}