Esempio n. 1
0
        private void singlePlayer(object sender, RoutedEventArgs e)
        {
            if (playerID == -1)
            {
                CustomMessageBox customMessageBox = new CustomMessageBox(kinectSensorChooser);
                customMessageBox.ShowText("Please login to continue");
            }
            else
            {
                GameRepository    gameRepository    = new GameRepository();
                PlayersRepository playersRepository = new PlayersRepository();

                if (gameRepository.GetGame(playerID).Count > 0)
                {
                    LoadGame loadGame = new LoadGame(kinectSensorChooser, playerID);
                    loadGame.ShowDialog();
                }
                else
                {
                    GameMode gameMode = new GameMode(kinectSensorChooser, playerID);
                    gameMode.ShowDialog();
                }
                PersonalBestValue.Text = playersRepository.GetPlayerScore(playerID).ToString();
            }
        }
Esempio n. 2
0
        //  Execute press function
        private void OnHandPointerPressRelease(object sender, HandPointerEventArgs e)
        {
            if (capturedHandPointer == e.HandPointer)
            {
                e.HandPointer.Capture(null);
                if (e.HandPointer.GetIsOver(btn_login))
                {
                    VisualStateManager.GoToState(btn_login, "MouseOver", true);

                    if (playerID == -1)
                    {
                        //	No user logged in, proceed to show login screen
                        Login login = new Login(kinectSensorChooser);
                        playerID = login.CustomShowDialog();
                    }
                    else
                    {
                        //	A user is logged in, prompt current user to logout before a new login
                        Logout logout = new Logout(kinectSensorChooser, playerID);

                        if (logout.CustomShowDialog())
                        {
                            PersonalBestValue.Visibility = Visibility.Hidden;
                            PersonalBestText.Visibility  = Visibility.Hidden;

                            //	Reset player ID
                            playerID = -1;

                            //	User logged out, proceed to show login screen
                            Login login = new Login(kinectSensorChooser);
                            playerID = login.CustomShowDialog();
                        }
                    }

                    //	If logged in, get highest score
                    if (playerID != -1)
                    {
                        PlayersRepository playersRepository = new PlayersRepository();
                        playerScore            = playersRepository.GetPlayerScore(playerID);
                        PersonalBestValue.Text = playerScore.ToString();

                        PersonalBestValue.Visibility = Visibility.Visible;
                        PersonalBestText.Visibility  = Visibility.Visible;
                    }
                    else
                    {
                        PersonalBestValue.Visibility = Visibility.Hidden;
                        PersonalBestText.Visibility  = Visibility.Hidden;
                    }
                }
                else if (e.HandPointer.GetIsOver(btn_register))
                {
                    VisualStateManager.GoToState(btn_register, "MouseOver", true);

                    if (playerID == -1)
                    {
                        //	No user logged in, proceed to show register screen
                        Register register = new Register(kinectSensorChooser);
                        register.ShowDialog();
                    }
                    else
                    {
                        //	A user is logged in, prompt current user to logout before a new registration
                        Logout logout = new Logout(kinectSensorChooser, playerID);

                        if (logout.CustomShowDialog())
                        {
                            //	Reset player ID
                            playerID = -1;

                            PersonalBestValue.Visibility = Visibility.Hidden;
                            PersonalBestText.Visibility  = Visibility.Hidden;

                            //	User logged out, proceed to show register screen
                            Register register = new Register(kinectSensorChooser);
                            register.ShowDialog();
                        }
                    }
                }
                else if (e.HandPointer.GetIsOver(btn_singlePlayer))
                {
                    VisualStateManager.GoToState(btn_singlePlayer, "MouseOver", true);

                    if (playerID == -1)
                    {
                        CustomMessageBox customMessageBox = new CustomMessageBox(kinectSensorChooser);
                        customMessageBox.ShowText("Please login to continue");
                    }
                    else
                    {
                        GameRepository gameRepository = new GameRepository();
                        if (gameRepository.GetGame(playerID).Count > 0)
                        {
                            LoadGame loadGame = new LoadGame(kinectSensorChooser, playerID);
                            loadGame.ShowDialog();
                        }
                        else
                        {
                            GameMode gameMode = new GameMode(kinectSensorChooser, playerID);
                            gameMode.ShowDialog();
                        }
                    }
                }
                else if (e.HandPointer.GetIsOver(btn_multiPlayer))
                {
                    VisualStateManager.GoToState(btn_multiPlayer, "MouseOver", true);

                    //	Multiplayer doesnt need login, player ID = -1
                    GameMode gameMode = new GameMode(kinectSensorChooser, -1);
                    gameMode.ShowDialog();
                }
                else if (e.HandPointer.GetIsOver(btn_loadGame))
                {
                    VisualStateManager.GoToState(btn_loadGame, "MouseOver", true);

                    if (playerID == -1)
                    {
                        CustomMessageBox customMessageBox = new CustomMessageBox(kinectSensorChooser);
                        customMessageBox.ShowText("Please login to continue");
                    }
                    else
                    {
                        GameRepository gameRepository         = new GameRepository();
                        List <GameRepository.GameDto> getGame = gameRepository.GetGame(playerID);
                        if (getGame.Count == 0)
                        {
                            //	No game saved, display the dialog
                            CustomMessageBox customMessageBox = new CustomMessageBox(kinectSensorChooser);
                            customMessageBox.ShowText("You have no saved game!");
                        }
                        else
                        {
                            //	Load the game
                            kinectSensorChooser.Stop();
                            DragDropImages dragDropImages = new DragDropImages(playerID, getGame[0].GameMode);
                            dragDropImages.GetLoadGameData(getGame[0].Lives, getGame[0].Time, getGame[0].Score, getGame[0].ItemGame);
                            dragDropImages.ShowDialog();

                            kinectSensorChooser.Start();
                        }
                    }
                }
                else if (e.HandPointer.GetIsOver(btn_highScores))
                {
                    VisualStateManager.GoToState(btn_highScores, "MouseOver", true);

                    GameMode gameMode = new GameMode(kinectSensorChooser, playerID, 0);
                    gameMode.ShowDialog();
                }
                else if (e.HandPointer.GetIsOver(btn_help))
                {
                    VisualStateManager.GoToState(btn_help, "MouseOver", true);

                    Help help = new Help(kinectSensorChooser);
                    help.ShowDialog();
                }
                else if (e.HandPointer.GetIsOver(btn_exit))
                {
                    VisualStateManager.GoToState(btn_exit, "MouseOver", true);

                    Close();
                }
                else
                {
                    VisualStateManager.GoToState(btn_login, "Normal", true);
                    VisualStateManager.GoToState(btn_register, "Normal", true);
                    VisualStateManager.GoToState(btn_singlePlayer, "Normal", true);
                    VisualStateManager.GoToState(btn_multiPlayer, "Normal", true);
                    VisualStateManager.GoToState(btn_loadGame, "Normal", true);
                    VisualStateManager.GoToState(btn_highScores, "Normal", true);
                    VisualStateManager.GoToState(btn_help, "Normal", true);
                    VisualStateManager.GoToState(btn_exit, "Normal", true);
                }
                e.Handled = true;
            }
        }