Example #1
0
        public void UpsertScoreboardEntry(ulong clientIndex, string name, int score = 0, int combo = 0)
        {
            if (disabled)
            {
                return;
            }
            ScoreboardEntry entry;

            if (!_scoreboardEntries.ContainsKey(clientIndex))
            {
                entry           = new ScoreboardEntry(clientIndex, name);
                entry.place     = 0;
                entry.score     = 0;
                entry.place     = _scoreboardEntries.Count + 1;
                entry.text      = _textPool.Alloc();
                entry.text.text = name;
                _scoreboardEntries.Add(clientIndex, entry);
            }
            else
            {
                entry       = _scoreboardEntries[clientIndex];
                entry.score = score;
                entry.combo = combo;
                entry.UpdateText(entry.place);
            }
            List <KeyValuePair <ulong, ScoreboardEntry> > sorted = _scoreboardEntries.ToList();

            sorted.Sort((pair1, pair2) => pair2.Value.score - pair1.Value.score);
            _scoreboardEntries = sorted.ToDictionary(pair => pair.Key, pair => pair.Value);
            UpdateScoreboardUI();
        }
Example #2
0
        public void RemoveScoreboardEntry(ulong clientIndex)
        {
            if (!_scoreboardEntries.ContainsKey(clientIndex))
            {
                return;
            }
            ScoreboardEntry entry = _scoreboardEntries[clientIndex];

            entry.text.text = "";
            _textPool.Free(entry.text);
            _scoreboardEntries.Remove(clientIndex);
            UpdateScoreboardUI();
        }