Esempio n. 1
0
        /// <summary> Starts the game with the selected <see cref="GameProfile"/>.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        private async void AppBarButtonPlay_Click(object sender, RoutedEventArgs e)
        {
            if ((GameProfilesList.SelectedItem as ListItemMainPage) == null)
            {
                return;
            }

            var gameProfileWithObjects = new ListItemMainPage
            {
                GameProfile = (GameProfilesList.SelectedItem as ListItemMainPage).GameProfile,
                Challenges  = ViewModel.GameProfileChallenges
            };

            try {
                CoreApplicationView newView = CoreApplication.CreateNewView();
                int newViewId = 0;
                await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    Frame frame = new Frame();
                    frame.Navigate(typeof(GamePage), gameProfileWithObjects);
                    Window.Current.Content = frame;
                    Window.Current.Activate();

                    newViewId = ApplicationView.GetForCurrentView().Id;
                });

                bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
            } catch (NullReferenceException) { }
        }
Esempio n. 2
0
        /// <summary>Handles the SelectionChanged event of the GameProfilesList control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="SelectionChangedEventArgs"/> instance containing the event data.</param>
        private async void GameProfilesList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            _storedGameProfile = ((sender as ListView).SelectedItem as ListItemMainPage);
            if (_storedGameProfile != null)
            {
                ViewModel.PutChallengesInLists(_storedGameProfile.GameProfile);
                _challengesSource = await GetChallengesGrouped(ViewModel.GameProfileChallenges);

                ChallengesCVS.Source    = _challengesSource;
                PlayButton.IsEnabled    = true;
                EditButton.IsEnabled    = true;
                RefreshButton.IsEnabled = true;

                PrepareLists();
            }
            else
            {
                ViewModel.GameProfileChallenges.Clear();
                _challengesSource = await GetChallengesGrouped(ViewModel.GameProfileChallenges);

                ChallengesCVS.Source    = _challengesSource;
                PlayButton.IsEnabled    = false;
                EditButton.IsEnabled    = false;
                RefreshButton.IsEnabled = false;

                PrepareLists();
            }
        }
Esempio n. 3
0
        /// <summary>Opens the edit menu for the <see cref="GameProfile"/></summary>
        /// <param name="clickedGameProfile">The clicked game profile.</param>
        private void EditCommand_ItemClicked(ListItemMainPage clickedGameProfile)
        {
            AddRemoveAll_Click();
            InsertChallengeAmounts();

            ConnectedAnimation animation = GameProfilesList.PrepareConnectedAnimation("forwardAnimation", _storedGameProfile, "connectedElement");

            SmokeGrid.Visibility = Visibility.Visible;

            SmokeGridText.Text = _storedGameProfile.GameProfile.GameProfileName;
            animation.TryStart(SmokeGrid.Children[0]);
        }
Esempio n. 4
0
        /// <summary>Handles the Click event of the SaveButton control.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            var newChallenges = new List <ChallengeBase>();

            newChallenges.AddRange(ViewModel.NewAudienceChallenges);
            newChallenges.AddRange(ViewModel.NewCrewChallenges);
            newChallenges.AddRange(ViewModel.NewMultipleChoiceChallenges);
            newChallenges.AddRange(ViewModel.NewMusicChallenges);
            newChallenges.AddRange(ViewModel.NewQuizChallenges);
            newChallenges.AddRange(ViewModel.NewScreenshotChallenges);
            newChallenges.AddRange(ViewModel.NewSilhouetteChallenges);
            newChallenges.AddRange(ViewModel.NewSologameChallenges);

            _storedGameProfile.GameProfile.GameProfileName = SmokeGridText.Text;

            var newProfile = new Profile {
                UsingID = (int)_storedGameProfile.GameProfile.ProfileID
            };

            foreach (var challenge in newChallenges)
            {
                newProfile.Challenges.Add(
                    new UsingChallenge
                {
                    Challenge   = challenge,
                    ChallengeID = challenge.ChallengeID,
                    UsingID     = _storedGameProfile.GameProfile.ProfileID
                });
            }

            _storedGameProfile.GameProfile.Profile = newProfile;

            ViewModel.EditCommand.Execute(_storedGameProfile.GameProfile);

            var index = ViewModel.GameProfiles.IndexOf(_storedGameProfile);

            ViewModel.GameProfiles[index] = _storedGameProfile;

            _storedGameProfile = ViewModel.GameProfiles[index];

            BackButton_Click(sender, e);
        }
