//-------------------------------------------------------------- // *** RESPAWNING *** public void RespawnCrystal(Char_Crystal crystal, Vector3 position) { // Show the ai's mesh renderer crystal.gameObject.GetComponentInChildren <Renderer>().enabled = true; // Add ai (newAI variable) to active minion array _POOL_ALIVE_MINIONS.Add(crystal.gameObject); // Remove ai (new AI variable) from dead minion array _POOL_DEAD_MINIONS.RemoveAt(_POOL_DEAD_MINIONS.Count - 1); // Set position crystal.transform.position = position; // Set LinearGoToTarget behaviour to be active crystal.GetComponent <LinearGoToTarget>().enabled = true; // Disable agency crystal.GetComponent <NavMeshAgent>().enabled = false; // Disable all behaviours crystal.SetWanderEnable(false); crystal.SetFleeEnable(false); crystal.SetSeekEnable(false); }
public void Start() { // Get all ai prefabs in the scene GameObject[] startupAi = GameObject.FindGameObjectsWithTag("Enemy"); foreach (var ai in startupAi) { // If the AI is meant to be active at the start of the match if (ai.GetComponent <Char_Crystal>().GetSpawningTime() == AiSpawningTime.MatchStart) { // Add to alive pool _POOL_ALIVE_MINIONS.Add(ai.gameObject); // Enable agency ai.GetComponent <NavMeshAgent>().enabled = true; } // Ai is not meant to be active in the arena at match startup else { // Remove the minion from the arena ai.GetComponent <SkinnedMeshRenderer>().enabled = false; ai.transform.position = new Vector3(1000, 1, 1000); // Disable ALL behaviours Char_Crystal crystal = ai.GetComponent <Char_Crystal>(); crystal.SetFleeEnable(false); crystal.SetWanderEnable(false); crystal.SetSeekEnable(false); crystal.SetLinearSeekEnable(false); } // Allocate minor types to their pool if (ai.GetComponent <Char_Crystal>().GetVariantType() == Char_Crystal.CrystalType.Minor) { // Add to minor pool _POOL_MINOR_MINIONS.Add(ai.gameObject); } // Allocate major types to their pool if (ai.GetComponent <Char_Crystal>().GetVariantType() == Char_Crystal.CrystalType.Major) { // Add to major pool _POOL_MAJOR_MINIONS.Add(ai.gameObject); } // Allocate cursed types to their pool if (ai.GetComponent <Char_Crystal>().GetVariantType() == Char_Crystal.CrystalType.Cursed) { // Add to cursed pool _POOL_CURSED_MINIONS.Add(ai.gameObject); } } }