2020-04-18 18:26:35 +02:00
|
|
|
|
using UnityEngine;
|
2020-04-19 22:09:31 +02:00
|
|
|
|
using UnityEngine.UI;
|
2020-04-18 18:26:35 +02:00
|
|
|
|
|
|
|
|
|
[RequireComponent(typeof(CanvasGroup))]
|
|
|
|
|
public class PauseMenu : MonoBehaviour {
|
2020-04-19 01:12:29 +02:00
|
|
|
|
public GameState GameState;
|
2020-04-19 22:09:31 +02:00
|
|
|
|
public Options Options;
|
|
|
|
|
|
|
|
|
|
[Header("Option inputs")]
|
|
|
|
|
public Toggle InvertMouseY;
|
|
|
|
|
public Toggle CameraBobbing;
|
|
|
|
|
public Slider MouseSensitivity;
|
|
|
|
|
public Slider MasterVolume;
|
|
|
|
|
public Slider CampfireVolume;
|
|
|
|
|
public Slider AmbientVolume;
|
|
|
|
|
public Slider FootstepVolume;
|
2020-04-18 18:26:35 +02:00
|
|
|
|
|
|
|
|
|
private CanvasGroup Canvas;
|
2020-04-19 01:12:29 +02:00
|
|
|
|
private bool Paused {
|
|
|
|
|
get {
|
|
|
|
|
return GameState.Current == State.Paused;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-18 18:26:35 +02:00
|
|
|
|
|
|
|
|
|
private void Awake() {
|
|
|
|
|
Canvas = GetComponent<CanvasGroup>();
|
2020-04-19 20:04:45 +02:00
|
|
|
|
Fade(true);
|
2020-04-18 18:26:35 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 22:09:31 +02:00
|
|
|
|
private void Start() {
|
|
|
|
|
InvertMouseY.isOn = Options.InvertMouseY;
|
|
|
|
|
CameraBobbing.isOn = Options.CameraBobbing;
|
|
|
|
|
MouseSensitivity.value = Options.MouseSensitivity;
|
|
|
|
|
MasterVolume.value = Options.MasterVolume;
|
|
|
|
|
CampfireVolume.value = Options.CampfireVolume;
|
|
|
|
|
AmbientVolume.value = Options.AmbientVolume;
|
|
|
|
|
FootstepVolume.value = Options.FootstepVolume;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 18:26:35 +02:00
|
|
|
|
private void Update() {
|
2020-04-19 20:04:45 +02:00
|
|
|
|
Fade(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Fade(bool instant) {
|
|
|
|
|
Canvas.alpha = Mathf.Lerp(Canvas.alpha, Paused ? 1 : 0, instant ? 1 : 10f * Time.unscaledDeltaTime);
|
|
|
|
|
Canvas.blocksRaycasts = Paused;
|
2020-04-20 04:05:26 +02:00
|
|
|
|
Canvas.interactable = Paused;
|
2020-04-18 18:26:35 +02:00
|
|
|
|
}
|
2020-04-19 22:09:31 +02:00
|
|
|
|
|
|
|
|
|
public void Resume() {
|
|
|
|
|
GameState.Current = State.Playing;
|
|
|
|
|
}
|
2020-04-20 04:42:36 +02:00
|
|
|
|
|
|
|
|
|
public void Quit() {
|
|
|
|
|
Application.Quit();
|
|
|
|
|
}
|
2020-04-18 18:26:35 +02:00
|
|
|
|
}
|