@@ -13,11 +13,14 @@ class PerfectDisplay : MonoBehaviour
1313 {
1414 TextMeshPro scoreMesh ;
1515 ScoreController scoreController ;
16-
17- int [ ] scoreRanges = { 100 , 90 , 50 } ;
18- string [ ] colors = { "blue" , "green" , "yellow" , "orange" , "red" } ;
16+ public static Vector3 displayPosition = new Vector3 ( 0 , 2.3f , 7f ) ;
17+ public static int [ ] scoreRanges = { 100 , 90 , 50 } ;
18+ public static string [ ] colors = { "blue" , "green" , "yellow" , "orange" , "red" } ;
1919 int [ ] scoreCount ;
20- int misses ;
20+ int misses = 0 ;
21+ int notes = 0 ;
22+ public static bool showNumbers = true ;
23+ public static bool showPercent = true ;
2124 IEnumerator WaitForLoad ( )
2225 {
2326 bool loaded = false ;
@@ -45,7 +48,7 @@ private void Init()
4548 scoreMesh . color = Color . white ;
4649 scoreMesh . font = Resources . Load < TMP_FontAsset > ( "Teko-Medium SDF No Glow" ) ;
4750 scoreMesh . alignment = TextAlignmentOptions . Center ;
48- scoreMesh . rectTransform . position = Plugin . scoreCounterPosition ;
51+ scoreMesh . rectTransform . position = displayPosition ;
4952 if ( scoreController != null )
5053 {
5154 scoreController . noteWasMissedEvent += Miss ;
@@ -56,10 +59,12 @@ private void Init()
5659 public void Miss ( NoteData data , int c )
5760 {
5861 misses ++ ;
62+ notes ++ ;
5963 UpdateText ( ) ;
6064 }
6165 public void Cut ( NoteData data , NoteCutInfo info , int combo )
6266 {
67+ notes ++ ;
6368 bool didDone = false ;
6469 info . afterCutSwingRatingCounter . didFinishEvent += c => {
6570 if ( didDone ) return ;
@@ -83,13 +88,30 @@ public void Cut(NoteData data, NoteCutInfo info, int combo)
8388 public void UpdateText ( )
8489 {
8590 String text = "" ;
86- for ( int i = 0 ; i < scoreRanges . Length ; i ++ )
91+ if ( showNumbers )
8792 {
88- text += "<color=\" " + colors [ i ] + "\" >" + ">" + scoreRanges [ i ] + "-" + scoreCount [ i ] + "<color=\" black\" >|" ;
93+ for ( int i = 0 ; i < scoreRanges . Length ; i ++ )
94+ {
95+ text += "<color=\" " + colors [ i ] + "\" >" + ">" + scoreRanges [ i ] + "-" + scoreCount [ i ] + "<color=\" black\" >|" ;
96+ }
97+ text += "<color=\" " + colors [ scoreRanges . Length ] + "\" >" + "<" + scoreRanges [ scoreRanges . Length - 1 ] + "-" + scoreCount [ scoreRanges . Length ] + "<color=\" black\" >|" ;
98+ text += "<color=\" " + colors [ scoreRanges . Length + 1 ] + "\" >" + "MISS-" + misses + "\n " ;
99+ }
100+ if ( showPercent )
101+ {
102+ for ( int i = 0 ; i < scoreRanges . Length ; i ++ )
103+ {
104+ text += "<color=\" " + colors [ i ] + "\" >" + ">" + scoreRanges [ i ] + "-" + GetPercent ( scoreCount [ i ] ) + "%<color=\" black\" >|" ;
105+ }
106+ text += "<color=\" " + colors [ scoreRanges . Length ] + "\" >" + "<" + scoreRanges [ scoreRanges . Length - 1 ] + "-" + GetPercent ( scoreCount [ scoreRanges . Length ] ) + "%<color=\" black\" >|" ;
107+ text += "<color=\" " + colors [ scoreRanges . Length + 1 ] + "\" >" + "MISS-" + GetPercent ( misses ) + "%" ;
89108 }
90- text += "<color=\" " + colors [ scoreRanges . Length ] + "\" >" + "<" + scoreRanges [ scoreRanges . Length - 1 ] + "-" + scoreCount [ scoreRanges . Length ] + "<color=\" black\" >|" ;
91- text += "<color=\" " + colors [ scoreRanges . Length + 1 ] + "\" >" + "MISS-" + misses ;
92109 scoreMesh . text = text ;
93110 }
111+ private String GetPercent ( int hits )
112+ {
113+ if ( hits == 0 ) return "0" ;
114+ return ( ( hits * 1f / notes ) * 100 ) . ToString ( "0.0" ) ;
115+ }
94116 }
95117}
0 commit comments