コード例 #1
0
    IEnumerator SpawnBEATz(WaveConfiguration waveConfig, GameObject BEAT, GameObject newBEAT)
    {
        if (!waveConfig.GetRandomSpawn())
        {
            // We instantiate BEATz based on the data that the Spawn Pattern is holding.
            newBEAT.GetComponent <SpawnPattern>().SetWaveConfiguration(waveConfig);

            // Cooldown before spawning another BEAT
            yield return(new WaitForSeconds(waveConfig.GetBEATzPerSecond()));
        }

        else
        {
            Vector2 randomBEATPosition = new Vector2(Random.Range(-8, 8), Random.Range(-4, 4));

            // Spawn BEATz in randon position
            Instantiate(BEAT, randomBEATPosition, Quaternion.identity);

            // Cooldown before spawning another BEAT
            yield return(new WaitForSeconds(waveConfig.GetBEATzPerSecond()));
        }
    }