Example #1
0
    void UpdateCurrentChart()
    {
        GameObject g = GameObject.Find("EventSystem").GetComponent <EventSystem>().currentSelectedGameObject;

        if (g != null)
        {
            if (g.name == "ChartButton(Clone)")
            {
                lastChartSelected = g;
                ChartButton b     = g.GetComponent <ChartButton>();
                string      grade = "";
                switch (SaveDataManager.current.saveData.playerChartRecordData[b.chart.songID].playerBest.grade)
                {
                case Grade.S: grade = "S"; backgroundGrade.color = superBackground.color; break;

                case Grade.AAA: grade = "AAA"; backgroundGrade.color = hardClearedBackground.color; break;

                case Grade.AA: grade = "AA"; backgroundGrade.color = hardClearedBackground.color; break;

                case Grade.A: grade = "A"; backgroundGrade.color = hardClearedBackground.color; break;

                case Grade.B: grade = "B"; backgroundGrade.color = clearedBackground.color; break;

                case Grade.C: grade = "C"; backgroundGrade.color = clearedBackground.color; break;

                case Grade.D: grade = "C"; backgroundGrade.color = failedBackground.color; break;

                case Grade.U: grade = "U"; backgroundGrade.color = failedBackground.color; break;
                }
                chartGradeText.text = grade;

                string clear = "";
                switch (SaveDataManager.current.saveData.playerChartRecordData[b.chart.songID].playerBest.cleared)
                {
                case Cleared.Clear: clear = "C"; backgroundClear.color = clearedBackground.color; break;

                case Cleared.Fail: clear = "X"; backgroundClear.color = failedBackground.color; break;

                case Cleared.HardClear: clear = "HC"; backgroundClear.color = hardClearedBackground.color; break;
                }
                chartClearText.text       = clear;
                chartImage.sprite         = b.chart.songImage;
                chartScoreText.text       = SaveDataManager.current.saveData.playerChartRecordData[b.chart.songID].playerBest.score.ToString("F0");
                chartPlayerComboText.text = SaveDataManager.current.saveData.playerChartRecordData[b.chart.songID].playerBest.highestCombo.ToString("F0");
                chartRatingText.text      = b.chart.rating.ToString("F0");
                chartNameText.text        = b.chart.songTitle;
                chartArtistText.text      = b.chart.songArtist;
                chartBPMText.text         = b.chart.bpm.ToString("F0");
                chartMaxComboText.text    = b.chart.notes.Length.ToString("F0");
                chartPlayCountText.text   = (SaveDataManager.current.saveData.playerChartRecordData[b.chart.songID].playHistory.plays.Count - 1).ToString("F0");

                if (b.chart.rating <= 5)
                {
                    backgroundRating.color = clearedBackground.color;
                }
                else if (b.chart.rating <= 10)
                {
                    backgroundRating.color = hardClearedBackground.color;
                }
                else if (b.chart.rating <= 15)
                {
                    backgroundRating.color = superBackground.color;
                }
                else
                {
                    backgroundRating.color = failedBackground.color;
                }
            }
        }
    }
Example #2
0
    void UpdateRecords()
    {
        if (Input.GetButtonDown("MenuCancel"))
        {
            chartExpand = !chartExpand;
            if (chartExpand)
            {
                chartsUI.SetActive(false);
                recordsUi.SetActive(true);
                GameObject.Find("EventSystem").GetComponent <EventSystem>().SetSelectedGameObject(null);
                ChartButton cb = lastChartSelected.GetComponent <ChartButton>();
                PlayHistory ph = SaveDataManager.current.saveData.playerChartRecordData[cb.chart.songID].playHistory;

                spawnedRecords = new List <GameObject>();
                GameObject hard = Instantiate(hardButtonPrefab) as GameObject;
                hard.transform.SetParent(chartRecordContainer.transform);
                hard.transform.localScale = new Vector3(1f, 1f, 1f);
                hard.GetComponent <Button>().onClick.AddListener(() => HardModePressed());
                GameObject.Find("EventSystem").GetComponent <EventSystem>().SetSelectedGameObject(hard);
                spawnedRecords.Add(hard);
                hardModeButton = hard;

                ph.plays.Sort((b, a) => a.score.CompareTo(b.score));
                int x = 0;
                foreach (PlayData playData in ph.plays)
                {
                    if (x < (ph.plays.Count - 1))
                    {
                        GameObject button = Instantiate(chartRecordPrefab) as GameObject;
                        button.transform.SetParent(chartRecordContainer.transform);
                        button.transform.localScale = new Vector3(1f, 1f, 1f);
                        button.GetComponent <ChartRecordButton>().data = playData;
                        button.GetComponent <ChartRecordButton>().rank = (x + 1);
                        spawnedRecords.Add(button);
                        x++;
                    }
                }
            }
            else
            {
                foreach (GameObject record in spawnedRecords)
                {
                    Destroy(record);
                }

                chartsUI.SetActive(true);
                recordsUi.SetActive(false);
                GameObject.Find("EventSystem").GetComponent <EventSystem>().SetSelectedGameObject(null);
                GameObject.Find("EventSystem").GetComponent <EventSystem>().SetSelectedGameObject(lastChartSelected);
            }
        }
        if (chartExpand)
        {
            if (hardMode)
            {
                hardModeButton.GetComponent <Image>().color = hardClearedBackground.color;
            }
            else
            {
                hardModeButton.GetComponent <Image>().color = normalBackground.color;
            }
        }
    }