void CalculateChannelHash()
 {
     channelHash = RecordsManager.GetAdoptedChannelHash(upperDeck.Concat(lowerDeck).ToArray());
 }
Exemple #2
0
    void Update()
    {
        bool triggerLoadingbar = bmsLoaded;

        if (bmsLoaded)
        {
            bmsLoaded          = false;
            titleDisplay.text  = bmsManager.Title;
            artistDisplay.text = string.Format(LanguageLoader.GetText(17), bmsManager.Artist, bmsManager.SubArtist.Replace("\n", " / "));
            levelDisplay.text  = bmsManager.PlayLevel.ToString();
            if (startOnLoad)
            {
                if (!bmsManager.BGAEnabled)
                {
                    bmsManager.placeHolderTexture = Texture2D.whiteTexture;
                }
                bmsManager.IsStarted = true;
                startOnLoad          = false;
                gameStarted          = true;
            }
        }
        if (stageFileLoaded)
        {
            stageFileLoaded = false;
            bgTexture.SetTexture(bmsManager.StageFile);
            bgTexture.rawImage.enabled = bmsManager.StageFile != null && !bmsManager.IsStarted;
        }
        if (gameEnded)
        {
            gameEnded = false;
            if (!Loader.listenMode)
            {
                panel.gameObject.SetActive(true);
                if (Loader.judgeMode != 2)
                {
                    resultText.text = "";
                    detailsPanel.gameObject.SetActive(true);
                    for (int i = 0; i < resultCountText.Length; i++)
                    {
                        resultCountText[i].text = bmsManager.GetNoteScoreCount(i).ToString("\\x0");
                    }
                    resultComboText.text = bmsManager.MaxCombos.ToString("\\x0");
                    resultScoreText.text = bmsManager.Score.ToString("0000000");
                    resultRankText.text  = string.Format(
                        "<color=#{0}>{1}</color>",
                        ColorUtility.ToHtmlStringRGBA(bmsManager.RankColor),
                        bmsManager.RankString
                        );
                }
                bgTexture.rawImage.enabled = bgTexture.rawImage.texture != null;
                if (graphDisplay)
                {
                    if (graphHandler)
                    {
                        graphDisplay.texture = graphHandler.Texture;
                    }
                    graphDisplay.enabled = graphDisplay.texture;
                }
                var recordsManager = RecordsManager.Instance;
                if (Loader.judgeMode == 2)
                {
                    var  hash        = bmsManager.GetHash(SongInfoLoader.CurrentEncoding, recordsManager.HashAlgorithm);
                    int  channelHash = RecordsManager.GetAdoptedChannelHash(bmsManager.GetAllAdoptedChannels());
                    var  records     = recordsManager.GetRecord(hash, channelHash);
                    bool pass        = bmsManager.Score >= bmsManager.MaxScore / 2;
                    if (pass && records != null)
                    {
                        pass = bmsManager.Score >= records.Value.score;
                    }
                    resultText.text = LanguageLoader.GetText(pass ? 33 : 34);
                    detailsPanel.gameObject.SetActive(false);
                }
                if (!Loader.autoMode)
                {
                    recordsManager.CreateRecord(bmsManager);
                }
            }
            SetPauseButton();
        }
        if (gameStarted)
        {
            gameStarted = false;
            panel.gameObject.SetActive(false);
            pausePanel.gameObject.SetActive(false);
            dummyBGA.SetActive(bmsManager.BGAEnabled);
            bgTexture.rawImage.enabled = false;
            SetPauseButton();
        }
        if (pauseChanged)
        {
            pauseChanged = false;
            pausePanel.gameObject.SetActive(bmsManager.IsPaused);
            SetPauseButton();
        }
        if (backgroundChanged)
        {
            backgroundChanged = false;
            dummyBGA.SetActive(false);
        }
        float t = Time.deltaTime * 10;

        if (bmsManager.Score < displayingScore)
        {
            displayingScore = bmsManager.Score;
        }
        displayingScore   = Mathf.CeilToInt(Mathf.Lerp(displayingScore, bmsManager.Score, t));
        scoreDisplay.text = displayingScore.ToString("0000000");

        if (targetCombos != bmsManager.Combos)
        {
            combosValue  = combosValue + bmsManager.Combos - targetCombos;
            targetCombos = bmsManager.Combos;
        }
        else
        {
            combosValue = Mathf.Lerp(combosValue, 0, t / 4);
        }
        if (displayCombos < targetCombos)
        {
            displayCombos = targetCombos;
        }
        displayCombos     = Mathf.FloorToInt(Mathf.Lerp(displayCombos, bmsManager.Combos, t));
        comboDisplay.text = (bmsManager.IsStarted && displayCombos >= 3) ? displayCombos.ToString() : "";
        comboDisplay.transform.localScale = Vector3.one * (1 + Mathf.Log(Mathf.Max(0, combosValue) + 1, 8));
        if (bmsManager.IsLoadingResources || triggerLoadingbar)
        {
            var anchorMax = durationBar.anchorMax;
            anchorMax.x           = bmsManager.LoadResourceProgress;
            durationBar.anchorMax = anchorMax;
        }
        else if (bmsManager.IsStarted)
        {
            var anchorMax = durationBar.anchorMax;
            anchorMax.x           = bmsManager.PercentageTimePassed;
            durationBar.anchorMax = anchorMax;
        }
        float deltaTime = Time.unscaledDeltaTime;

        if (fpsBar)
        {
            UpdateVerticalBar(fpsBar, deltaTime * 10F);
        }
        if (fpsText)
        {
            fpsText.text = string.Format("{0:0} FPS", 1 / deltaTime);
        }
        if (polyphonyBar)
        {
            UpdateVerticalBar(polyphonyBar, bmsManager.Polyphony / 255F);
        }
        if (polyphonyText)
        {
            polyphonyText.text = string.Format("{0} POLY", bmsManager.Polyphony);
        }
        if (accuracyBar)
        {
            UpdateHorzBar(accuracyBar, bmsManager.Accuracy / 50F);
        }
        if (accuracyText)
        {
            accuracyText.text = string.Format("{0:+0000;-0000}MS", bmsManager.Accuracy);
        }
        if (bpmText)
        {
            bpmText.text = string.Format(
                bpmFormatText, bmsManager.BPM,
                ColorUtility.ToHtmlStringRGBA(
                    Color.Lerp(bpmText.color, bpmLightColor, bpmLightLerp)
                    ));
        }
    }