Options

  1. An if statement that checks the name, or ID number, of a pattern and generates the asteroids according to the name

  2. A data structure, like using a class, that stores all of the information about the asteroid pattern in neat containers. Control of the spawning is then passed over to this class

    // a 2- dimensional array that stores the y coordinates of the asteroids. 
    // It is 2D because it allows for a separation between left and right asteroids
    bar_1_asteroids_array = [ [2, 8], [5] ]; 
    // There will be an array for each bar
    bar_2_asteroids_array = [ [-3], [1, -8] ];
    
  3. Store the information for the current pattern in arrays inside the original asteroidSpawner script. This way, the code can just spawn asteroids in the array, without needing to ask what pattern it is in. Whenever it reaches the end of the pattern, and needs a new one, it just calls for a new one and refills the arrays accordingly.

    string patternName;
    int[][] bar_1_asteroids_array;
    int[][] bar_2_asteroids_array;
    int[][] bar_3_asteroids_array;
    int[][] bar_4_asteroids_array;
    int[][] bar_5_asteroids_array;