Esempio n. 1
0
    void SpawnWave()
    {
        DeactivateTexts();
        List <List <GameObject> > EnemyRows = new List <List <GameObject> >();

        for (int y = 0; y < numRows; y++)
        {
            Color rowColour = Color.red / numRows * (y + 1) + Color.white / numRows * (numRows - (y + 1));
            Debug.Log("Row Colour: " + rowColour);
            List <GameObject> NewRow = new List <GameObject>();
            for (int x = 0; x < numPerRow; x++)
            {
                GameObject newEnemy = Instantiate(enemyPrefab);
                newEnemy.transform.position = new Vector3((-numPerRow / 2) + 0.5f + x, 6.5f - y, 0);
                newEnemy.GetComponent <Enemy>().SetColour(rowColour);
                newEnemy.GetComponent <Enemy>().SetController(Controller);
                newEnemy.GetComponent <Enemy>().SetNumInRow(x);
                newEnemy.transform.SetParent(transform.parent);
                if (y == numRows - 1)
                {
                    newEnemy.GetComponent <Enemy>().SetFront(true);
                }
                else
                {
                    newEnemy.GetComponent <Enemy>().SetFront(false);
                }
                NewRow.Add(newEnemy);
            }
            EnemyRows.Add(NewRow);
            Controller.AddEnemies(NewRow.Count);
            Debug.Log("Row with " + NewRow.Count + " enemies");
            NewRow = new List <GameObject>();
        }
        Controller.SetWave(EnemyRows);
        Debug.Log("Wave with " + EnemyRows.Count + " rows");
        TimerActive = false;
        return;
    }