Exemplo n.º 1
0
        public static SwingHolder GetSwing(SaberSwingRatingCounter ssrc)
        {
            SwingHolder sh = swings.Find((s) => s.ssrc == ssrc);

            swings.Remove(sh);
            return(sh);
        }
Exemplo n.º 2
0
        private void SaberSwingRatingCounter_didFinishEvent(SaberSwingRatingCounter v)
        {
            ScoreController.RawScoreWithoutMultiplier(noteCutInfos[v], out int beforeCut, out int afterCut, out int cutDistance);
            //"cutDistanceRawScore" is already calculated into "beforeCutRawScore"
            if (noteCutInfos[v].saberType == Saber.SaberType.SaberA)
            {
                totalScoreLeft += beforeCut + afterCut + cutDistance;
                ++totalCutCountLeft;
            }
            else
            {
                totalScoreRight += beforeCut + afterCut + cutDistance;
                ++totalCutCountRight;
            }

            if (settings.SeparateSaberCounts)
            {
                double leftAverage  = Math.Round(((double)(totalScoreLeft)) / (totalCutCountLeft));
                double rightAverage = Math.Round(((double)(totalScoreRight)) / (totalCutCountRight));
                leftAverage      = Double.IsNaN(leftAverage) ? 0 : leftAverage;
                rightAverage     = Double.IsNaN(rightAverage) ? 0 : rightAverage;
                cutCounter.text  = $"{leftAverage}";
                cutCounter.text += $"  {rightAverage}";
            }
            else
            {
                cutCounter.text = $"{Math.Round(((double)(totalScoreRight + totalScoreLeft)) / (totalCutCountRight + totalCutCountLeft))}";
            }

            noteCutInfos.Remove(v);
        }
Exemplo n.º 3
0
 public void Update()
 {
     if (_saber)
     {
         Utilities.Time(ref _saber) += Time.deltaTime;
         if (!_saber.disableCutting)
         {
             Vector3 topPosition    = Utilities.TopPos(ref _saber).position;
             Vector3 bottomPosition = Utilities.BottomPos(ref _saber).position;
             int     i = 0;
             while (i < Utilities.SwingRatingCounters(ref _saber).Count)
             {
                 SaberSwingRatingCounter swingCounter = Utilities.SwingRatingCounters(ref _saber)[i];
                 if (swingCounter.didFinish)
                 {
                     swingCounter.Deinit();
                     Utilities.SwingRatingCounters(ref _saber).RemoveAt(i);
                     Utilities.UnusedSwingRatingCounters(ref _saber).Add(swingCounter);
                 }
                 else
                 {
                     i++;
                 }
             }
             SaberMovementData.Data lastAddedData = Utilities.MovementData(ref _saber).lastAddedData;
             Utilities.MovementData(ref _saber).AddNewData(topPosition, bottomPosition, Utilities.Time(ref _saber));
             if (!_saber.disableCutting)
             {
                 Utilities.Cutter(ref _saber).Cut(_saber, topPosition, bottomPosition, lastAddedData.topPos, lastAddedData.bottomPos);
             }
         }
     }
 }
Exemplo n.º 4
0
 public static void PreparePreswing(SaberSwingRatingCounter ssrc)
 {
     if (!swings.Any((s) => s.ssrc == ssrc))
     {
         swings.Add(new SwingHolder(ssrc));
         takeNextPreswing = true;
     }
 }
Exemplo n.º 5
0
        public static void AddPostswing(SaberSwingRatingCounter ssrc, float swing)
        {
            SwingHolder sh = swings.Find((s) => s.ssrc == ssrc);

            if (sh != null)
            {
                sh.AddPostSwing(swing);
            }
        }
Exemplo n.º 6
0
 static bool Prefix(SaberSwingRatingCounter saberSwingRatingCounter, FlyingScoreEffect __instance, NoteCutInfo ____noteCutInfo)
 {
     if (Config.instance.doIntermediateUpdates)
     {
         ScoreModel.RawScoreWithoutMultiplier(____noteCutInfo, out int before, out int after, out int accuracy);
         int total = before + after + accuracy;
         Config.judge(__instance, ____noteCutInfo, saberSwingRatingCounter, total, before, after, accuracy);
     }
     return(false);
 }
Exemplo n.º 7
0
 public static void DestroyNotes()
 {
     foreach (GameNoteController gameNoteController in UnityEngine.Object.FindObjectsOfType <GameNoteController>())
     {
         try
         {
             SaberSwingRatingCounter counter = Plugin.player.leftSaber.CreateSwingRatingCounter(gameNoteController.noteTransform);
             counter.SetField("_beforeCutRating", 1f);
             counter.SetField("_afterCutRating", 1f);
             gameNoteController.InvokeMethod("SendNoteWasCutEvent", (new NoteCutInfo(true, true, true, false, 999f, Vector3.down,
                                                                                     (gameNoteController.noteData.noteType == NoteType.NoteA) ? Saber.SaberType.SaberA : Saber.SaberType.SaberB, 1f, 0f, Vector3.down, new Vector3(0.0001f, 0.00001f, 0.00001f), counter, 0f)));
         }
         catch (System.Exception ex)
         {
             Plugin.Log("Error Trying to Destroy notes: " + ex);
         }
     }
 }
