示例#1
0
        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;
        }
示例#2
0
 private StoryLineViewModel AddStoryline(int index, StoryLineViewModel childStorylineModel)
 {            
     if (index < storyLines.Count - 1)
     {
         storyLines.Insert(index + 1, childStorylineModel);
     }
     else
     {
         storyLines.Add(childStorylineModel);
     }
     return childStorylineModel;
 }
示例#3
0
 internal ObservableCollection<DataModel.Model.IScene> GetScenes(StoryLineViewModel storylineModel)
 {
     ObservableCollection<IScene> scenes = new ObservableCollection<IScene>();
     if (storylineModel != null)
     {
         foreach (SceneViewModel sceneModel in storylineModel)
         {
             scenes.Add(sceneModel.CurrentScene);
         }
     }
     return scenes;
 }
示例#4
0
 public void Position(StoryLineViewModel lineScenes)
 {
     AddStoryline(index, lineScenes);
 }
示例#5
0
 public void Position(StoryLineViewModel lineScenes)
 {
     storylines.Add(lineScenes);
 }
示例#6
0
 internal StoryLineViewModel CreateStoryLine(StoryViewModel storyViewModel)
 {
     StoryLineViewModel storylineModel = new StoryLineViewModel(storyViewModel, null);
     storylineModel.CollectionChanged += lineScenes_CollectionChanged;
     return storylineModel;
 }
示例#7
0
        private static InteractiveScene GetPredecessor(int index, StoryLineViewModel storylineModel)
        {
            if ((index == 0 && storylineModel.Parent == null) || index > storylineModel.Count)
            {
                return null;
            }
            
            InteractiveScene oldPredecessor = null;

            if (index == 0 && storylineModel.Parent != null)
            {
                StoryLineViewModel parentStoryline = storylineModel.Parent;
                SceneViewModel parentSceneModel = parentStoryline.Last();
                if (parentSceneModel.CurrentScene is InteractiveScene)
                {
                    oldPredecessor = parentSceneModel.CurrentScene as InteractiveScene;
                }
            }
            else{
                SceneViewModel lastExistingSceneModel = storylineModel[index - 1];
                oldPredecessor = lastExistingSceneModel.CurrentScene as InteractiveScene;
            }

            return oldPredecessor;
        }
示例#8
0
        private InteractiveScene GetSuccessor(int addedSceneIndex, StoryLineViewModel storylineModel)
        {
            int successorIndex = addedSceneIndex + 1;
            if (successorIndex < storylineModel.Count)
            {
                SceneViewModel successorSceneModel = storylineModel[successorIndex];
                return successorSceneModel.CurrentScene as InteractiveScene;
            }

            return null;
        }
示例#9
0
        public void RefreshScenes(StoryLineViewModel storyline, bool refreshSelected = true)
        {
            ScenesViewModel = new ObservableCollection<SceneViewModel>(BuildPath(storyline));
            SceneViewModel lastSceneViewModel = null;
            lastSceneViewModel = storyline.LastOrDefault();

            if (null != lastSceneViewModel)
            {
                Scenes = new ObservableCollection<IScene>(BuildPath(Story.StartScene, lastSceneViewModel.CurrentScene));
            }

            if (Scenes.Count > 0)
            {
                CurrentScene = Scenes[0];
                if (refreshSelected)
                {
                    SelectedSceneViewModel = storyline.FirstOrDefault();
                    SelectedSceneViewModel = null;
                }
            }
        }
示例#10
0
 private int FindStoryLineIndex(StoryLineViewModel storyline)
 {
     for (int i = 0; i < StoryLines.Count; i++)
     {
         if (StoryLines[i] == storyline)
         {
             return i;
         }
     }
     return -1;
 }
示例#11
0
        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]);
                }
            }
        }
示例#12
0
 private static bool isFavorited(StoryLineViewModel targetStoryLine, SceneViewModel scene)
 {
     ObservableCollection<SceneTag> favoriteTags = targetStoryLine.StoryModel.FavoriteTags;
     if (favoriteTags.Count == 0)
     {
         return false;
     }
     foreach (SceneTag sceneTag in scene.Tags)
     {
         foreach (SceneTag favoriteTag in favoriteTags)
         {
             if (favoriteTag.Content.Equals(sceneTag.Content))
             {
                 return true;
             }
         }
     }
     return false;
 }
示例#13
0
 private static IEnumerable<SceneViewModel> ReverseAndFilter(StoryLineViewModel targetStoryLine)
 {
     return (from scene in targetStoryLine
             where (!scene.IsBonus || (scene.IsBonus && isFavorited(targetStoryLine, scene)))
             select scene).Reverse();
 }
示例#14
0
        private IEnumerable<SceneViewModel> BuildPath(StoryLineViewModel targetStoryLine)
        {
            List<SceneViewModel> result = new List<SceneViewModel>();
            result.AddRange(ReverseAndFilter(targetStoryLine));
            StoryLineViewModel parent = targetStoryLine;
            while (null != (parent = parent.Parent))
            {
                result.AddRange(ReverseAndFilter(parent));
            }

            result.Reverse();
            return result;
        }
示例#15
0
 internal void SelectStoryline(StoryLineViewModel storyline)
 {
     CurrentStoryline = storyline;
     RefreshScenes(storyline);
 }
示例#16
0
 private void HandleReorder(StoryViewModel storyModel, StoryLineViewModel storyline)
 {
     //storyModel.Story = storyModel.Story;
     storyModel.RefreshScenes(storyline);
 }
示例#17
0
 private void UpdateIsCurrent(StoryLineViewModel storyline)
 {
     if (storyline != null)
     {
         //This value is dummy, just to trigger property notification
         storyline.IsCurrent = true;
     }
 }