예제 #1
0
        protected override void OnUpdate(ref UpdateParams p)
        {
            base.OnUpdate(ref p);

            // color
            bgColMultiplier      += RandomMath.RandomBetween(-0.0005f, +0.0005f);
            bg.DrawInfo.DrawColor = Color.White * bgColMultiplier;
            if (bgColMultiplier <= 0.08f)
            {
                bgColMultiplier += RandomMath.RandomBetween(0f, +0.0008f);
            }
            if (bgColMultiplier > 0.5432f)
            {
                bgColMultiplier -= RandomMath.RandomBetween(-0.0008f, -0.0002f);
            }


            //
            //float f = (SimTime % 4.0f) / 4.0f ;
            //if (bg.Target.X < bg.Position.X)
            //    bg.Position.X = bg.Target.X;
            //float g = (SimTime % 20.0f)/20.0f;
            //Vector2 v = new Vector2(bg.Texture.Width * (0.2f + 0.7f * f), bg.Texture.Height * (0.1f + 0.8f * g));
            float   freq = 0.0123f;
            Vector2 v    = new Vector2((float)Math.Cos(MathHelper.TwoPi * freq * SimTime), (float)Math.Sin(MathHelper.TwoPi * freq * SimTime));

            v = new Vector2(0.5f, 0.5f) + 0.33f * v;
            bg.Motion.Position = Screen.Center - Motion.ScaleAbs * v;
        }
예제 #2
0
        /// <summary>
        /// play a random combat sound, optionally adapted by a distance to player
        /// </summary>
        /// <param name="volumeMin"></param>
        /// <param name="volumeMax"></param>
        /// <param name="distToPlayer"></param>
        public void PlayRandomCombatSound(float volumeMin, float volumeMax, float distToPlayer = 0f)
        {
            float a = 1f;

            if (distToPlayer >= 0f)
            {
                if (distToPlayer > HEARING_RANGE)
                {
                    return;
                }
                a = 1f - (distToPlayer / HEARING_RANGE);
            }
            else
            {
                return;
            }
            int n = RandomMath.RandomIntBetween((int)SoundEffects.COMBAT1, (int)SoundEffects.COMBAT7);

            PlaySoundDist(n, RandomMath.RandomBetween(volumeMin, volumeMax), 0.0, 1.0, distToPlayer);
        }
예제 #3
0
 /// <summary>
 /// Play methodd to play an effect at a random volume between limits
 /// </summary>
 /// <param name="effect"></param>
 /// <param name="volumeMin">min volume</param>
 /// <param name="volumeMax">max volume</param>
 public void PlaySoundRandVol(int effect, double volumeMin, double volumeMax)
 {
     PlaySound(effect, RandomMath.RandomBetween(volumeMin, volumeMax));
 }