public void ConstructStoryLines(StoryViewModel storyModel, StoryLineViewModel parent, IScene startScene, int depth, IStorylinePositioner storylineAdder) { IScene currentScene = startScene; StoryLineViewModel lineScenes = new StoryLineViewModel(storyModel, parent); lineScenes.Depth = depth; storylineAdder.Position(lineScenes); int padding = depth; while (currentScene != null) { padding++; lineScenes.Add(new SceneViewModel(currentScene)); InteractiveScene interactiveScene = currentScene as InteractiveScene; if (null != interactiveScene && interactiveScene.Type == SceneType.Interactive) { foreach (IScene possibleStartScene in interactiveScene.PossibleScenes) { ConstructStoryLines(storyModel, lineScenes, possibleStartScene, padding, storylineAdder); } break; } else { currentScene = currentScene.FollowingScene; } } lineScenes.CollectionChanged += lineScenes_CollectionChanged; }
internal void AddStoryline(StoryLineViewModel storyline) { if (storyline.Count > 0) { SceneViewModel lastScene = storyline.Last(); InteractiveScene interactiveScene; if (lastScene.CurrentScene is InteractiveScene) { interactiveScene = lastScene.CurrentScene as InteractiveScene; if (null != interactiveScene) { interactiveScene.Type = SceneType.Interactive; } } else { interactiveScene = new InteractiveScene(lastScene.CurrentScene.LibraryItem); storyline.Remove(lastScene); storyline.Add(CreateSceneViewModel(interactiveScene)); } int index = FindStoryLineIndex(storyline); if (index > -1) { IStorylinePositioner positioner = new StorylineInserter(StoryLines, index); _builder.ConstructStoryLines(this, storyline, null, storyline.Depth + storyline.Count, positioner); SelectStoryline(StoryLines[index + 1]); } } }