Beispiel #1
0
        void DestroyPlayer(PhotonPlayer player)
        {
            ScoreboardPlayer scoreboardPlayer = null;

            if (players.TryGetValue(player, out scoreboardPlayer))
            {
                Destroy(scoreboardPlayer.gameObject);
            }
        }
Beispiel #2
0
        void CreatePlayer(PhotonPlayer player)
        {
            GameObject       go = Instantiate(scoreboardPlayerPrefab) as GameObject;
            ScoreboardPlayer scoreboardPlayer = go.GetComponent <ScoreboardPlayer>();

            scoreboardPlayer.scoreboard = this;
            scoreboardPlayer.player     = player;
            scoreboardPlayer.Refresh();

            players.Add(player, scoreboardPlayer);
        }
Beispiel #3
0
        public void Refresh()
        {
            if (scoreboard == null)
            {
                return;
            }

            if (!scoreboard.activeInHierarchy)
            {
                needsToRefresh = true;
                return;
            }

            needsToRefresh = false;

            float topKDRRed  = 0f;
            float topKDRBlue = 0f;
            float topKDRNone = 0f;

            foreach (var pair in players)
            {
                PhotonPlayer     player           = pair.Key;
                ScoreboardPlayer scoreboardPlayer = pair.Value;

                float kdr = ServerController.GetKDR(player);
                switch (player.GetTeam())
                {
                case PunTeams.Team.red:
                    if (kdr > topKDRRed)
                    {
                        topKDRRed = kdr;

                        if (scoreboardPlayer != null)
                        {
                            scoreboardPlayer.transform.SetAsFirstSibling();
                        }
                    }
                    break;

                case PunTeams.Team.blue:
                    if (kdr > topKDRBlue)
                    {
                        topKDRBlue = kdr;

                        if (scoreboardPlayer != null)
                        {
                            scoreboardPlayer.transform.SetAsFirstSibling();
                        }
                    }
                    break;

                default:
                    if (kdr > topKDRNone)
                    {
                        topKDRNone = kdr;

                        if (scoreboardPlayer != null)
                        {
                            scoreboardPlayer.transform.SetAsFirstSibling();
                        }
                    }
                    break;
                }
            }
        }