Пример #1
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();
            }
        }
Пример #2
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();
            }
        }