118 lines
2.3 KiB
C#
118 lines
2.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
public enum Difficulty
|
|
{
|
|
Easy,
|
|
Normal,
|
|
Hard
|
|
}
|
|
|
|
public enum GameMode
|
|
{
|
|
Defend,
|
|
Training
|
|
}
|
|
|
|
public enum SubGameMode
|
|
{
|
|
Arcade,
|
|
Simulation
|
|
}
|
|
|
|
private static GameManager _instance;
|
|
private Difficulty _difficulty = Difficulty.Easy;
|
|
private GameMode _gameMode = GameMode.Defend;
|
|
private SubGameMode _subGameMode = SubGameMode.Arcade;
|
|
private bool _isUIMenuOpen = false;
|
|
|
|
public static GameManager Instance
|
|
{
|
|
get
|
|
{
|
|
if (_instance is null)
|
|
Debug.LogError("GameManager is null");
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
_instance = this;
|
|
}
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyUp(KeyCode.Space))
|
|
{
|
|
ReloadScene();
|
|
}
|
|
|
|
if (Input.GetKeyUp(KeyCode.KeypadEnter) && Application.isEditor)
|
|
{
|
|
UIMenuManager uiManager = GetComponent<UIMenuManager>();
|
|
uiManager.SetGameMode(GameMode.Defend);
|
|
uiManager.SetSubGameMode(SubGameMode.Arcade);
|
|
uiManager.SetDifficulty(Difficulty.Easy);
|
|
}
|
|
|
|
}
|
|
|
|
public void ReloadScene()
|
|
{
|
|
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex, LoadSceneMode.Single);
|
|
}
|
|
|
|
public Difficulty GetDifficulty()
|
|
{
|
|
return _difficulty;
|
|
}
|
|
|
|
public GameMode GetGameMode()
|
|
{
|
|
return _gameMode;
|
|
}
|
|
|
|
public SubGameMode GetSubGameMode()
|
|
{
|
|
return _subGameMode;
|
|
}
|
|
|
|
public bool GetIsUIMenuOpen()
|
|
{
|
|
return _isUIMenuOpen;
|
|
}
|
|
|
|
public void SetDifficulty(Difficulty d)
|
|
{
|
|
_difficulty = d;
|
|
}
|
|
|
|
public void SetGameMode(GameMode gm)
|
|
{
|
|
_gameMode = gm;
|
|
}
|
|
|
|
public void SetSubGameMode(SubGameMode sgm)
|
|
{
|
|
_subGameMode = sgm;
|
|
}
|
|
|
|
public void SetIsUIMenuOpen(bool value)
|
|
{
|
|
_isUIMenuOpen = value;
|
|
}
|
|
|
|
public void GameStart()
|
|
{
|
|
if (_gameMode.Equals(GameMode.Defend))
|
|
{
|
|
GetComponent<MapManager>().SpawnWaveScript();
|
|
GetComponent<WaveManager>().SetToStart();
|
|
}
|
|
}
|
|
}
|