コード例 #1
0
        public void DisplayScoresOnScoreboard(Song song)
        {
            if ((object)scoreList == null || scoreList.song != song)
            {
                scoreList = new ScoreList(song);
                scoreList.LoadScores();
            }

            for (int i = 0; i < scoreListContent.childCount; i++)
            {
                Destroy(scoreListContent.GetChild(i).gameObject);
            }

            int contentHeight = 0;

            foreach (var playthrough in scoreList.GetScores())
            {
                var scorePanel = Instantiate(scorePrefab, scoreListContent);
                var texts      = scorePanel.GetComponentsInChildren <Text>();
                var rt         = scorePanel.GetComponent <RectTransform>();               //get rect transform
                rt.anchoredPosition = new Vector2(rt.anchoredPosition.x, -contentHeight); // set elements position
                texts[0].text       = core.playerName;
                texts[1].text       = playthrough.score.ToString();
                contentHeight      += (int)rt.sizeDelta.y;
            }
            scoreListContent.sizeDelta = new Vector2(0, contentHeight);
        }
コード例 #2
0
        public void SelectSongAndAddPlaythrough(Song song)
        {
            if ((object)scoreList == null || scoreList.song != song)
            {
                scoreList = new ScoreList(song);
                scoreList.LoadScores();
            }
            else
            {
                scoreList.SaveScores();
            }

            currentPlaythrough = scoreList.AddPlaythrough();
        }
コード例 #3
0
        public void OnEnable()
        {
            if (rows == null)
            {
                return;
            }

            scores = ScoreList.LoadScores();

            for (int i = 0; i < ScoreList.POSITIONS; i++)
            {
                Text[] column = rows[i].GetComponentsInChildren <Text>();

                var scoreInfo = (name : scores[i].Item1, points : scores[i].Item2);
                column[0].text = scoreInfo.name;
                column[1].text = scoreInfo.points.ToString();
            }
        }