コード例 #1
0
        public typingParams.GAME_STATE KeyDown(String enter)
        {
            typingParams.GAME_STATE r_inf = typingParams.GAME_STATE.NON_OF_PARAM;
            typingParams            tP    = typingParams.getInstance();

            if (tP.getTimerState() == true)
            {
                r_inf = this.getKeyInput(enter);
            }
            else if (enter.Equals("Space") == true)
            {
                tP.setTimerState(true);
                r_inf = typingParams.GAME_STATE.GAME_STARTED;
            }
            return(r_inf);
        }
コード例 #2
0
        private typingParams.GAME_STATE getKeyInput(String enter)
        {
            typingParams.GAME_STATE r_inf = typingParams.GAME_STATE.NON_OF_PARAM;
            typingParams            tP    = typingParams.getInstance();
            String curTarget = tP.getCurrentString();

            if (enter.Equals(curTarget) == true)
            {
                tP.appendPoolString();
                tP.incCurrentPos();
                r_inf = checkNextPlayer(tP.getCurrentPos());
            }
            else if (enter.Equals("Escape") == true)
            {
                /* ESCキーでゲームを強制終了する */
                r_inf = typingParams.GAME_STATE.TERMINATE_GAME;
            }
            else
            {
                r_inf = typingParams.GAME_STATE.MISS_ENTER;
            }
            return(r_inf);
        }
コード例 #3
0
        private typingParams.GAME_STATE checkNextPlayer(int curPos)
        {
            typingParams.GAME_STATE r_inf = typingParams.GAME_STATE.CONTINUE_INPUT;
            typingParams            tP    = typingParams.getInstance();
            int termPos = tP.getCurrentPlayerLength();

            if (curPos == termPos)
            {
                tP.setTimerState(false);

                if (tP.getGameMode() == typingParams.GAME_MODE.CHAMPION_MODE)
                {
                    double tmp = tP.getInputTime();
                    int    cP  = tP.getCurrentPlayer();
                    for (int ii = 0; ii < cP; ii++)
                    {
                        tmp = tmp - tP.getPlayerTime(ii);
                    }
                    tP.setPlayerTime(cP, tmp);
                }
                else
                {
                    tP.setPlayerTime(tP.getCurrentPlayer(), tP.getInputTime());
                    tP.clearInputTime();
                }

                if (tP.getCurrentPlayer() == tP.getLastPlayer())
                {
                    r_inf = typingParams.GAME_STATE.GAME_IS_OVER;
                }
                else
                {
                    r_inf = typingParams.GAME_STATE.GO_TO_NEXT_PLAYER;
                }
            }
            return(r_inf);
        }
コード例 #4
0
        private void onKeyDown(object sender, KeyEventArgs e)
        {
            typingParams tP    = typingParams.getInstance();
            String       enter = e.Key.ToString();

            Debug.WriteLine(enter);

            if (this.isGameOver == true)
            {
                if ((enter.Equals("Space") == true) || (enter.Equals("Eacape") == true))
                {
                    this.isGameOver         = false;
                    this.skel.Visibility    = Visibility.Hidden;
                    this.yamochi.Visibility = Visibility.Hidden;

                    tP.setTimerState(false);
                    tP.clearInputTime();

                    initForm(true);
                    this.m_bgRatio           = 0x0;
                    this.label1.Visibility   = Visibility.Visible;
                    this.MainForm.Background = new SolidColorBrush(Colors.AliceBlue);
                    this.label3.Visibility   = Visibility.Hidden;
                    this.label5.Content      = tP.getGameModeString();
                    this.label6.Visibility   = Visibility.Visible;
                    this.label7.Visibility   = Visibility.Visible;
                    this.label8.Visibility   = Visibility.Visible;
                }
                return;
            }

            typingParams.GAME_STATE r_inf = this.m_typing.KeyDown(enter);
            this.MainForm.Background = new SolidColorBrush(Colors.AliceBlue);
            this.label1.Visibility   = Visibility.Visible;
            this.label3.Visibility   = Visibility.Hidden;

            switch (r_inf)
            {
            case typingParams.GAME_STATE.GAME_STARTED:
            {
                String modeStr = tP.getGameModeString();

                tP.randomTargetString();
                tP.championTargetString();

                tP.setFirstChar();

                this.label1.Foreground = new SolidColorBrush(Colors.Blue);
                this.label1.FontWeight = FontWeights.Normal;
                this.label1.FontSize   = 300;
                this.label1.Content    = tP.getViewString();
                this.label6.Visibility = Visibility.Hidden;
                this.label7.Visibility = Visibility.Hidden;
                this.label8.Visibility = Visibility.Hidden;

                if (tP.getGameMode() == typingParams.GAME_MODE.EASY_MODE)
                {
                    this.label2.Content = tP.getCurrentString();
                }

                if (tP.getAorZmode() == true)
                {
                    modeStr += "\n(A → Z)";
                }
                else
                {
                    modeStr += "\n(Z → A)";
                }

                label5.Content = modeStr;

                this.disTimer.Start();
                break;
            }

            case typingParams.GAME_STATE.CONTINUE_INPUT:
            {
                this.label1.Content = tP.getViewString();
                this.label2.Content = tP.getPoolString();
                break;
            }

            case typingParams.GAME_STATE.MISS_ENTER:
            {
                this.label3.Content      = "Miss!!";
                this.label3.FontSize     = 180;
                this.label1.Visibility   = Visibility.Hidden;
                this.label3.Visibility   = Visibility.Visible;
                this.MainForm.Background = new SolidColorBrush(Colors.PaleVioletRed);
                break;
            }

            case typingParams.GAME_STATE.GO_TO_NEXT_PLAYER:
            {
                this.disTimer.Stop();
                this.label1.Content = tP.getViewString();

                String tex = this.m_typing.getTmpGameResult();
                System.Windows.MessageBox.Show(tex, "中間発表");

                this.label3.Visibility = Visibility.Hidden;
                tP.incCurrentPlayer();
                initForm();
                break;
            }

            case typingParams.GAME_STATE.GAME_IS_OVER:
            {
                String resultString = "";
                this.disTimer.Stop();
                this.label1.Content = tP.getViewString();

                resultString = this.m_typing.getGameResult();
                this.m_typing.writeResultDataToFile(resultString);
                System.Windows.MessageBox.Show(resultString,
                                               "結果発表");
                initForm(true);
                this.label5.Content    = tP.getGameModeString();
                this.label6.Visibility = Visibility.Visible;
                this.label7.Visibility = Visibility.Visible;
                this.label8.Visibility = Visibility.Visible;
                break;
            }

            case typingParams.GAME_STATE.TERMINATE_GAME:
            {
                this.disTimer.Stop();

                tP.setTimerState(false);
                tP.clearInputTime();

                initForm(true);
                this.m_bgRatio         = 0x0;
                this.label5.Content    = tP.getGameModeString();
                this.label6.Visibility = Visibility.Visible;
                this.label7.Visibility = Visibility.Visible;
                this.label8.Visibility = Visibility.Visible;
                break;
            }

            default:
                break;
            }
        }