Beispiel #1
0
 private void shootPerson(Person target)
 {
     System.Diagnostics.Trace.WriteLine("Shoot method: entered shoot method");
     if (!waitingToShoot)
     {
         return;
     }
     if (DSound.isPlaying(lockSound))
     {
         return;
     }
     if (shootTime == 0)
     {
         lastShootTime = DateTime.Now;
         shootTime     = Common.getRandom(1, 3000);
     }
     System.Diagnostics.Trace.WriteLine("Shoot: Got passed init");
     System.Diagnostics.Trace.WriteLine(String.Format("Shoot: shootTime {0}; diff {1}", shootTime, (DateTime.Now - lastShootTime).TotalMilliseconds));
     if ((DateTime.Now - lastShootTime).TotalMilliseconds > shootTime)
     {
         DSound.PlaySound3d(shootSound, true, false, shootX, 0, shootY);
         if (Degrees.getDistanceBetween(shootX, shootY, shootTarget.x, shootTarget.y) <= 2)
         {
             shootTarget.hitAndGrunt(300);
         }
         waitingToShoot = false;
         lastShootTime  = DateTime.Now;
         maxShootTime   = Common.getRandom(1, 10);
         shootTime      = 0;
         shootTarget    = null;
     }
 }
Beispiel #2
0
 public override void playCrashSound(int x, int y)
 {
     if (crashSound == null)
     {
         crashSound = DSound.LoadSound3d(DSound.SoundPath + "\\a_fwall.wav");
     }
     DSound.PlaySound3d(crashSound, true, false, x, y, 0);
 }
		/// <summary>
		/// Plays the crash sound.
		/// </summary>
		/// <param name="x">The x coordinate where to position the sound.</param>
		/// <param name="y">The y coordinate where to position the sound.</param>
		public override void playCrashSound(int x, int y)
		{
			if (crashSound == null)
				crashSound = loadSound(hitFile);
			if (DSound.isPlaying(crashSound))
				return;
			DSound.PlaySound3d(crashSound, true, false, x, 0, y);
		}
Beispiel #4
0
 /// <summary>
 /// Plays a sound.
 /// </summary>
 /// <param name="theSound">The sound to play.</param>
 /// <param name="stopFlag">If the sound should be stopped before playing.</param>
 /// <param name="loopFlag">Whether the sound should be looped or not.</param>
 protected void playSound(SecondarySoundBuffer theSound, bool stopFlag, bool loopFlag)
 {
     if (isAI)
     {
         DSound.PlaySound3d(theSound, stopFlag, loopFlag, x, 0, y);
     }
     else
     {
         DSound.PlaySound(theSound, stopFlag, loopFlag);
     }
 }
 /// <summary>
 /// Plays a sound.
 /// </summary>
 /// <param name="theSound">The sound to play.</param>
 /// <param name="stopFlag">If the sound should be stopped before playing.</param>
 /// <param name="loopFlag">Whether the sound should be looped or not.</param>
 protected void playSound(ExtendedAudioBuffer theSound, bool stopFlag, bool loopFlag)
 {
     if (isAI)
     {
         DSound.PlaySound3d(theSound, stopFlag, loopFlag, x, 0, y);
     }
     else
     {
         DSound.PlaySound(theSound, stopFlag, loopFlag);
     }
 }
 /// <summary>
 /// Creates a new missile.
 /// </summary>
 /// <param name="thrower">The Person throwing the missile.</param>
 /// <param name="target">The target Person.</param>
 /// <param name="speed">The number of milliseconds to elapse between each move of the missile.</param>
 /// <param name="maxDamage">The maximum damage the missile can cause.</param>
 public PersonMissile(Person thrower, Person target, int speed, int maxDamage)
 {
     x              = thrower.x;
     y              = thrower.y;
     this.speed     = speed;
     this.maxDamage = maxDamage;
     this.target    = target;
     startTime      = DateTime.Now;
     moveSound      = DSound.LoadSound3d(DSound.SoundPath + "\\a_mmove.wav");
     explodeSound   = DSound.LoadSound3d(DSound.SoundPath + "\\a_mexpl.wav");
     DSound.PlaySound3d(moveSound, true, true, x, 0, y);
 }
