Ejemplo n.º 1
0
        private void OnDisable()
        {
            var scores = DataSaver.GetValue <List <UI.ScoreItem> >("Scores") ?? new List <ScoreItem>();

            scores.Add(new UI.ScoreItem {
                Name = $"{_textP1.text} & {_textP2.text}", Score = GameManager.Instance.TotalScore
            });
            DataSaver.SetValue("Scores", scores);
            DataSaver.SaveData();
        }
Ejemplo n.º 2
0
        private IEnumerator AddScoreRoutine()
        {
            var scores = DataSaver.GetValue <List <ScoreItem> >("Scores") ?? new List <ScoreItem>();

            scores.Sort((x, y) => y.Score.CompareTo(x.Score));
            _scores.ForEach(x => Destroy(x));
            _scores.Clear();
            for (int i = 0; i < scores.Count; i++)
            {
                var go = Instantiate(_scorePrefab);
                go.transform.SetParent(transform);
                go.transform.localScale = Vector3.one;
                go.GetComponent <ScoreElement>().SetName(scores[i].Name).SetScore(scores[i].Score).SetRank(i + 1);
                _scores.Add(go);
                yield return(new WaitForSeconds(0.1f));
            }
        }