Пример #1
0
    IEnumerator BatCountDown(GameObject batSpawner)
    {
        batCountingDown = true;
        yield return(new WaitForSeconds(batTime));

        BatSpawner spawnerScript = batSpawner.GetComponent <BatSpawner>();

        spawnerScript.spawnBat();
        batCountingDown = false;
    }
    void Start()
    {
        rushModeBatSpawner = new BatSpawner(autoBatPrefab, batSpawnerTransform, player.transform);

        n = player.n;
        int levelMax = 100;

        // build level
        level   = new int[levelMax];
        enemies = new GameObject[levelMax];
        // 9 = finish/level complete, 1 = high bat, 2 = low bat, 7 = rush mode on, 8 = rush mode off
        level[level.Length - 1] = 9;

        level[2]  = 2;
        level[5]  = 1;
        level[8]  = 2;
        level[9]  = 1;
        level[18] = 1;
        level[21] = 2;
        level[32] = 2;
        level[41] = 1;
        level[43] = 2;
        level[44] = 1;
        level[46] = 2;
        level[49] = 2;
        level[51] = 2;
        level[52] = 1;
        level[53] = 1;
        level[57] = 1;
        level[58] = 1;
        level[62] = 2;
        level[65] = 2;
        level[68] = 7;
        level[95] = 8;

        // spawn everything
        for (int i = 0; i < level.Length; i++)
        {
            if (level[i] == 1)
            {
                enemies[i] = Instantiate <GameObject>(highBatPrefab, new Vector3((i) * 0.5f * 4, 1f * 4, 0), Quaternion.identity, transform.GetChild(2));
            }

            if (level[i] == 2)
            {
                enemies[i] = Instantiate <GameObject>(lowBatPrefab, new Vector3((i) * 0.5f * 4, 0.3f * 4, 0), Quaternion.identity, transform.GetChild(2));
            }

            if (level[i] == 9)
            {
                Instantiate <GameObject>(endPrefab, new Vector3(i * 2f, -1.5f, 0), Quaternion.identity, transform);
            }
        }
    }