Adding Levels to 3D Tower Defense Starter Kit - Unsure How To Pass Values Into Class

Hi,

Please forgive my ignorance as I’m new to Unity and C#. I purchased the 3D Tower Defense start kit and I want to create different levels where each level will have more enemies than the last, making it progressively more challenging. I have a WaveManager.cs script which initializes a options list using a WaveOptions class, as follows…

Line 18: )
public List options = new List();

Line 348: )
//Wave Options class - per wave
[System.Serializable]
public class WaveOptions
{
//enemy prefab to instantiate, multiple enemies per wave possible
public List enemyPrefab = new List();
//how many enemies to spawn, per type
public List enemyCount = new List();
//spawn delay measured from start, per type
public List startDelay = new List();
//spawn delay between each enemy, per type
public List delayBetween = new List();
//which path each enemy has to follow, per type
public List path = new List();
}

What I want to do is change line 18 so that I can pass in different values to the class or set different values for the option list depending on the players current level. The following code is what I came up with but I’m obviously not doing something right because I get a Unity error which states that the list doesn’t have a constructor that takes ‘5’ arguments…

currentlevel = PlayerPrefs.GetInt(“level”);

if( currentlevel == 1 ){

public List options = new List( “peasant”, 3, 0, 2, “PathGround1”);

}else if( currentlevel == 2){

public List options = new List( “peasant”, 6, 0, 2, “PathGround1”);

}

Where “peasant”, 3, 0, 2, “PathGround1” corresponds to enemyPrefab, enemyCount, startDelay, delayBetween, path. Any help or feedback on how I would accomplish this would be greatly appreciated.

Thanks,

Ryan

Hi Ryan,

sorry for the very late response, I just found your post via a google search.

If you’re still having issues or haven’t contacted us already, please visit our main thread:

http://forum.unity3d.com/threads/130124-3D-Tower-Defense-Starter-Kit

or reach out to us at info@rebound-games.com.

Regards