public static Dictionary <string, float[]> GetUnitsPerSec(int totalTime) { Dictionary <string, float[]> unitsPerType = new Dictionary <string, float[]>(); #region FindTotalUnitsPerType Spawner[] totalSpawners = SpawnersToolWindow.GetSpawners(); // for each group of spawners with the same tag foreach (Spawner spawner in totalSpawners) { // if dictionary has already defined this unit type if (unitsPerType.ContainsKey(spawner.GetUnitToSpawn().name)) { // get this spawner's unit / sec activity float[] unitsPerSec = FindUnitsPerSec(spawner.numberOfUnitsToSpawn, spawner.spawningFrequency, totalTime); for (int time = 0; time < totalTime; time++) { unitsPerType[spawner.GetUnitToSpawn().name][time] += unitsPerSec[time]; } } else { unitsPerType.Add(spawner.GetUnitToSpawn().name, FindUnitsPerSec(spawner.numberOfUnitsToSpawn, spawner.spawningFrequency, totalTime)); } } #endregion return(unitsPerType); }