Esempio n. 1
0
        private void ProcessChoice(string sender, int choice)
        {
            try
            {
                if (sender != "finished")
                {
                    currLocalAdventure.CurrentChapter = Convert.ToInt32(sender);
                    Paragraph newBlock = new Paragraph();
                    switch (choice)
                    {
                        case 1:
                            TextRange range1 = new TextRange(textOne.ContentStart, textOne.ContentEnd);
                            newBlock.Inlines.Add(range1.Text);
                            currLocalAdventure.ongoingStory.Blocks.InsertAfter(currLocalAdventure.ongoingStory.Blocks.Last(), newBlock);
                            break;
                        case 2:
                            TextRange range2 = new TextRange(textOne.ContentStart, textOne.ContentEnd);
                            newBlock.Inlines.Add(range2.Text);
                            currLocalAdventure.ongoingStory.Blocks.InsertAfter(currLocalAdventure.ongoingStory.Blocks.Last(), newBlock);
                            break;
                        case 3:
                            TextRange range3 = new TextRange(textOne.ContentStart, textOne.ContentEnd);
                            newBlock.Inlines.Add(range3.Text);
                            currLocalAdventure.ongoingStory.Blocks.InsertAfter(currLocalAdventure.ongoingStory.Blocks.Last(), newBlock);
                            break;
                        default:
                            break;
                    }
                    noTunes = true;
                    SaveAdventure(currLocalAdventure);
                    LoadCurrentFlowDocChapter(currLocalAdventure, Convert.ToInt32(sender));
                    //LoadSceneImage(sender);
                    if (noTunes == true)
                        LoadSceneMusic(currentMusic);
                }
                else
                {
                    using (FileStream fs = new FileStream(@AppGlobals.finishedStoryDir + "/" + AppGlobals.currGlobalAdventure.Title + "_" + DateTime.Now.Month + DateTime.Now.Day + DateTime.Now.Year + ".rtf", FileMode.Create))
                    {
                        TextRange textRange = new TextRange(currLocalAdventure.ongoingStory.ContentStart, currLocalAdventure.ongoingStory.ContentEnd);
                        textRange.Save(fs, DataFormats.Rtf);
                    }

                    //DELETE THE IN PROGRESS FILES AS THE STORY IS FINISHED
                    DirectoryInfo currentDir = new DirectoryInfo(@AppGlobals.saveGameDir);
                    var saveFile = currentDir.GetFiles().Where(d => d.Name == AppGlobals.currGlobalAdventure.Title + ".advo");
                    if (saveFile.Count() > 0)
                    {
                        File.Delete(saveFile.First().FullName);
                    }
                    currentDir = new DirectoryInfo(@AppGlobals.saveGameMetaDir);
                    var metaFile = currentDir.GetFiles().Where(d => d.Name == AppGlobals.currGlobalAdventure.Title + ".advm");
                    if (metaFile.Count() > 0)
                    {
                        File.Delete(metaFile.First().FullName);
                    }

                    AppGlobals.currGlobalAdventure = new Adventure();
                    MainMenu mainMenu = new MainMenu();
                    this.NavigationService.Navigate(mainMenu);
                }
            }
            catch (Exception err)
            {
                exHand.LogException(err, "Story-ProcessChoice");
            }
            finally
            {
                currLocalAdventure.DecisionsMade++;
                LoadStats(currLocalAdventure);
            }
        }
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Escape)
     {
         MainMenu mainMenu = new MainMenu();
         this._navFrame.Navigate(mainMenu);
         AppGlobals.player.isMenu = true;
         if (!AppGlobals.player.isMenu)
             AppGlobals.player.PauseMusic();
         else
         {
             AppGlobals.player.StopMusic();
             AppGlobals.player.PlayTheme();
         }
     }
 }