campfire/Assets/Scripts/GameOverMenu.cs

26 lines
688 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[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 : 5f * Time.deltaTime);
Canvas.interactable = IsGameOver;
}
}