Esempio n. 1
0
        private void NextVideoStart(object sender, EventArgs e)
        {
            // by default we advance the position by 1
            int nextStoryPosition = MainResources.GetPathPosition() + 1;

            switch (_prevButtonSchema.ButtonType)
            {
            case ButtonType.Default:
                MainResources.AdjustHP(_prevButtonSchema.ScoreAdjustment.HP);
                MainResources.AdjustPoints(_prevButtonSchema.ScoreAdjustment.Points);
                break;

            case ButtonType.End:
                // an "End" button type will end the game immidiately
                nextStoryPosition = -1;
                break;

            default:
                break;
            }
            // update the game resources
            MainResources.SetPathPosition(nextStoryPosition);
            // create new GameMenu instance
            GameMenu nextGameMenu = new GameMenu(_prevButtonSchema);

            DebugFunctions.DEBUG_output_list_of_videos("NextVideoStart function, line 398", _prevButtonSchema);
            MainResources.MainWindow.MainPanel.Children.Add(nextGameMenu);
            MainResources.MainWindow.MainPanel.Children.Remove(this);
            MainResources.SetPathPosition(nextStoryPosition);
        }
Esempio n. 2
0
        private void RetryButtonClicked(object sender, RoutedEventArgs e)
        {
            // create new GameMenu instance with previous game state
            RestorePoint load = MainResources.RestorePreviousState();

            DebugFunctions.DEBUG_output_list_of_videos("LOADED RESTORE POINT", load.LastChoice);
            // we only want to show the last video played, not the whole list
            ButtonSchema  loadedState = load.LastChoice;
            List <string> setupVideo  = new List <string>();

            // if there was more than 1 video played, just play the last video
            if (loadedState.VideoFilename.Count > 1)
            {
                // only add the last video to the list
                setupVideo.Add(loadedState.VideoFilename[loadedState.VideoFilename.Count - 1]);
            }
            else
            {
                // there's only one anyways, so just pass it along
                setupVideo = loadedState.VideoFilename;
            }
            // add the setup video to our loaded state
            loadedState.VideoFilename = setupVideo;

            GameMenu replayChoices = new GameMenu(loadedState);

            MainResources.MainWindow.MainPanel.Children.Add(replayChoices);
            MainResources.MainWindow.MainPanel.Children.Remove(this);
        }
Esempio n. 3
0
        private void ShowLoseScreen(ButtonSchema buttonD)
        {
            // lost the game, show LoseScreen
            DebugFunctions.DEBUG_output_list_of_videos("ShowLoseScreen function", buttonD);

            var lost = new LoseScreen(buttonD);

            MainResources.MainWindow.MainPanel.Children.Add(lost);
            MainResources.MainWindow.MainPanel.Children.Remove(this);
        }
Esempio n. 4
0
        private void ButtonClicked(ButtonSchema buttonSchema)
        {
            DebugFunctions.DEBUG_output_list_of_videos("ButtonClicked", buttonSchema);

            // disable UI
            IsEnabled = false;

            if (buttonSchema.Path.Branch != MainResources.GetBranch())
            {
                MainResources.SetBranch(buttonSchema.Path.Branch);
                MainResources.SetPathPosition(buttonSchema.Path.StartPosition - 1);
            }

            _prevButtonSchema = buttonSchema;
            _fadeInStoryboards.Stop();
            _fadeOutStoryboards.Begin();
        }
