You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
FlyingFred/Assets/Scripts/GameManager.cs

42 lines
1.1 KiB
C#

1 month ago
using CnControls;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public enum DifficultyLevel
{
easy, medium, hard,
}
public class GameManager : MonoBehaviour
{
public DifficultyLevel difficultyLevel;
public List<int> difficultyScores;
public float Score;
public static GameManager instance;
public bool isGameOver = false;
public static UnityEvent DifficultyIncreased=new();
public void Awake()
{
instance = this;
}
private void Start()
{
StartCoroutine(ScoreUpdateRoutine());
}
IEnumerator ScoreUpdateRoutine()
{
difficultyLevel = DifficultyLevel.easy;
while (!isGameOver)
{
Score++;
UIManager.instance.ScoreText.text = Score.ToString();
if(Score > difficultyScores[(int)difficultyLevel] && (int)difficultyLevel< difficultyScores.Count-1)
{
difficultyLevel++;
DifficultyIncreased.Invoke();
}
yield return new WaitForSeconds(1);
}
}
}