Esempio n. 1
0
    /// <summary>
    /// Spawns waves of enemies using enemyTypeXform at a set interval
    /// </summary>
    private IEnumerator SpawnEnemiesIncrementally()
    {
        _particleManager.CreateSpawnEffects(_xform.position);
        print(_particleManager);
        // How many enemies should we spawn?
        var count = numberOfEnemiesToSpawn;

        while (count >= 0)
        {
            // Spawn an enemy & set spawn location within spawn radius
            SpawnEnemies();
            count--;

            yield return(new WaitForSeconds(incrementSpawnInterval));
        }
    }
    /// <summary>
    /// Spawns waves of enemies using enemyTypeXform at a set interval
    /// </summary>
    /// <param name="enemyXform">Type of enemy to spawn. Default is Xform used in SpawnMananger</param>
    /// <param name="numToSpawn">How many enemies do we create?</param>
    /// <param name="interval">How often do they spawn?</param>
    public IEnumerator SpawnEnemiesIncrementally(Transform enemyXform, int numToSpawn, float interval)
    {
        // Resets spawn point to new location
        MoveSpawnPoint();

        // Create particles at spawn location
        _particleManager.CreateSpawnEffects(enemyXform.position);

        // How many enemies should we spawn?
        var count = numToSpawn;

        while (count > 0)
        {
            // Spawn an enemy & set spawn location within spawn radius
            SpawnEnemiesWithinSphere(enemyXform);
            count--;

            // Add enemy to the list, so that we can track how many are on screen at once
            numOfEnemiesInScene++;

            // call this function recursively, every (x) seconds
            yield return(new WaitForSeconds(interval));
        }
    }
Esempio n. 3
0
    /// <summary>
    /// Spawns object at SpawnPoint, which is set in the editor
    /// </summary>
    private IEnumerator OnBecameInvisible()
    {
        // Set state and draw particles where player just died
        _state = State.Explosion;
        _particleManager.CreatePlayerExplosionEffects(xform.position);

        // Make player ship invisible
        gameObject.renderer.enabled = false;
        // Move spawn point and set player location to that point
        MoveSpawnPoint();

        yield return(new WaitForSeconds(_shipInvisibleTime));

        if (GameManager.lives > 0)
        {
            // Remove any power ups, if they were applied
            ResetDefaultValues();


            xform.position = _playerSpawnPoint.position;

            // Set player to invincible while flashing & create particle effect at spawn point
            _state = State.Invincible;
            _particleManager.CreateSpawnEffects(xform.position); //TODO: Why is this called twice??


            // Make player ship visible again
            gameObject.renderer.enabled = true;

            // Make ship flash
            StartCoroutine(gameObject.GetComponent <FlashingObject>().Flash());

            yield return(new WaitForSeconds(2.2f));
        }
        // Not flashing anymore? Now you can take hits
        _state = State.Playing;
    }