Ejemplo n.º 1
0
        private void loadGame(object sender, RoutedEventArgs e)
        {
            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();
                }
            }
        }
Ejemplo n.º 2
0
        private void timeAttack(object sender, RoutedEventArgs e)
        {
            if (windowType == -1)
            {
                if (playerID != -1)
                {
                    //	Time Attack
                    kinectSensorChooser.Stop();
                    DragDropImages dragDropImages = new DragDropImages(playerID, 1);

                    Close();

                    dragDropImages.ShowDialog();

                    kinectSensorChooser.Start();
                }
                else
                {
                    //	Multiplayer
                    //	Multiplayer game, log in not required, playerID == -1
                    Multiplayer multiplayer = null;
                    kinectSensorChooser.Stop();

                    //	Time Attack
                    multiplayer = new Multiplayer(1);

                    VisualStateManager.GoToState(btnTimeAttack, "MouseOver", true);

                    if (multiplayer != null)
                    {
                        Close();

                        //	Start the game for player 1 then player 2
                        player1Score = multiplayer.StartGame();
                        multiplayer  = new Multiplayer(1);
                        player2Score = multiplayer.StartGame();

                        kinectSensorChooser.Start();

                        //	Find the winner
                        CustomMessageBox customMessageBox = new CustomMessageBox(kinectSensorChooser);
                        if (player1Score > player2Score)
                        {
                            customMessageBox.ShowText("Winner is Player #1\nScore: " + player1Score, "Game Ended");
                        }
                        else if (player2Score > player1Score)
                        {
                            customMessageBox.ShowText("Winner is Player #2\nScore: " + player2Score, "Game Ended");
                        }
                        else
                        {
                            //	If draw
                            customMessageBox.ShowText("DRAW!\nScore: " + player1Score, "Game Ended");
                        }

                        return;
                    }
                }
            }
            else
            {
                //	Time attack
                HighScore highScore = new HighScore(kinectSensorChooser, 1);
                highScore.Show();

                Close();
            }
        }
Ejemplo n.º 3
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;
            }
        }