Assigning Multiple Game Objects to an Array in one line of code, Need Help

I am making a TD game like Baloons Tower Defence. I am trying to make a list of creeps that will spawn in each wave, but steam line the code as much as posible. I want to assign 10 game objects to a array with one line of code. it seems that i just cant word it properly to get it done.

this is my hole chink so far (a lot is missing, i am reprogramming the game manager. but you can see what i am needing.)

The problem is here, can anyone make this work for me?

            wavePlaner[] = {minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0]} as GameObject ;

this is the entire class, if you are wondering.

[code=CSharp]using System.Collections;
using System;

[Serializable]

public class gameManager : MonoBehaviour {
//Level Settings
    //Notes:easy, med, hard. Any powerups, ect.

//Player Settings
    //Notes:sound settings, controles, ect.

//Level Variables
    //Notes: Curent Wave, wave total, money, health, towers, minions, ect.
    //Wave Variables.
    public int totalWaveNumber;
    public int currentWaveNumber;
    public int spawnCounter;
    private GameObject[] wavePlaner;
        //This is the spawn timer, to make the creeps trickle out.
    private float timer;
    private float spawnSpeed;
 
    //player variables.
    public int credits;
    public int health;

    //minion variables.
    public GameObject[] minion1;
        //minion needed information variables.
    public Transform spawnLocation;
    public Transform[] pathArray;

    //tower variables

    //tower needed information varibales
    //Notes: powerups and info.
 
    //level settings
    public bool spawningMinions;

 
    public GameObject[] Waves(){
        wavePlaner = new GameObject[0];
        //this switch will take the current have number and provide the spawner with a list of minions to spawn, well at the same time adjusting settings acordingly.
        switch(currentWaveNumber){
        case 1:
            wavePlaner[] = {minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0]} as GameObject ;

            break;
        case 2:

            break;
        case 3:
            break;
        case 4:
            break;
        case 5:
            break;
        case 6:
            break;
        case 7:
            break;
        case 8:
            break;
        case 9:
            break;
        case 10:
            break;
        }
    }

[/code]

What’s that “as GameObject” doing there?

Use a for-loop? Something like this:

public numSpawns;

for(int i = 0; i < numSpawns; i++)
{
      wavePlaner[i] = new minion; // whatever gameobjects your enemy is
}

This is pseudocode, can’t type that good from a phone :stuck_out_tongue:

I was trying to make it work and added it to the end at some point.

this is possible. ill try using a couple loops and show you what i got.

Oh, I totally read over the error: it should be like this:

wavePlaner = new GameObject[] {minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0],minion1[0]};

thank you my friend.

i ended up going down a different

void Waves(){
        //twe are resetting this variable to insure that each time waves is ran, we are asigning to the begining of the array.
        minionArrayPlacekeeper = 0;

        if(currentWaveNumber > totalWaveNumber){
            spawningMinions = false;
            Debug.Log("Game Over"); // temp
            return;
        }

    //this switch will take the current have number and provide the spawner with a list of minions to spawn, well at the same time adjusting settings acordingly.
        switch(currentWaveNumber){
        case 1:
            incomingWave = new GameObject[6];
            spawnSpeed = 1;
            HaveAsigned(2,minion1[0]);
            HaveAsigned(2,minion1[1]);
            HaveAsigned(2,minion1[0]);
            minionArrayPlacekeeper = 0; //this needs to be set to 0 to make sure the next time Hase Asigned is called, it works properly.

            break;
        case 2:
            incomingWave = new GameObject[6];
            spawnSpeed = 1;
            HaveAsigned(2,minion1[0]);
            HaveAsigned(3,minion1[1]);
            HaveAsigned(1,minion1[0]);
            minionArrayPlacekeeper = 0; //this needs to be set to 0 to make sure the next time Hase Asigned is called, it works properly.

            break;
        case 3:
            break;
        case 4:
            break;
        case 5:
            break;
        case 6:
            break;
        case 7:
            break;
        case 8:
            break;
        case 9:
            break;
        case 10:
            break;
        }
    }

    //this function is a tool, to assign multiple minion gameobjects to the wave at one time.
    void HaveAsigned(int numberOfSpawns, GameObject minionToSpawn){
        //asigning the incoming minions acording to the information given.
        for(int i = 0; i < numberOfSpawns; i++){
            //asign the wave.
            incomingWave[minionArrayPlacekeeper] = minionToSpawn;
            //we are using this variable insted of i, so that way we can run this function again and add more minions of a difrent type to the wave.
            minionArrayPlacekeeper ++;

        }
    }

rout for my waves, so that way i can have each wave change settings like spawn speed.

This is what i got, what you think?