campfire/Assets/Scripts/GameState.cs

28 lines
659 B
C#
Raw Permalink Normal View History

2020-04-19 01:12:29 +02:00
using UnityEngine;
[System.Serializable]
public enum State {
Playing,
Paused,
GameOver
}
public class GameState : MonoBehaviour {
public State Current = State.Playing;
private void Update() {
if (Input.GetKeyDown(KeyCode.Escape)) {
switch (Current) {
case State.Playing:
Current = State.Paused;
break;
case State.Paused:
Current = State.Playing;
break;
}
}
2020-04-19 04:33:04 +02:00
Time.timeScale = Mathf.Lerp(Time.timeScale, Current == State.Paused ? 0 : 1, 6f * Time.unscaledDeltaTime);
2020-04-19 01:12:29 +02:00
}
}