Put Team in the statscreen

This commit is contained in:
Sofia 2020-08-10 03:08:09 +03:00
parent 68eab14326
commit 186c84ee62
4 changed files with 25 additions and 4 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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<TMP_Text>().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<TMP_Text>();
NickText.color = playerColor;
NickText.text = player.Nick;
int ping = (int)(player.Ping * 1000);
Rows[i].GetChild(1).GetComponent<TMP_Text>().text = $"{ping} ms";
}
}
public void UpdateRowAmount() {

View File

@ -45,7 +45,7 @@ namespace NeonTea.Quakeball.Networking.Instances {
LocalPlayer.Nick = nick;
AddPlayer(LocalPlayer);
PlayerJoined(LocalPlayer);
GameMaster.PlayerJoined(LocalPlayer);
}
public override void OnStop() {