/// <summary> /// Initializes the level and creates all necessary nodes. No geometry is loaded yet /// </summary> /// <param name="scenario">The scenario that constitutes the level</param> public void Initialize(Scenario scenario) { _scenario = scenario; var levelGameObject = new GameObject("Level", typeof(View.Level.Level)); Level = levelGameObject.GetComponent <View.Level.Level>(); Camera = Object.FindObjectOfType <CameraController>(); LevelNodeController previous = new LevelNodeController(); _nodes.AddLast(previous); //create new controllers for each step in the scenario foreach (var scenarioStep in _scenario.Steps) { var levelNodeController = new LevelNodeController(previous, scenarioStep); levelNodeController.OnFinished += OnNodeFinished; levelNodeController.OnLengthChanged += Level.OnNodeChangedLength; previous = levelNodeController; _nodes.AddLast(levelNodeController); } _currentListNode = _nodes.First; Level.RebuildSplinePoints(); // instantly enable the first levelcontroller Debug.Assert(_currentListNode != null, "No Nodes in List! Are there any steps loaded?"); CurrentNode.Enable(); }