Beispiel #1
0
    void GenerateSpawners()
    {
        for (int i = 0; i < numEnemySpawners; i++)
        {
            float proposedLocationX = Random.Range(-rectWidth / 2f, rectWidth / 2f);
            float proposedLocationY = Random.Range(-rectHeight / 2f, rectHeight / 2f);

/*			while (!topography.TestTileEmpty ((int)proposedLocationX, (int)proposedLocationY)) {
 *                              proposedLocationX = Random.Range (-rectWidth / 2f, rectWidth / 2f);
 *                              proposedLocationY = Random.Range (-rectHeight / 2f, rectHeight / 2f);
 *                      }*/
            //		Vector3 spawnerLocation = new Vector3 (Random.Range (-rectWidth / 2f, rectWidth / 2f), Random.Range (-rectHeight / 2f, rectHeight / 2f), 0f);
            Vector3 spawnerLocation = topography.FindUnoccupiedTile();

            GameObject newSpawnerGO = Instantiate(spawnerPrefab, spawnerLocation, Quaternion.identity);
            Spawner    newSpawner   = newSpawnerGO.GetComponent <Spawner> () as Spawner;
            newSpawner.SetSpawnables(spawnableEnemies);
            newSpawnerGO.transform.parent = this.transform;
        }

        for (int i = 0; i < numBuffSpawners; i++)
        {
            //	Vector3 spawnerLocation = new Vector3 (Random.Range (-rectWidth / 2f, rectWidth / 2f), Random.Range (-rectHeight / 2f, rectHeight / 2f), 0f);
            Vector3    spawnerLocation = topography.FindUnoccupiedTile();
            GameObject newSpawnerGO    = Instantiate(spawnerPrefab, spawnerLocation, Quaternion.identity);
            Spawner    newSpawner      = newSpawnerGO.GetComponent <Spawner> () as Spawner;
            newSpawner.SetSpawnables(spawnableBuffs);
            newSpawnerGO.transform.parent = this.transform;
        }

        StoreSpawners();          //Otherwise this will be missed when this is invoked on a delay
        SetSpawnersIndependent();
    }