Esempio n. 5
0
        /// <summary>Puts the challenges in their respective lists.</summary>
        /// <param name="profile">The profile.</param>
        internal void PutChallengesInLists(GameProfile profile)
        {
            GameProfileChallenges.Clear();

            List <int?> saveGameChallengeIDs = new List <int?>();

            foreach (var saveGame in profile.SaveGame.Challenges)
            {
                saveGameChallengeIDs.Add(saveGame.ChallengeID);
            }

            foreach (var profileChallenge in profile.Profile.Challenges)
            {
                var challenge = ChallengesFromDB.Where(c => c.ChallengeID == profileChallenge.ChallengeID).First();
                ListItemMainPage listChallenge = new ListItemMainPage
                {
                    IsChallengeCompleted = (saveGameChallengeIDs.Contains(profileChallenge.ChallengeID)?true:false)
                };

                switch (challenge.GetDiscriminator())
                {
                case "AudienceChallenge":
                    listChallenge.Challenge       = challenge as AudienceChallenge;
                    listChallenge.IsGameChallenge = Windows.UI.Xaml.Visibility.Visible;
                    GameProfileChallenges.Add(listChallenge);
                    break;

                case "CrewChallenge":
                    listChallenge.Challenge       = challenge as CrewChallenge;
                    listChallenge.IsGameChallenge = Windows.UI.Xaml.Visibility.Visible;
                    GameProfileChallenges.Add(listChallenge);
                    break;

                case "MultipleChoiceChallenge":
                    listChallenge.Challenge           = challenge as MultipleChoiceChallenge;
                    listChallenge.IsQuestionChallenge = Windows.UI.Xaml.Visibility.Visible;
                    GameProfileChallenges.Add(listChallenge);
                    break;

                case "MusicChallenge":
                    listChallenge.Challenge        = challenge as MusicChallenge;
                    listChallenge.IsMusicChallenge = Windows.UI.Xaml.Visibility.Visible;
                    GameProfileChallenges.Add(listChallenge);
                    break;

                case "QuizChallenge":
                    listChallenge.Challenge           = challenge as QuizChallenge;
                    listChallenge.IsQuestionChallenge = Windows.UI.Xaml.Visibility.Visible;
                    GameProfileChallenges.Add(listChallenge);
                    break;

                case "ScreenshotChallenge":
                    listChallenge.Challenge        = challenge as ScreenshotChallenge;
                    listChallenge.IsImageChallenge = Windows.UI.Xaml.Visibility.Visible;
                    GameProfileChallenges.Add(listChallenge);
                    break;

                case "SilhouetteChallenge":
                    listChallenge.Challenge        = challenge as SilhouetteChallenge;
                    listChallenge.IsImageChallenge = Windows.UI.Xaml.Visibility.Visible;
                    GameProfileChallenges.Add(listChallenge);
                    break;

                case "SologameChallenge":
                    listChallenge.Challenge       = challenge as SologameChallenge;
                    listChallenge.IsGameChallenge = Windows.UI.Xaml.Visibility.Visible;
                    GameProfileChallenges.Add(listChallenge);
                    break;
                }
            }
        }
Esempio n. 6
0
 /// <summary>Resets the <see cref="SaveGame"/> of the <see cref="GameProfile"/>.</summary>
 /// <param name="clickedGameProfile">The clicked game profile.</param>
 private void ResetSaveCommand_ItemClicked(ListItemMainPage clickedGameProfile)
 {
     ViewModel.RefreshSaveGame.Execute(clickedGameProfile);
 }