示例#1
0
    // Method to instantiate particle systems resembling fire works timed one after the other
    private void SetOffFireworks()
    {
        Vector2[] posArray = coinCreator.GetSpawnPoints();
        int       positionIndex;
        Vector2   randomPos;
        Vector3   spawnPos;
        float     timeToNext;

        Color[] colorAray = { Color.red, Color.green, Color.yellow, Color.blue, Color.white, Color.cyan, Color.magenta };

        for (int i = 0; i < nrOfFireworks; i++)
        {
            positionIndex = Random.Range(1, posArray.Length);
            randomPos     = posArray[positionIndex];
            spawnPos      = new Vector3(randomPos.x, randomPos.y, 0); // Save a random cell position from the cell grid
            timeToNext    = 0.5f * i;                                 // Time of instantiation of next firework
            StartCoroutine(SpawnFireworks(timeToNext, spawnPos, colorAray[i]));
        }
    }