TowerDefenseGame/Assets/Scripts/Runtime/GameManagement/EnemySpawnerManager.cs
Nico 4fe5fb18e8 Recreate enemy management
Remove separate states
Will contain all states in one type of enemy management script
Will use enemy manager to update states of each enemy and spawning
2025-07-09 09:54:28 -07:00

49 lines
1.3 KiB
C#

using AI.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UIElements;
public class EnemySpawnerManager : MonoBehaviour {
public static EnemySpawnerManager Instance;
[SerializeField] public GameObject GoblerPreFab;
public static Dictionary<GoblerStateManager, GameObject> Goblers = new Dictionary<GoblerStateManager, GameObject>();
public static Action UpdateTick;
public static Action GizmoTick;
public static int MaxGoblers = 1;
public class Gobler {
public GameObject Object;
public GoblerStateManager Manager;
public Gobler(GameObject obj, GoblerStateManager manager) {
Object = obj;
Manager = manager;
}
}
public void Awake() {
Instance = this;
}
public static void RemoveGobler(GoblerStateManager goblerManager){
Destroy(Goblers[goblerManager]);
Goblers.Remove(goblerManager);
}
public void Update() {
if (Goblers.Count() < MaxGoblers){
var gobler = Instantiate(GoblerPreFab, this.transform.position, Quaternion.identity);
Goblers.Add(new GoblerStateManager(gobler), gobler);
}
UpdateTick?.Invoke();
}
public static void OnDrawGizmos() {
GizmoTick?.Invoke();
}
}