From 186c84ee625985dca51e21510f06ab99da25c807 Mon Sep 17 00:00:00 2001 From: teascade Date: Mon, 10 Aug 2020 03:08:09 +0300 Subject: [PATCH] Put Team in the statscreen --- .../Prefabs/UI/StatScreenRoot.prefab | 3 +++ Assets/Scripts/Game/GameMaster.cs | 3 ++- Assets/Scripts/Interface/StatScreen.cs | 21 +++++++++++++++++-- Assets/Scripts/Networking/Instances/Server.cs | 2 +- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Assets/GameObjects/Prefabs/UI/StatScreenRoot.prefab b/Assets/GameObjects/Prefabs/UI/StatScreenRoot.prefab index 41e57ed..3a4b323 100644 --- a/Assets/GameObjects/Prefabs/UI/StatScreenRoot.prefab +++ b/Assets/GameObjects/Prefabs/UI/StatScreenRoot.prefab @@ -52,6 +52,9 @@ MonoBehaviour: RowColor: {r: 0.6117647, g: 0.6117647, b: 0.6117647, a: 0.13333334} BackroundPanel: {fileID: 2512848922102124251} RowPrefab: {fileID: 6592059455020087165, guid: 02259c41b4c68c246afbf2fd4b4c1624, type: 3} + ForceOpen: 0 + SunColor: {r: 1, g: 0.8311939, b: 0.3160377, a: 1} + MoonColor: {r: 0.6666667, g: 0.85309076, b: 1, a: 1} --- !u!1 &9081539380605237274 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Game/GameMaster.cs b/Assets/Scripts/Game/GameMaster.cs index cc8fe3d..4bae873 100644 --- a/Assets/Scripts/Game/GameMaster.cs +++ b/Assets/Scripts/Game/GameMaster.cs @@ -3,7 +3,7 @@ using UnityEngine; using System.Collections.Generic; using NeonTea.Quakeball.Networking.Instances; using NeonTea.Quakeball.Networking; -using NeonTea.Quakeball.TeaNet.Packets; +using NeonTea.Quakeball.Interface; namespace NeonTea.Quakeball.Game { @@ -33,6 +33,7 @@ namespace NeonTea.Quakeball.Game { } Players[Team.Sun].Add(player.Id); player.Team = team; + Terminal.Singleton.Println($"Put {player.Nick} to Team {player.Team}"); } public void PlayerLeft(NetPlayer player) { diff --git a/Assets/Scripts/Interface/StatScreen.cs b/Assets/Scripts/Interface/StatScreen.cs index 620c8fc..cefc1ea 100644 --- a/Assets/Scripts/Interface/StatScreen.cs +++ b/Assets/Scripts/Interface/StatScreen.cs @@ -4,16 +4,20 @@ using UnityEngine.UI; using UnityEngine.InputSystem; using TMPro; using NeonTea.Quakeball.Networking; +using NeonTea.Quakeball.Game; using System.Collections.Generic; namespace NeonTea.Quakeball.Interface { public class StatScreen : MonoBehaviour { - public Color RowColor; + public Color RowColor = new Color(); public RectTransform BackroundPanel; public GameObject RowPrefab; public bool ForceOpen; + public Color SunColor = new Color(); + public Color MoonColor = new Color(); + private bool Open; private InputAction OpenStatScreenAction; @@ -55,10 +59,23 @@ namespace NeonTea.Quakeball.Interface { } for (int i = 0; i < rowAmount; i++) { NetPlayer player = Net.Singleton.Instance.PlayerList[i]; - Rows[i].GetChild(0).GetComponent().text = player.Nick; + Color playerColor = new Color(1, 1, 1, 1); + switch (player.Team) { + case Team.Sun: + playerColor = SunColor; + break; + case Team.Moon: + playerColor = MoonColor; + break; + + } + TMP_Text NickText = Rows[i].GetChild(0).GetComponent(); + NickText.color = playerColor; + NickText.text = player.Nick; int ping = (int)(player.Ping * 1000); Rows[i].GetChild(1).GetComponent().text = $"{ping} ms"; } + } public void UpdateRowAmount() { diff --git a/Assets/Scripts/Networking/Instances/Server.cs b/Assets/Scripts/Networking/Instances/Server.cs index 83508c0..31e253a 100644 --- a/Assets/Scripts/Networking/Instances/Server.cs +++ b/Assets/Scripts/Networking/Instances/Server.cs @@ -45,7 +45,7 @@ namespace NeonTea.Quakeball.Networking.Instances { LocalPlayer.Nick = nick; AddPlayer(LocalPlayer); - PlayerJoined(LocalPlayer); + GameMaster.PlayerJoined(LocalPlayer); } public override void OnStop() {