コード例 #1
0
        // Handle key presses
        public override EGames KeyDown(KeyEventArgs e)
        {
            // If the Pause button was pressed
            if (e.KeyCode == Keys.Space)
            {
                // If the Game is currently Paused
                if (mePitchMatcherState == EPitchMatcherGameStates.Pause)
                {
                    // Switch to Playing the game
                    mePitchMatcherState = EPitchMatcherGameStates.Play;

                    // If the Game hadn't started yet
                    if (!mbGameStarted)
                    {
                        // Record that the Game has now Started
                        mbGameStarted = true;

                        // Start the player with no Score
                        miScore = 0;
                    }
                }
                // Else the Game is not Paused
                else
                {
                    // So Pause the Game
                    mePitchMatcherState = EPitchMatcherGameStates.Pause;
                }
            }

            // If Restart was pressed
            if (e.KeyCode == Keys.R)
            {
                Reset();
            }

            return(meGame);
        }
コード例 #2
0
        // Reset class variables to their default values
        public void Reset()
        {
            // Record that we are playing Pong
            meGame = EGames.PitchMatcher;

            // Set the games initial State
            mePitchMatcherState = EPitchMatcherGameStates.Pause;

            // Record that the Game hasn't started yet
            mbGameStarted = false;

            // Set the initial game Duration
            mfGameTimeRemaining = miGAME_DURATION;

            // Reset the Pitch To Match variables
            mfTimeBeforeChangingTargetPitchInSeconds = 0.0f;
            mfUnitTargetPitchToAchieve  = 0.0f;
            mfTargetPitchChangeVelocity = 0.0f;
            mfCurrentUnitTargetPitch    = 0.5f;

            // Set the initial Pitch Meter Indicator positions
            mcPitchMeter.UpdatePitchIndicatorsPosition(0.5f);
            mcPitchMeterToMatch.UpdatePitchIndicatorsPosition(0.5f);
        }