using UnityEngine;
public class GameManager : MonoBehaviour
{
public static GameManager instance;
public GameObject enemyGroupPrefab;
public Transform spawnPoint;
public float baseSpeed = 2f;
private int level = 1;
private GameObject currentEnemies;
void Awake()
{
instance = this;
}
void Start()
{
SpawnEnemies();
}
void Update()
{
// If no enemies remain
if (GameObject.FindGameObjectsWithTag("Enemy").Length == 0)
{
LevelUp();
}
}
void SpawnEnemies()
{
currentEnemies = Instantiate(enemyGroupPrefab, spawnPoint.position, Quaternion.identity);
EnemyGroup movement = currentEnemies.GetComponent<EnemyGroup>();
if (movement != null)
{
movement.speed = baseSpeed + level;
}
}
void LevelUp()
{
level++;
Debug.Log("Level: " + level);
SpawnEnemies();
}
}