TO SQUASH: Changes.
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class ScoreChecker : MonoBehaviour
|
||||
{
|
||||
public AudioSource winSound;
|
||||
|
||||
public AudioSource loseSound;
|
||||
|
||||
public Fader fadeOut;
|
||||
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void resetFader()
|
||||
{
|
||||
Invoke(nameof(checkScore), 0.5f);
|
||||
}
|
||||
|
||||
private IEnumerator PlayAudioThenActivateGameObject(AudioSource audio, bool showGui)
|
||||
{
|
||||
audio.Play();
|
||||
|
||||
if (showGui) {
|
||||
// Activate your GUI here
|
||||
} else {
|
||||
yield return new WaitUntil(() => audio.time >= audio.clip.length);
|
||||
fadeOut.resetFader();
|
||||
}
|
||||
}
|
||||
|
||||
void checkScore()
|
||||
{
|
||||
int currentScore = PlayerPrefs.GetInt("CurrentScore");
|
||||
AudioSource audio = null;
|
||||
bool showGui = false;
|
||||
|
||||
if (GameSetup.IsHighScore(currentScore)) {
|
||||
audio = winSound;
|
||||
showGui = true;
|
||||
} else {
|
||||
audio = loseSound;
|
||||
}
|
||||
|
||||
StartCoroutine(PlayAudioThenActivateGameObject(audio, showGui));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7d837793868a819eb438a6336078dd7
|
||||
Reference in New Issue
Block a user