Skip to content

Commit

Permalink
Styling fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Apr 23, 2023
1 parent 2e1b9ef commit 89c0737
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 152 deletions.
16 changes: 8 additions & 8 deletions Assets/Script/PlayMode/AbstractTrack.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using Unity.Mathematics;
using UnityEngine;
using YARG.Data;
using YARG.Input;
using YARG.Settings;
Expand Down Expand Up @@ -130,7 +130,7 @@ private void Awake() {
commonTrack.SetupCameras();
commonTrack.TrackCamera.targetTexture = renderTexture;

susTracker = new(Play.Instance.chart.beats);
susTracker = new();
}

private void Start() {
Expand Down Expand Up @@ -176,13 +176,13 @@ protected virtual void OnDestroy() {
},
score = new DiffScore {
difficulty = player.chosenDifficulty,
score = (int) math.round(scoreKeeper.score),
score = (int) math.round(scoreKeeper.Score),
stars = math.clamp((int) starsKeeper.Stars, 0, 6)
},
},
notesHit = notesHit,
notesMissed = Chart.Count - notesHit
};

Play.OnPauseToggle -= PauseToggled;
}

Expand Down Expand Up @@ -387,7 +387,7 @@ private void UpdateInfo() {
// run ONCE
if (soloInProgress) {
soloPtsEarned = scoreKeeper.AddSolo(soloNotesHit, soloNoteCount);

// set box text
if (soloHitPercent >= 100f) {
// Set text color
Expand Down Expand Up @@ -421,7 +421,7 @@ private void UpdateInfo() {
commonTrack.soloBox.sprite = commonTrack.soloMessySprite;
commonTrack.soloText.text = "MESSY\nSOLO!";
}

// show points earned after some time
StartCoroutine(SoloBoxShowScore());

Expand Down
18 changes: 10 additions & 8 deletions Assets/Script/PlayMode/MicPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private string EndPhraseName {
// easy, medium, hard, expert
// https://rockband.scorehero.com/forum/viewtopic.php?t=4545
// max harmony pts = 10% of main points per extra mic
private readonly int[] MAX_POINTS = { 200, 400, 800, 1000 };
private readonly int[] MAX_POINTS = { 200, 400, 800, 1000, 1000 };
private StarScoreKeeper starsKeeper;
private int ptsPerPhrase; // pts per phrase, set depending on difficulty

Expand Down Expand Up @@ -277,7 +277,7 @@ private void Start() {
if (ev.name == EndPhraseName)
phrases++;
}

// note: micInput.Count = number of players on vocals
ptsPerPhrase = MAX_POINTS[(int) micInputs[0].player.chosenDifficulty];
starsKeeper = new(scoreKeeper, micInputs[0].player.chosenInstrument, phrases, ptsPerPhrase);
Expand All @@ -300,7 +300,7 @@ private void OnDestroy() {
},
score = new DiffScore {
difficulty = micInputs[0].player.chosenDifficulty,
score = (int) math.round(scoreKeeper.score),
score = (int) math.round(scoreKeeper.Score),
stars = math.clamp((int) starsKeeper.Stars, 0, 6)
},
notesHit = sectionsHit,
Expand Down Expand Up @@ -733,18 +733,20 @@ private void UpdateEndPhrase() {
}
}

// get portion sang from bar graphic
// Get portion sang from bar graphic
// WHAT. Redo this!
var sectionPercents = new List<float>();
foreach (var bar in barImages) {
sectionPercents.Add(bar.fillAmount);
}
sectionPercents.Sort();
// add to ScoreKeeper

// Add to ScoreKeeper
for (int i = sectionPercents.Count - 1; i >= 0; --i) {
var phraseScore = math.clamp((double)sectionPercents[i] * ptsPerPhrase, 0, ptsPerPhrase);
if (i != sectionPercents.Count-1)
var phraseScore = math.clamp((double) sectionPercents[i] * ptsPerPhrase, 0, ptsPerPhrase);
if (i != sectionPercents.Count - 1) {
phraseScore *= 0.1;
Debug.Log($"player earned {phraseScore:N0}pts");
}
scoreKeeper.Add(Multiplier * phraseScore);
}

Expand Down
18 changes: 9 additions & 9 deletions Assets/Script/PlayMode/Play.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public float SongLength {
private int lyricPhraseIndex = 0;

// tempo (updated throughout play)
public float curBeatPerSecond { get; private set; } = 0f;
public float curTempo => curBeatPerSecond * 60; // BPM
public float CurrentBeatsPerSecond { get; private set; } = 0f;
public float CurrentTempo => CurrentBeatsPerSecond * 60; // BPM

private List<AbstractTrack> _tracks;

Expand Down Expand Up @@ -104,18 +104,18 @@ private IEnumerator StartSong() {

// Determine if speed is not 1
bool isSpeedUp = Math.Abs(speed - 1) > float.Epsilon;

// Load MOGG if RB_CON, otherwise load stems
if (song.songType == SongInfo.SongType.RB_CON) {
Debug.Log(song.moggInfo.ChannelCount);

GameManager.AudioManager.LoadMogg(song.moggInfo, isSpeedUp);
} else {
var stems = AudioHelpers.GetSupportedStems(song.RootFolder);

GameManager.AudioManager.LoadSong(stems, isSpeedUp);
}

SongLength = GameManager.AudioManager.AudioLengthF;

GameUI.Instance.SetLoadingText("Loading chart...");
Expand Down Expand Up @@ -197,7 +197,7 @@ private void LoadChart() {

// initialize current tempo
if (chart.beats.Count > 2)
curBeatPerSecond = chart.beats[1] - chart.beats[0];
CurrentBeatsPerSecond = chart.beats[1] - chart.beats[0];
}

private void Update() {
Expand Down Expand Up @@ -275,15 +275,15 @@ private void Update() {
while (chart.beats.Count > beatIndex && chart.beats[beatIndex] <= SongTime) {
foreach (var track in _tracks) {
if (!track.IsStarPowerActive || !GameManager.AudioManager.UseStarpowerFx) continue;

GameManager.AudioManager.PlaySoundEffect(SfxSample.Clap);
break;
}
BeatEvent?.Invoke();
beatIndex++;

if (beatIndex < chart.beats.Count) {
curBeatPerSecond = 1 / (chart.beats[beatIndex] - chart.beats[beatIndex - 1]);
CurrentBeatsPerSecond = 1 / (chart.beats[beatIndex] - chart.beats[beatIndex - 1]);
}
}

Expand Down Expand Up @@ -381,7 +381,7 @@ public void Exit() {

// Unpause just in case
Time.timeScale = 1f;

_tracks.Clear();

GameManager.Instance.LoadScene(SceneIndex.MENU);
Expand Down
29 changes: 13 additions & 16 deletions Assets/Script/PlayMode/ScoreDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine;

public class ScoreDisplay : MonoBehaviour {
[SerializeField]
private TextMeshProUGUI scoreText;
[SerializeField]
private TextMeshProUGUI scoreText;

private void Start() {
scoreText.text = $"<mspace=0.59em>0";
}
private void Start() {
scoreText.text = $"<mspace=0.59em>0";
}

private void OnEnable() {
private void OnEnable() {
ScoreKeeper.OnScoreChange += OnScoreChange;
}

private void OnDisable() {
ScoreKeeper.OnScoreChange -= OnScoreChange;
}
private void OnDisable() {
ScoreKeeper.OnScoreChange -= OnScoreChange;
}

private void OnScoreChange() {
scoreText.text = $"<mspace=0.59em>{ScoreKeeper.TotalScore:n0}";
}
private void OnScoreChange() {
scoreText.text = $"<mspace=0.59em>{ScoreKeeper.TotalScore:n0}";
}
}
34 changes: 14 additions & 20 deletions Assets/Script/PlayMode/ScoreKeeper.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Unity.Mathematics;

using YARG.Data;

// Score keeping for each track
public class ScoreKeeper {
public delegate void ScoreAction();
Expand All @@ -14,32 +9,31 @@ public class ScoreKeeper {
/// </summary>
public static event ScoreAction OnScoreChange;

// keep track of all instances to calculate the band total
// keep track of all instances to calculate the band total
public static List<ScoreKeeper> instances = new();
public static double TotalScore {
get {
public static double TotalScore {
get {
double sum = 0;
foreach (var ins in instances) {
sum += ins.score;
foreach (var ins in instances) {
sum += ins.Score;
}
return sum;
}
}
}

public static void Reset() {
instances.Clear();
}

public double score { get; private set; } = 0;
public double Score { get; private set; } = 0;

/// <summary>
/// Add points for this keeper. Fires the OnScoreChange event.
/// </summary>
/// <param name="points"></param>
public void Add(double points) {
score += points;
if (OnScoreChange != null)
OnScoreChange();
Score += points;
OnScoreChange?.Invoke();
}

/// <summary>
Expand All @@ -49,25 +43,25 @@ public void Add(double points) {
/// <param name="notesMax"></param>
/// <returns>The bonus points earned.</returns>
public double AddSolo(int notesHit, int notesMax) {
double ratio = (double)notesHit / notesMax;
double ratio = (double) notesHit / notesMax;

if (ratio <= 0.5)
return 0;

// linear
double multiplier = math.clamp((ratio - 0.5)/0.5, 0, 1);
double multiplier = math.clamp((ratio - 0.5) / 0.5, 0, 1);
double ptsEarned = 100 * notesHit * multiplier;

// +5% bonus points
// TODO: limit to FC? decide to keep at all?
if (ratio >= 1)
ptsEarned = 1.05*ptsEarned;
ptsEarned = 1.05 * ptsEarned;

Add(ptsEarned);
return ptsEarned;
}

public ScoreKeeper() {
public ScoreKeeper() {
instances.Add(this);
}
}
Loading

0 comments on commit 89c0737

Please sign in to comment.