Exemplo n.º 1
0
        void _client_RecognizeSpeechCompleted(object sender, RecognizeSpeechCompletedEventArgs e)
        {
            hidePopup();
            bool good = false;

            try
            {
                //attempt to process voice recognition
                VoiceCommandFuzzyProcessing.process(e.Result);

                //determine if there is a pawn that needs promotion
                bool doesAPawnNeedPromotion = false;

                string color         = GameStateManager.getInstance().getCurrentPlayer().ToString().ToLower();
                bool   white_and_end = color == "white" && GameState.getInstance().getSelectedPiece() != null && GameState.getInstance().getSelectedPiece().getMasqueradeType() == "pawn" && GameState.getInstance().getChosenPosition().X == 7;
                bool   black_and_end = color == "black" && GameState.getInstance().getSelectedPiece() != null && GameState.getInstance().getSelectedPiece().getMasqueradeType() == "pawn" && GameState.getInstance().getChosenPosition().X == 0;

                doesAPawnNeedPromotion = (white_and_end || black_and_end);

                //check to see if pawn promotion is needed
                if (doesAPawnNeedPromotion && !alreadyCalledPromote)
                {
                    showPopup("Pawn Promote");
                    alreadyCalledPromote = true;
                }
                else
                {
                    SetupPage();
                }
                good = true;
            }
            catch (Exception ex)
            {
                handleError(ex.Message);
            }
            finally
            {
                if (!good)
                {
                    SetupPage();
                }
            }
        }
Exemplo n.º 2
0
        void _client_RecognizeSpeechCompleted(object sender, RecognizeSpeechCompletedEventArgs e)
        {
            hidePopup();
            bool good = false;
            try
            {
                //attempt to process voice recognition
                VoiceCommandFuzzyProcessing.process(e.Result);

                //determine if there is a pawn that needs promotion
                bool doesAPawnNeedPromotion = false;

                string color = GameStateManager.getInstance().getCurrentPlayer().ToString().ToLower();
                bool white_and_end = color == "white" && GameState.getInstance().getSelectedPiece() != null && GameState.getInstance().getSelectedPiece().getMasqueradeType() == "pawn" && GameState.getInstance().getChosenPosition().X == 7;
                bool black_and_end = color == "black" && GameState.getInstance().getSelectedPiece() != null && GameState.getInstance().getSelectedPiece().getMasqueradeType() == "pawn" && GameState.getInstance().getChosenPosition().X == 0;

                doesAPawnNeedPromotion = (white_and_end || black_and_end);

                //check to see if pawn promotion is needed
                if (doesAPawnNeedPromotion && !alreadyCalledPromote)
                {
                    showPopup("Pawn Promote");
                    alreadyCalledPromote = true;
                }
                else
                {
                    SetupPage();
                }
                good = true;
            }
            catch (Exception ex)
            {
                handleError(ex.Message);
            }
            finally
            {
                if (!good)
                {
                    SetupPage();
                }
            }
        }