TowerDefenseGame/Assets/Scripts/Runtime/GameManagement/GameManager.cs
Nico a492afdf1b Switch over to isometric map and set navmesh
Refactor attack animator
Refactor SpawnerManager - utilize SO (SpawnableEnemyInfo)
2025-07-18 23:51:27 -07:00

45 lines
998 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity.VisualScripting;
using UnityEngine;
public class GameManager : MonoBehaviour {
[SerializeField] public float Timescale = 1;
private float PrevTimescale = 1;
[SerializeField] private GameObject CrystalRef;
public static GameObject Crystal;
public static bool IsPaused { get; private set; }
[SerializeField] private GameObject pauseMenuUI;
private void Awake() {
Crystal = CrystalRef;
}
void Update() {
if (Input.GetKeyDown(KeyCode.Escape))
TogglePause();
SetTimeScale();
}
public void TogglePause() {
IsPaused = !IsPaused;
Time.timeScale = IsPaused ? 0f : 1f;
AudioListener.pause = IsPaused;
pauseMenuUI?.SetActive(IsPaused);
}
public void SetTimeScale() {
if (IsPaused) return;
if (PrevTimescale != Timescale) {
Time.timeScale = Timescale;
PrevTimescale = Timescale;
}
}
}