Add scores to JustSign
This commit is contained in:
@@ -25,6 +25,11 @@ public class JustSignController : MonoBehaviour
|
||||
/// </summary>
|
||||
public TMP_Text feedBack;
|
||||
|
||||
/// <summary>
|
||||
/// The current score
|
||||
/// </summary>
|
||||
public TMP_Text scoreDisplay;
|
||||
|
||||
/// <summary>
|
||||
/// The zone that the player should be hitting with his or her inputs
|
||||
/// </summary>
|
||||
@@ -85,16 +90,41 @@ public class JustSignController : MonoBehaviour
|
||||
/// </summary>
|
||||
private int perfectBoundary = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Score obtained when getting a perfect hit
|
||||
/// </summary>
|
||||
private int perfectScore = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Max distance from hit zone to get good score
|
||||
/// </summary>
|
||||
private int goodBoundary = 120;
|
||||
|
||||
/// <summary>
|
||||
/// Score obtained when getting a good hit
|
||||
/// </summary>
|
||||
private int goodScore = 3;
|
||||
|
||||
/// <summary>
|
||||
/// Max distance from hit zone to get meh score
|
||||
/// </summary>
|
||||
private int mehBoundary = 200;
|
||||
|
||||
/// <summary>
|
||||
/// Score obtained when getting a meh hit
|
||||
/// </summary>
|
||||
private int mehScore = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Score obtained when getting a terrible hit
|
||||
/// </summary>
|
||||
private int terribleScore = -3;
|
||||
|
||||
/// <summary>
|
||||
/// Score obtained when symbol goes offscreen
|
||||
/// </summary>
|
||||
private int offscreenScore = -5;
|
||||
|
||||
/// <summary>
|
||||
/// Time at which the last symbol was spawned
|
||||
/// </summary>
|
||||
@@ -110,12 +140,11 @@ public class JustSignController : MonoBehaviour
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
scoreDisplay.text = "Score: " + score.ToString();
|
||||
themeList = ThemeLoader.LoadJson();
|
||||
currentTheme = FindThemeByName(PlayerPrefs.GetString("themeName"));
|
||||
words = currentTheme.words;
|
||||
lastSpawn = Time.time;
|
||||
Debug.Log(hitZone.transform.position.x);
|
||||
Debug.Log(hitZone.transform.position.y);
|
||||
SpawnNewSymbol();
|
||||
}
|
||||
|
||||
@@ -123,23 +152,22 @@ public class JustSignController : MonoBehaviour
|
||||
/// Update is called once per frame
|
||||
/// </summary>
|
||||
void Update()
|
||||
{ /*
|
||||
Debug.Log("X");
|
||||
Debug.Log(activeSymbols[0].transform.position.x);
|
||||
Debug.Log("Y");
|
||||
Debug.Log(activeSymbols[0].transform.position.y);
|
||||
*/
|
||||
{
|
||||
// Destroy the oldest symbol if the current input matches it
|
||||
if (answerField.text.ToLower() == activeWords[0]) {
|
||||
int difference = Math.Abs((int) (activeSymbols[0].transform.position.x - hitZone.transform.position.x));
|
||||
if (difference < perfectBoundary) {
|
||||
feedBack.text = "Perfect!";
|
||||
score += perfectScore;
|
||||
} else if (difference < goodBoundary) {
|
||||
feedBack.text = "Good!";
|
||||
score += goodScore;
|
||||
} else if (difference < mehBoundary) {
|
||||
feedBack.text = "Meh...";
|
||||
score += mehScore;
|
||||
} else {
|
||||
feedBack.text = "Terrible!";
|
||||
score += terribleScore;
|
||||
}
|
||||
|
||||
DestroyRightmostSymbol();
|
||||
@@ -149,6 +177,7 @@ public class JustSignController : MonoBehaviour
|
||||
// Destroy the oldest symbol if it leaves the screen
|
||||
if (activeSymbols[0].GetComponent<RectTransform>().localPosition.x > -trackX) {
|
||||
DestroyRightmostSymbol();
|
||||
score += offscreenScore;
|
||||
}
|
||||
|
||||
// Spawn new symbol every spawn period
|
||||
@@ -163,6 +192,8 @@ public class JustSignController : MonoBehaviour
|
||||
RectTransform rectTransform = symbol.GetComponent<RectTransform>();
|
||||
rectTransform.localPosition = new Vector3(rectTransform.localPosition.x + Time.deltaTime * moveSpeed, trackY, 0);
|
||||
}
|
||||
|
||||
scoreDisplay.text = "Score: " + score.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user