Example #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();
                }
            }
        }
Example #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();
            }
        }
Example #3
0
        //	Execute button functions
        private void HandPointerPressReleaseEvent(object sender, HandPointerEventArgs e)
        {
            if (capturedHandPointer == e.HandPointer)
            {
                if (windowType == -1)
                {
                    if (playerID != -1)
                    {
                        //	Single player game
                        //	Show game play window
                        kinectSensorChooser.Stop();
                        DragDropImages dragDropImages = null;

                        if (e.HandPointer.GetIsOver(btnSurvival))
                        {
                            //	Survival
                            dragDropImages = new DragDropImages(playerID, 0);

                            VisualStateManager.GoToState(btnSurvival, "MouseOver", true);
                        }
                        else if (e.HandPointer.GetIsOver(btnTimeAttack))
                        {
                            //	Time Attack
                            dragDropImages = new DragDropImages(playerID, 1);

                            VisualStateManager.GoToState(btnTimeAttack, "MouseOver", true);
                        }
                        else
                        {
                            VisualStateManager.GoToState(btnSurvival, "Normal", true);
                            VisualStateManager.GoToState(btnTimeAttack, "Normal", true);
                        }

                        if (dragDropImages != null)
                        {
                            e.HandPointer.Capture(null);
                            e.Handled = true;

                            Close();

                            dragDropImages.ShowDialog();

                            kinectSensorChooser.Start();

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

                        if (e.HandPointer.GetIsOver(btnSurvival))
                        {
                            //	Survival
                            multiplayer  = new Multiplayer(0);
                            multiplayer1 = new Multiplayer(0);

                            VisualStateManager.GoToState(btnSurvival, "MouseOver", true);
                        }
                        else if (e.HandPointer.GetIsOver(btnTimeAttack))
                        {
                            //	Time Attack
                            multiplayer  = new Multiplayer(1);
                            multiplayer1 = new Multiplayer(1);

                            VisualStateManager.GoToState(btnTimeAttack, "MouseOver", true);
                        }
                        else
                        {
                            VisualStateManager.GoToState(btnSurvival, "Normal", true);
                            VisualStateManager.GoToState(btnTimeAttack, "Normal", true);
                        }

                        if (multiplayer != null && multiplayer1 != null)
                        {
                            e.HandPointer.Capture(null);
                            e.Handled = true;

                            Close();

                            //	Start the game for player 1 then player 2
                            player1Score = multiplayer.StartGame();
                            player2Score = multiplayer1.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
                {
                    //	Show high score
                    if (e.HandPointer.GetIsOver(btnSurvival))
                    {
                        //	Survival
                        HighScore highScore = new HighScore(kinectSensorChooser, 0);
                        highScore.ShowDialog();

                        VisualStateManager.GoToState(btnSurvival, "MouseOver", true);
                    }
                    else if (e.HandPointer.GetIsOver(btnTimeAttack))
                    {
                        //	Time Attack
                        HighScore highScore = new HighScore(kinectSensorChooser, 1);
                        highScore.ShowDialog();

                        VisualStateManager.GoToState(btnTimeAttack, "MouseOver", true);
                    }
                    else
                    {
                        VisualStateManager.GoToState(btnSurvival, "Normal", true);
                        VisualStateManager.GoToState(btnTimeAttack, "Normal", true);
                    }
                }

                e.HandPointer.Capture(null);
                e.Handled = true;

                Close();
            }
        }
Example #4
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;
            }
        }