예제 #1
0
 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);
             }
         }
     }
 }
예제 #2
0
    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);
    }
예제 #3
0
 /// <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);