using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; //Define the system managing the events. (Singleton) //TODO: Switch to a registering approach for events public sealed class EventManager : MonoBehaviour { //Singleton private static EventManager _instance=null; public static EventManager Instance { get { if(_instance is null) Debug.LogError("Missing EventManager instance"); return _instance; } } [HideInInspector] public bool ready = false; //Wether the ClientManager is initialized [SerializeField] float SpawnRange = 1.0f; //Range of an event spawn from its origin (real max distance = 2*range) [SerializeField] int nbMaxEvents = 1; //Maximum active clients [SerializeField] float spawnChance = 100.0f; //Probability of an event to spawn // [SerializeField] // float eventSpawnTimer = 0.5f; //Intial time before first spawn (pseudo-random after that) // [SerializeField] // float maxTimeNewEvents = 2.0f; //Longest waiting time for new clients // bool eventSpawnReady = false; [SerializeField] string EventRessourceFolder = "Events"; //Ressource folder w/ events prefabs private Object[] events; GameObject EventContainer=null; List eventIDs = new List(); //List of active event ID private Dictionary coroutines= new Dictionary(); //Dict of EventManager coroutines associated to each client ID //Spawn an event near position with a probability of spawnChance% public void spawnEvent(Vector2 position, float spawnChance = 100.0f) { Vector3 spawnPoint; if (Random.Range(0.0f, 99.9f)