Exemplo n.º 8
0
        private void SaberSwingRatingCounter_didFinishEvent(SaberSwingRatingCounter v)
        {
            ScoreModel.RawScoreWithoutMultiplier(noteCutInfos[v], out int beforeCut, out int afterCut, out int cutDistance);
            //"cutDistanceRawScore" is already calculated into "beforeCutRawScore"
            if (noteCutInfos[v].saberType == SaberType.SaberA)
            {
                totalScoresLeft[0] += beforeCut;
                totalScoresLeft[1] += afterCut;
                totalScoresLeft[2] += cutDistance;
                ++totalCutCountLeft;
            }
            else
            {
                totalScoresRight[0] += beforeCut;
                totalScoresRight[1] += afterCut;
                totalScoresRight[2] += cutDistance;
                ++totalCutCountRight;
            }

            UpdateLabels();

            noteCutInfos.Remove(v);
        }
Exemplo n.º 9
0
 public SwingHolder(SaberSwingRatingCounter _ssrc)
 {
     ssrc = _ssrc;
 }
Exemplo n.º 10
0
        public static void judge(FlyingScoreEffect scoreEffect, NoteCutInfo noteCutInfo, SaberSwingRatingCounter saberSwingRatingCounter, int score, int before, int after, int accuracy)
        {
            // as of 0.13, the TextMeshPro is private; use reflection to grab it out of a private field
            TextMeshPro text = scoreEffect.getPrivateField <TextMeshPro>("_text");

            // enable rich text
            text.richText = true;
            // disable word wrap, make sure full text displays
            text.enableWordWrapping = false;
            text.overflowMode       = TextOverflowModes.Overflow;


            Judgment judgment = DEFAULT_JUDGMENT;
            int      index; // save in case we need to fade

            for (index = 0; index < instance.judgments.Length; index++)
            {
                Judgment j = instance.judgments[index];
                if (score >= j.threshold)
                {
                    judgment = j;
                    break;
                }
            }

            Color color;

            if (judgment.fade)
            {
                Judgment fadeJudgment = instance.judgments[index - 1];
                Color    baseColor    = toColor(judgment.color);
                Color    fadeColor    = toColor(fadeJudgment.color);
                float    lerpDistance = Mathf.InverseLerp(judgment.threshold, fadeJudgment.threshold, score);
                color = Color.Lerp(baseColor, fadeColor, lerpDistance);
            }
            else
            {
                color = toColor(judgment.color);
            }
            scoreEffect.setPrivateField("_color", color);

            if (instance.displayMode == "format")
            {
                StringBuilder formattedBuilder = new StringBuilder();
                string        formatString     = judgment.text;
                int           nextPercentIndex = formatString.IndexOf('%');
                while (nextPercentIndex != -1)
                {
                    formattedBuilder.Append(formatString.Substring(0, nextPercentIndex));
                    if (formatString.Length == nextPercentIndex + 1)
                    {
                        formatString += " ";
                    }
                    char specifier = formatString[nextPercentIndex + 1];

                    switch (specifier)
                    {
                    case 'b':
                        formattedBuilder.Append(before);
                        break;

                    case 'c':
                        formattedBuilder.Append(accuracy);
                        break;

                    case 'a':
                        formattedBuilder.Append(after);
                        break;

                    case 'B':
                        formattedBuilder.Append(judgeSegment(before, instance.beforeCutAngleJudgments));
                        break;

                    case 'C':
                        formattedBuilder.Append(judgeSegment(accuracy, instance.accuracyJudgments));
                        break;

                    case 'A':
                        formattedBuilder.Append(judgeSegment(after, instance.afterCutAngleJudgments));
                        break;

                    case 's':
                        formattedBuilder.Append(score);
                        break;

                    case 'p':
                        formattedBuilder.Append(string.Format("{0:0}", score / 115d * 100));
                        break;

                    case '%':
                        formattedBuilder.Append("%");
                        break;

                    case 'n':
                        formattedBuilder.Append("\n");
                        break;

                    default:
                        formattedBuilder.Append("%" + specifier);
                        break;
                    }

                    formatString     = formatString.Remove(0, nextPercentIndex + 2);
                    nextPercentIndex = formatString.IndexOf('%');
                }
                formattedBuilder.Append(formatString);

                text.text = formattedBuilder.ToString();
                return;
            }

            if (instance.displayMode == "textOnly")
            {
                text.text = judgment.text;
                return;
            }
            if (instance.displayMode == "numeric")
            {
                text.text = score.ToString();
                return;
            }
            if (instance.displayMode == "scoreOnTop")
            {
                text.text = score + "\n" + judgment.text + "\n";
                return;
            }
            text.text = judgment.text + "\n" + score + "\n";
        }
Exemplo n.º 11
0
 private void OnSwingRatingCounterFinished(SaberSwingRatingCounter afterCutRating)
 {
     afterCutRating.didFinishEvent -= OnSwingRatingCounterFinished;
     StartCoroutine(CalculateAccuracyAndFireEvents());
 }