Beispiel #7
0
 private void lockOnPerson(Person target)
 {
     System.Diagnostics.Trace.WriteLine("Shoot method: entered lock method");
     if (juliusLevel() != 3)
     {
         return;
     }
     if (waitingToShoot || (DateTime.Now - lastShootTime).TotalSeconds < maxShootTime)
     {
         return;
     }
     DSound.PlaySound3d(lockSound, true, false, shootX = target.x, 0, shootY = target.y);
     shootTarget    = target;
     waitingToShoot = true;
     //shoot time is set in shoot method because we need to wait for locksound to stop first.
     shootTime = 0;
 }
Beispiel #8
0
 //The below methods are mask methods for directX
 //All projectors will have the ability to play sounds from their perspectives
 public void playSound(ExtendedAudioBuffer theSound, bool stopFlag, bool loopFlag)
 {
     lock (this)
     {
         if (isAI && !autoPlayTarget)
         {
             if (!forceStareo)
             {
                 DSound.PlaySound3d(theSound, stopFlag, loopFlag, x, z, y, velocity.X, velocity.Z, velocity.Y);
             }
             else
             {
                 DSound.PlaySound(theSound, stopFlag, loopFlag);
             }
         }
         else
         {
             DSound.PlaySound(theSound, stopFlag, loopFlag);
         }
     }
 }
Beispiel #9
0
 //The below methods are mask methods for directX
 //All projectors will have the ability to play sounds from their perspectives
 public void playSound(SecondarySoundBuffer theSound, bool stopFlag, bool loopFlag)
 {
     lock (this)
     {
         if (isAI && !autoPlayTarget)
         {
             if (!forceStareo)
             {
                 DSound.PlaySound3d(theSound, stopFlag, loopFlag, x, z, y);
             }
             else
             {
                 DSound.PlaySound(theSound, stopFlag, loopFlag);
             }
         }
         else
         {
             DSound.PlaySound(theSound, stopFlag, loopFlag);
         }
     }
 }
 public void move()
 {
     if (isFinished() || DSound.isPlaying(explodeSound))
     {
         return;
     }
     if ((DateTime.Now - lastMoveTime).TotalMilliseconds >= speed)
     {
         lastMoveTime = DateTime.Now;
         System.Diagnostics.Trace.WriteLine("Missile moved");
         if (target.x < x)
         {
             x--;
         }
         else if (target.x > x)
         {
             x++;
         }
         else if (target.y < y)
         {
             y--;
         }
         else if (target.y > y)
         {
             y++;
         }
         DSound.PlaySound3d(moveSound, false, true, x, 0, y);
     }
     if ((DateTime.Now - startTime).Seconds >= 10)
     {
         moveSound.Stop();
         DSound.PlaySound3d(explodeSound, true, false, x, 0, y);
         if (Degrees.getDistanceBetween(x, y, target.x, target.y) <= 1)
         {
             target.hitAndGrunt(maxDamage);
         }
     }
 }
Beispiel #11
0
 /// <summary>
 /// Plays a sound in 3D desipte setting of isAI.
 /// </summary>
 /// <param name="s">The ExtendedAudioBuffer to play.</param>
 /// <param name="stopFlag">True if this sound should be stopped before it is played or replayed.</param>
 /// <param name="loopFlag">True if this sound should loop.</param>
 protected void playSound3d(ExtendedAudioBuffer s, bool stopFlag, bool loopFlag)
 {
     DSound.PlaySound3d(s, stopFlag, loopFlag, x, z, y);
 }
Beispiel #12
0
 /// <summary>
 /// Plays a sound in 3D desipte setting of isAI.
 /// </summary>
 /// <param name="s">The SecondarySoundBuffer to play.</param>
 /// <param name="stopFlag">True if this sound should be stopped before it is played or replayed.</param>
 /// <param name="loopFlag">True if this sound should loop.</param>
 protected void playSound3d(SecondarySoundBuffer s, bool stopFlag, bool loopFlag)
 {
     DSound.PlaySound3d(s, stopFlag, loopFlag, x, z, y);
 }