Esempio n. 5
0
        public GameMenu(ButtonSchema buttonData)
        {
            DebugFunctions.DEBUG_output_list_of_videos("GameMenu Constructor", buttonData);

            InitializeComponent();
            // load root directory
            _scenarioPath = MainResources.GetRootDirectory();

            // holds our buttons so we can iterate and enable/disable
            gameButtons = new List <GameButton>();

            // load current path position (ie 1, 2, 3, -1)
            _storyPosition = MainResources.GetPathPosition();

            // set default video to play (first video in list)
            string videoPath = buttonData.VideoFilename[_currentlyPlayingVideo];

            // path for the current branch
            _branchPath = Path.Combine(_scenarioPath, MainResources.GetBranch() + _storyPosition.ToString());

            // if we are at -1 story position or no HP, it's game over
            if (_storyPosition == -1 || isPlayerDead())
            {
                ShowLoseScreen(buttonData);
                return;
            }
            // didn't lost the game, so save restore point
            MainResources.SaveCurrentState(buttonData);

            // callback to invoke after the video is played
            Action afterVideoPlayed = AfterChoiceVideoPlayed;

            // win conditions
            // 1. if there are no more folders along this story path
            // 2. if the button data has an ending
            if (!Directory.Exists(_branchPath) || buttonData.Endings.Count > 0)
            {
                // start by setting the ending video we will play
                string endVideoPath = videoPath;

                // determine which ending based on points
                foreach (Ending ending in buttonData.Endings)
                {
                    // the first ending that matches the condition will be set as the ending (so consider the order of endings in the list)
                    if (MainResources.GetPoints() >= ending.WhenPointsAreBetween[0] && MainResources.GetPoints() <= ending.WhenPointsAreBetween[1])
                    {
                        _hasEndingVideo = true;

                        // set this ending to play after the choice video
                        endVideoPath = Path.Combine(_scenarioPath, "endings", ending.VideoFilename);

                        // set the text to display on the ending screen depending on this ending
                        buttonData.EndScreenMessage = ending.EndScreenMessage;
                        // break on first match
                        break;
                    }
                }

                if (!_hasEndingVideo && buttonData.Endings.Count == 1)
                {
                    // only 1 ending, play it (no point condition)
                    _hasEndingVideo = true;
                    endVideoPath    = Path.Combine(_scenarioPath, "endings", buttonData.Endings[0].VideoFilename);
                }


                afterVideoPlayed = () => ShowWinScreen(buttonData, endVideoPath);
                // "just in case" there are  no matches
                if (!_hasEndingVideo || buttonData.Endings.Count == 0)
                {
                    // just show the regular win screen (no ending video)
                    ShowWinScreen(buttonData, videoPath);
                    return;
                }
            }

            // see if we have other videos to play after this one
            if (buttonData.VideoFilename.Count > 1)
            {
                // set the callback to invoke after ALL videos are played
                Action finalCallback = afterVideoPlayed;
                // set the immidiate callback to play other videos first
                afterVideoPlayed = () => PlayOtherVideosFirst(buttonData.VideoFilename, finalCallback);
            }

            _fadeInStoryboards  = new Storyboard();
            _fadeOutStoryboards = new Storyboard();

            // setting fade in animations (not running them yet)
            var fadeIn = FindResource("FadeInStoryboard") as Storyboard;

            Storyboard.SetTarget(fadeIn, GameMenuGrid);

            var fadeIn2 = FindResource("FadeInStoryboard2") as Storyboard;

            Storyboard.SetTarget(fadeIn2, ChoiceMenuBorder);

            var fadeOut = FindResource("FadeOutStoryboard") as Storyboard;

            // sets the callback when storyboard (choices) have faded out
            fadeOut.Completed += NextVideoStart;
            Storyboard.SetTarget(fadeOut, GameMenuGrid);

            var fadeOut2 = FindResource("FadeOutStoryboard2") as Storyboard;

            Storyboard.SetTarget(fadeOut2, ChoiceMenuBorder);


            _fadeInStoryboards.Children.Add(fadeIn);
            _fadeInStoryboards.Children.Add(fadeIn2);

            _fadeOutStoryboards.Children.Add(fadeOut);
            _fadeOutStoryboards.Children.Add(fadeOut2);

            if (!_hasEndingVideo)
            {
                // if we are not playing the ending video, we must be continuing the game, so add the choice buttons
                AddButtons();
            }

            // now play the video, and invoke the callback after it's played
            MainResources.MainWindow.PlayFile(videoPath, afterVideoPlayed);
        }