TowerDefenseGame/Assets/Scripts/Runtime/GameManagement/EnemySpawnerManager.cs
Nico 0ef60e5828 Add third party plugin NavMeshPlus
Add A* pathing to enemies
Add choice between havving Goblers chase player as priority or go to crystal
2025-07-09 19:14:28 -07:00

53 lines
1.4 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;
using static EnemySpawnerManager;
public class EnemySpawnerManager : MonoBehaviour {
public static EnemySpawnerManager Instance;
[SerializeField] public GameObject GoblerPreFab;
private GameObjectPool GoblerPool;
public static Dictionary<GoblerStateManager, GameObject> Goblers = new Dictionary<GoblerStateManager, GameObject>();
public static Action UpdateTick;
public static Action GizmoTick;
public static int MaxGoblers = 100;
public class Gobler {
public GameObject Object;
public GoblerStateManager Manager;
public Gobler(GameObject obj, GoblerStateManager manager) {
Object = obj;
Manager = manager;
}
}
public void Awake() {
Instance = this;
Goblers.Clear();
GoblerPool = new GameObjectPool(GoblerPreFab, 50, 200);
}
public static void RemoveGobler(GoblerStateManager goblerManager) {
Destroy(Goblers[goblerManager]);
Goblers.Remove(goblerManager);
}
public void Update() {
while (Goblers.Count() < MaxGoblers) {
var gobler = GoblerPool.Get(transform.position, Quaternion.identity);
Goblers.Add(new GoblerStateManager(gobler), gobler);
}
UpdateTick?.Invoke();
}
public static void OnDrawGizmos() {
GizmoTick?.Invoke();
}
}