示例#1
0
    IEnumerator SpawnEnemy()
    {
        int NORMAL_CAR  = 0;
        int RAINBOW_CAR = 1;
        int TRUCK_CAR   = 2;

        bool lastCarTruck = false;

        while (true)
        {
            if (lastCarTruck)
            {
                yield return(new WaitForSeconds(spawningRoutineTime));

                lastCarTruck = false;
            }
            float rNum = Random.Range(0.0F, 3.0F);

            if (rNum < 1)
            {
                enemyFactory.Generate(NORMAL_CAR);
            }
            else if (rNum < 2)
            {
                enemyFactory.Generate(RAINBOW_CAR);
            }
            else
            {
                enemyFactory.Generate(TRUCK_CAR);
                lastCarTruck = true;
            }
            yield return(new WaitForSeconds(spawningRoutineTime));
        }
    }