Beispiel #1
0
        Random mcRandom;                                // Used to generate random numbers


        // Class constructor
        public CPitchMatcher()
        {
            try
            {
                // Pre-load images


                // Pre-load sounds
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Exception caught");
            }

            // Seed the Random number generator
            mcRandom = new Random(Environment.TickCount);

            // Setup the Pitch Meter
            mcPitchMeter = new CPitchMeter(500, 125);
            mcPitchMeter.ShowFourthsMarkers(true);

            // Setup the Pitch Meter to Match
            mcPitchMeterToMatch = new CPitchMeter(300, 125);
            mcPitchMeterToMatch.ShowFourthsMarkers(true);

            // Setup the Fonts
            mcFontText  = new Font("Arial", 20, FontStyle.Regular);
            mcFontPause = new Font("Arial", 50, FontStyle.Regular);

            // Specify the Game Duration, Max Target Wait Time, and Max Pitch Difference to get Points
            miGAME_DURATION = 30;
            mfMAX_TARGET_PITCH_WAIT_TIME = 3.0f;
            mfMAX_UNIT_PITCH_DIFFERENCE_TO_EARN_POINTS = 0.25f;

            // Start the player with no Score
            miScore = 0;

            // Set the other variables default values
            Reset();
        }
Beispiel #2
0
        FMOD.Sound msSoundFire = null;      // Sound when the player Fires the Arrow

        // Class constructor
        public CTargetPractice()
        {
            try
            {
                // Pre-load images
                mcBowAndArrowImage = Image.FromFile("../../Data/Images/TargetPracticeBowAndArrow.png");
                mcArrowImage       = Image.FromFile("../../Data/Images/TargetPracticeArrow.png");
                mcTargetImage      = Image.FromFile("../../Data/Images/TargetPracticeTarget.png");

                // Pre-load sounds
                CFMOD.CheckResult(CFMOD.GetSystem().createSound("../../Data/Sounds/TargetPracticeHit.wav", FMOD.MODE.DEFAULT, ref msSoundHit), "FMOD Create Sound Error");
                CFMOD.CheckResult(CFMOD.GetSystem().createSound("../../Data/Sounds/TargetPracticeMiss.wav", FMOD.MODE.DEFAULT, ref msSoundMiss), "FMOD Create Sound Error");
                CFMOD.CheckResult(CFMOD.GetSystem().createSound("../../Data/Sounds/TargetPracticeFire.wav", FMOD.MODE.DEFAULT, ref msSoundFire), "FMOD Create Sound Error");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Exception caught");
            }

            // Seed the Random number generator
            mcRandom = new Random(Environment.TickCount);

            // Setup the Pitch Meter
            mcPitchMeter = new CPitchMeter(500, 125);
            mcPitchMeter.ShowFourthsMarkers(true);

            // Setup the Fonts
            mcFontText  = new Font("Arial", 20, FontStyle.Regular);
            mcFontLarge = new Font("Arial", 50, FontStyle.Regular);

            // Start the player with no Score
            miScore = 0;

            // Record that we are playing Pong
            meGame = EGames.TargetPractice;

            // Set the games initial State
            meTargetPracticeState = ETargetPracticeGameStates.Aiming;

            // Set the initial Pitch Meter Indicator positions
            mcPitchMeter.UpdatePitchIndicatorsPosition(0.0f);

            // Initialize the constants
            mcGRAVITY_ACCELERATION   = new Vector2(0.0f, 65.0f);
            mrBOW_AND_ARROW_POSITION = new Rectangle(10, 400, 60, 69);

            // Specify the initial Target and Arrow positions
            mrTarget = new Rectangle(650, 250, 128, 128);
            mrArrow  = new RectangleF(10, 10, 60, 11);
            MoveTargetToNewRandomLocation();
            MoveArrowToBow();

            // Set the Arrows initial Velocity and the initial Power
            mcArrowVelocity        = new Vector2();
            mfUnitBowAndArrowPower = 0.0f;

            // Set the initial Bow And Arrow and Arrow Rotations
            miBowAndArrowRotation = miArrowRotation = 0;

            // Initialize the Reset Arrow Wait Time
            mfResetArrowWaitTime = 0.0f;

            // Initialize the Arrow Hit Target variable
            mbArrowHitTarget = false;
        }