// Update is called once per frame void Update() { if (spawnerState == SpawnerStates.waiting) { timeBeforeSpawnStart -= Time.deltaTime; if (timeBeforeSpawnStart <= 0) { spawnerState = SpawnerStates.ready; } } if (spawnerState == SpawnerStates.ready) { m_timer -= Time.deltaTime; if (m_timer <= 0) { unitIndex++; if (unitIndex > spawnPoints.Length - 1) { unitIndex = 0; } SpawnUnits(); ResetSpawnTimer(); } } }
// Update is called once per frame void Update() { // if (FindObjectOfType<GameStateManager>().isPaused == true) // return; if (spawnerState == SpawnerStates.waiting) { timeBeforeSpawnStart -= Time.deltaTime; if (timeBeforeSpawnStart <= 0) { SpawnUnits(); spawnerState = SpawnerStates.ready; } } else if (spawnerState == SpawnerStates.ready) { if (m_timer > 0) { m_timer -= Time.deltaTime; } else { SpawnUnits(); ResetSpawnTimer(); } } }
public void StopSpawnCicle() { ActualState = SpawnerStates.WAITING; animatorController.SetBool("IsSpawning", false); if (spawnCicle != null) { StopCoroutine(spawnCicle); } spawnCicle = null; }
// Essa função apenas spawnad e seta o statos do spawner de acordo com o limimte // Ela não controla os turnos public IEnumerator SpawnCicle() { // Se o spawner atinge seu limite ele para if (countSpawnedEnemys >= spawnLimit || actualState == SpawnerStates.WAITING) { actualState = SpawnerStates.WAITING; Debug.Log("Limite spawn atingido estado de espera"); yield break; } for (int i = 0; i < spawnLimit; i++) { SpawnEnemy(); // Faz a cazerna esperar para spawnar o próximo yield return(new WaitForSeconds(spawnFrequency)); } yield break; }
public void StartSpawnCicle() { ActualState = SpawnerStates.SPAWNING; animatorController.SetBool("IsSpawning", true); spawnCicle = StartCoroutine(SpawnCicle()); }
void Start() { spawnerState = SpawnerStates.waiting; m_timer = timeBetweenSpawns; spawnPoints = GetComponentsInChildren <HangerSpawner>(); }
void Start() { spawnerState = SpawnerStates.waiting; m_timer = timeBetweenSpawns; spawnPoints = FindObjectsOfType <HangerSpawner>(); }