public void GenerateLevelFromSamples(FrequencyBand[] frequencyBands, float _songTime) { levelObjects = new List <LevelObject>(); songIndexLength = frequencyBands[0].spectralFluxSamples.Count; levelLength = (songIndexLength * spacingBetweenSamples); songTime = _songTime; //Scale level to the length of the song platform.localScale = new Vector3(levelLength + 15, 1, 1); physicsModel = new PhysicsModel(); //Set physics model physicsModel.gravity = Mathf.Abs(Physics2D.gravity.y * player.rigidbody.gravityScale); physicsModel.velocity = levelLength / songTime; physicsModel.jumpAcceleration = player.GetJumpAcceleration(); physicsModel.CalculatePhysicsModel(); //Sort level based on priority Array.Sort(levelFeatures, delegate(LevelFeature feature1, LevelFeature feature2) { return(feature1.priority.CompareTo(feature2.priority)); }); for (int i = 0; i < levelFeatures.Length; i++) { switch (levelFeatures[i].type) { case LevelFeature.features.Spikes: CreateLevelObjects(spikePrefab, frequencyBands[levelFeatures[i].bandIndex], ref levelFeatures[i]); break; case LevelFeature.features.SlideBlock: CreateLevelObjects(slideBlockPrefab, frequencyBands[levelFeatures[i].bandIndex], ref levelFeatures[i]); break; case LevelFeature.features.DestructableWalls: break; case LevelFeature.features.LevelHeight: break; case LevelFeature.features.Lighting: CreateLightingEvents(frequencyBands[levelFeatures[i].bandIndex]); break; } } CleanUpLevel(); }