void Update() { if (CreepQueue != null) { if (CreepQueue.Count > 0 && SpawnPool.Count > 0) { //Counts down to spawn SpawnTimer -= Time.deltaTime; if (SpawnTimer <= 0) { //Gets next creep in queue BaseCreep creep = CreepQueue.Dequeue(); //Gets next SpawnPool object GameObject poolObject = SpawnPool.Dequeue(); //Sets object to active poolObject.SetActive(true); //Gets component for creep handling and sets correct creep poolObject.GetComponent<CreepMovementTesting>().CurrentCreep = creep; Debug.Log("Spawning Creep"); //Reset timer SpawnTimer = SpawnDelay; SpawnCounter++; Debug.Log(SpawnCounter); } } } }
private void SpawnCoin() { Vector2 min = levelBounds.Min; float x = Random.Range(min.x, levelBounds.Max.x); float playerX = player.position.x; while (Mathf.Abs(playerX - x) < 2f) { x = Random.Range(min.x, levelBounds.Max.x); } GameObject coin = spawnPool.Dequeue(); coin.transform.position = new Vector2(x, min.y); coin.SetActive(true); }
/// <summary> /// Método para hacer aparecer una roca, llamado a través de evento de animación. /// </summary> private void Throw() => spawnPool.Dequeue().SetActive(true);