Пример #1
0
        /// <summary>
        /// Plays one of the slapping sound effects based on a random number and if the player has gone for a new slap.
        /// </summary>
        private void handleSlappingSoundEffect()
        {
            if (mouseRect.Intersects(guy.PositionRect) &&
                !slapEffectLocked)
            {
                Random randomizer   = new Random();
                int    randomNumber = randomizer.Next(0, 2);
                slapEffectLocked = true;

                if (randomNumber == 0)
                {
                    SoundEffectHandler.playSlap1SoundEffect();
                }
                else
                {
                    SoundEffectHandler.playSlap2SoundEffect();
                }
            }
            else if (!mouseRect.Intersects(guy.PositionRect) &&
                     slapEffectLocked)
            {
                slapEffectLocked = false;
            }
        }