33 lines
833 B
C#
33 lines
833 B
C#
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
[RequireComponent(typeof(CanvasGroup))]
|
|
public class GameOverMenu : MonoBehaviour {
|
|
public GameState GameState;
|
|
|
|
private CanvasGroup Canvas;
|
|
|
|
private void Awake() {
|
|
Canvas = GetComponent<CanvasGroup>();
|
|
UpdateCanvas(true);
|
|
}
|
|
|
|
private void Update() {
|
|
UpdateCanvas(false);
|
|
}
|
|
|
|
private void UpdateCanvas(bool instantTransition) {
|
|
bool IsGameOver = GameState.Current == State.GameOver;
|
|
Canvas.alpha = Mathf.Lerp(Canvas.alpha, IsGameOver ? 1 : 0, instantTransition ? 1 : 2f * Time.deltaTime);
|
|
Canvas.blocksRaycasts = IsGameOver;
|
|
}
|
|
|
|
public void Replay() {
|
|
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
|
}
|
|
|
|
public void Exit() {
|
|
Application.Quit();
|
|
}
|
|
}
|