campfire/Assets/Scripts/GameOverMenu.cs

26 lines
688 B
C#
Raw Normal View History

2020-04-19 02:32:20 +02:00
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;
2020-04-19 03:02:40 +02:00
Canvas.alpha = Mathf.Lerp(Canvas.alpha, IsGameOver ? 1 : 0, instantTransition ? 1 : 2f * Time.deltaTime);
2020-04-19 02:32:20 +02:00
Canvas.interactable = IsGameOver;
}
}