Ejemplo n.º 1
0
        public override void onTick()
        {
            if (isFinished())
            {
                fireDisposeEvent();
                return;
            }
            if (finished && performing)
            {
                //The weapon is done doing what it needs to do, but a sound is still playing.
                //Do not free this weapon until the sound is done playing.
                performing = (Hit != null && DSound.isPlaying(Hit)) || (expl != null && DSound.isPlaying(expl));
                return;
            }

            performing = true;
            base.onTick();
            playSound3d(moveSound, false, false);
            if (inFiringRange())
            {
                moveSound.stop();
                Hit = target.loadSound(target.soundPath + "bsg" + Common.getRandom(3, 4) + ".wav");
                target.playSound(Hit, true, false);
                fireHitEvent(target, Common.getRandom(100, 200));
                finished = true;
                return;
            }

            if (!DSound.isPlaying(moveSound))
            {
                finished = true;
                explode();
                performing = (Hit != null && DSound.isPlaying(Hit)) || (expl != null && DSound.isPlaying(expl));
            }
        }
Ejemplo n.º 2
0
 public static void startGame()
 {
     if (!KeyMap.readFromFile())
     {
         OggBuffer kError = DSound.playOgg(DSound.NSoundPath + "\\kme.ogg");
         while (kError.isPlaying())
         {
             if (dxInput.isKeyHeldDown())
             {
                 break;
             }
             Thread.Sleep(10);
         }                 //while
         kError.stopOgg();
         kError = null;
     }
     Options.setDifficulty(Options.difficulties.easy);
     Interaction.clearData();
     mainMenu();
     if (!Options.requestedShutdown)
     {
         Common.startGame();
         if (Common.firstTimeLoad)
         {
             Common.firstTimeLoad = false;
             while (!Common.threadNotifier)
             {
                 Thread.Sleep(6000);
             }
         }
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new person
 /// </summary>
 /// <param name="x">Starting x coordinate</param>
 /// <param name="y">Starting y coordinate</param>
 /// <param name="damage">Starting hit points; max damage will also be set to this value</param>
 /// <param name="isAI">True if computer controlled, false otherwise</param>
 public Person(int x, int y, int damage, bool isAI)
     : base(x, y, damage, isAI)
 {
     this.isAI = isAI;
     if (juliusLevel() == 2)
     {
         missiles = new PersonMissile[1];
     }
     else if (juliusLevel() == 3)
     {
         missiles = new PersonMissile[4];
     }
     if (juliusLevel() == 3)
     {
         shootSound = loadSound("l3s.wav");
         lockSound  = loadSound("l3a.wav");
     }
     lastStunTime  = lastPunchTime = lastMissileTime = DateTime.Now;
     stopPunchTime = Common.getRandom(1, 10);
     startSeekTime = DateTime.Now;
     blockSound    = loadSound("fb.wav");
     stunSound     = loadSound("fstun.wav");
     if (!isAI)
     {
         DSound.SetCoordinates(x, 0.0, y);
     }
 }
Ejemplo n.º 4
0
 private void startRain()
 {
     if (isRaining)
     {
         rainElapsed += 1;
         if (rainElapsed >= rainTime)
         {
             stopRain();
         }
         return;
         ////already raining
     }
     if (Common.getRandom(1, 50) == 25)
     {
         if (!isRaining)
         {
             rainIntensity = (WeatherTypes)Common.getRandom(1, 3);
             rain          = DSound.loadOgg(DSound.SoundPath + "\\wr" + rainIntensity + ".ogg");
             rain.play(true);
             isRaining = true;
         }
         ////if !isRaining
     }
     ////if random
 }
Ejemplo n.º 5
0
 public override void free()
 {
     DSound.unloadSound(ref missileLaunchSound);
     DSound.unloadSound(ref missileSound);
     DSound.unloadSound(ref missileHitSound);
     DSound.unloadSound(ref missileExplodeSound);
 }
Ejemplo n.º 6
0
        public override void onTick()
        {
            if (isFinished())
            {
                fireDisposeEvent();
                return;
            }
            if (finished && performing)
            {
                //The weapon is done doing what it needs to do, but a sound is still playing.
                //Do not free this weapon until the sound is done playing or the program will act up.
                if (gunHitSound != null)
                {
                    performing = DSound.isPlaying(gunHitSound);
                }
                return;
            }

            performing = true;
            base.onTick();
            if (inFiringRange())
            {
                gunHitSound = target.loadSound(target.soundPath + "gun1-" + Common.getRandom(1, 5) + ".wav");
                target.playSound(gunHitSound, true, false);
                fireHitEvent(target, 10);
                finished = true;
                return;
            }

            if (totalDistance >= 4)
            {
                finished   = true;
                performing = false;
            }
        }
Ejemplo n.º 7
0
 public override void free()
 {
     base.free();
     DSound.unloadSound(ref launchSound);
     DSound.unloadSound(ref missileSound);
     DSound.unloadSound(ref hitSound);
 }
Ejemplo n.º 8
0
        public override void use()
        {
            direction = weapon.creator.direction;
            int ammunitionNumber = weapon.ammunitionFor(WeaponTypes.missile) + 1;

            if (!isAI)
            {
                if (ammunitionNumber % 2 != 0)                                             //odd number means fire from right
                {
                    DSound.setPan(missileLaunchSound, (ammunitionNumber + 1) / 2 * 0.25f); //give 1 to ammunition number so we can divide properly; adding 1 will make it evenly divisible by 2.
                }
                else
                {
                    DSound.setPan(missileLaunchSound, ammunitionNumber / 2 * -0.25f);
                }
                fox = loadSound(soundPath + "fox2.wav");
                playSound(fox, true, false);
                DXInput.startFireEffect();
            }             //if !AI
            playSound(missileLaunchSound, true, false);
            if (origTarget != null)
            {
                z = origTarget.z;
                if (isAI && origTarget is Aircraft)
                {
                    ((Aircraft)origTarget).notifyOf(Notifications.missileLaunch, Degrees.getDistanceBetween(x, y, origTarget.x, origTarget.y) <= 15);
                }
            }
        }
Ejemplo n.º 9
0
        public virtual void mute(bool hardMute)
        {
            if (volumes == null || isMuted)
            {
                return;                 //object may not have defined any sounds to be muted.
            }
            //Or we've already muted.

            /*Holders will keep calling mute()
             * Even though they may already have called it.
             * This way, objects that are inserted into the holders after the mute operation will also be muted.
             * */
            for (int i = 0; i < ctrlVolume.Count; i++)
            {
                volumes.Add(ctrlVolume[i].Volume);
                if (ctrlVolume[i].Volume > -8000)
                {
                    ctrlVolume[i].Volume = -8000;
                }
                if (hardMute)
                {
                    looping.Add(DSound.isLooping(ctrlVolume[i]));
                    ctrlVolume[i].Stop();
                }
            }
            isMuted = true;
        }
Ejemplo n.º 10
0
        public SecondarySoundBuffer loadSound(string filename)
        {
            SecondarySoundBuffer s = null;

            System.Diagnostics.Trace.WriteLine("Loading sound " + filename);
            if (isAI && !autoPlayTarget)
            {
                if (!forceStareo)
                {
                    s = DSound.LoadSound3d(filename);
                }
                else
                {
                    s = DSound.LoadSound(filename);
                }
            }
            else             //Either this is not AI or this is autoPlayTarget
            {
                s = DSound.LoadSound(filename);
            }
            if (s == null)
            {
                System.Diagnostics.Trace.WriteLine(filename + " is a null buffer");
            }
            return(s);
        }
Ejemplo n.º 11
0
 public virtual void onTick()
 {
     //First, need to set what object sare in range
     //since this is the first ontick method.
     if (vArray == null)
     {
         vArray = Interaction.getObjectsInRange(this,
                                                reachRange,
                                                Interaction.RangeFlag.existing);
     }
     updateTotalDistance();
     move();
     if (Options.mode == Options.Modes.mission &&
         followTarget &&
         origTarget != null)
     {
         z = origTarget.z;
     }
     if (damage < 1)
     {
         expl = DSound.LoadSound(DSound.SoundPath + "\\m4-1.wav");
         DSound.PlaySound(expl, true, false);
         finished = true;
     }
 }
Ejemplo n.º 12
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;
     }
 }
Ejemplo n.º 13
0
        public override void onTick()
        {
            if (isFinished())
            {
                fireDisposeEvent();
                return;
            }

            if (finished && performing)
            {
                performing = (missileHitSound != null && DSound.isPlaying(missileHitSound)) || (expl != null && DSound.isPlaying(expl));
                return;
            }

            performing = true;
            playSound3d(missileSound, false, true);
            base.onTick();
            if (inFiringRange())
            {
                missileSound.Stop();
                missileHitSound = target.loadSound(target.soundPath + "m3-" + Common.getRandom(1, 3) + ".wav");
                target.playSound(missileHitSound, true, false);
                fireHitEvent(target, Common.getRandom(300));
                finished = true;
                return;
            }
            if (totalDistance > 15.0 || finished)
            {
                missileSound.Stop();
                finished   = true;
                performing = (missileHitSound != null && DSound.isPlaying(missileHitSound)) || (expl != null && DSound.isPlaying(expl));
            }
        }
Ejemplo n.º 14
0
        public override void onTick()
        {
            if (isFinished())
            {
                fireDisposeEvent();
                return;
            }
            if (finished && performing)
            {
                //The weapon is done doing what it needs to do, but a sound is still playing.
                //Do not free this weapon until the sound is done playing or the program will act up.
                if (hitSound != null)
                {
                    performing = DSound.isPlaying(hitSound);
                }
                return;
            }

            performing = true;
            if ((Math.Abs(Environment.TickCount - time)) / 1000 < 2)
            {
                return;
            }
            playSound3d(missileSound, false, true);
            if (!inVerticalRange(10))
            {
                if (z > origTarget.z)
                {
                    z -= 10;
                }
                if (z < origTarget.z)
                {
                    z += 10;
                }
                if (Math.Abs(z - origTarget.z) <= 10)
                {
                    z = origTarget.z;
                }
            }
            direction = Degrees.GetDegreesBetween(x, y, origTarget.x, origTarget.y);
            base.onTick();
            if (inFiringRange())
            {
                missileSound.stop();
                hitSound = target.loadSound(target.soundPath + "m3-" + Common.getRandom(1, 2) + ".wav");
                target.playSound(hitSound, true, false);
                // Since the boss aircraft has 10,000 damage, let's not let the player kill them with one cruise missile.
                // However, the missile should wipe out everything else it contacts.
                fireHitEvent(target, (target is JuliusAircraft)? 1500:100000);
                finished = true;
                return;
            }
            if (totalDistance > 30.0 || !Weapons.isValidLock(origTarget) || finished)
            {
                missileSound.stop();
                finished   = true;
                performing = (hitSound != null && DSound.isPlaying(hitSound)) || (expl != null && DSound.isPlaying(expl));
            }
        }
Ejemplo n.º 15
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);
		}
Ejemplo n.º 16
0
 public override bool clearForRemoval()
 {
     if (damage > 0)
     {
         return(false);
     }
     return(destroySound != null && !DSound.isPlaying(destroySound));
 }
Ejemplo n.º 17
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);
 }
Ejemplo n.º 18
0
 private void playTaunt(String t)
 {
     if (taunt != null && DSound.isPlaying(taunt))
     {
         return;
     }
     taunt = DSound.LoadSound(t);
     DSound.PlaySound(taunt, true, false);
 }
Ejemplo n.º 19
0
 public override void freeResources()
 {
     base.freeResources();
     DSound.unloadSound(ref engine);
     DSound.unloadSound(ref startChargeSound);
     DSound.unloadSound(ref chargeSound);
     DSound.unloadSound(ref endChargeSound);
     DSound.unloadSound(ref taunt);
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Updates this person's coordinates and also takes care of updating the listener if necessary.
 /// </summary>
 /// <param name="x">The X coordinate of the object.</param>
 /// <param name="y">The Y coordinate of the object.</param>
 public void updateCoordinates(int x, int y)
 {
     this.x = x;
     this.y = y;
     if (!isAI)
     {
         DSound.SetCoordinates(x, 0.0, y);
     }
 }
Ejemplo n.º 21
0
 public CruiseMissile(Weapons w)
     : base(w, "p" + (int)WeaponTypes.cruiseMissile)
 {
     type = WeaponTypes.cruiseMissile;
     weapon.decreaseAmmunitionFor(WeaponTypes.cruiseMissile);
     neutralizeSpeed((weapon.creator.flyingCruiseMissile) ? 1800f : 900f);
     setSpan(0.10f, 0.25f);
     launchSound  = loadSound(soundPath + "cr1.wav");
     missileSound = DSound.LoadSound(DSound.SoundPath + "\\cr2.wav");
 }
Ejemplo n.º 22
0
 public Missile(Weapons w)
     : base(w, "p" + (int)WeaponTypes.missile)
 {
     type = WeaponTypes.missile;
     weapon.decreaseAmmunitionFor(WeaponTypes.missile);
     missileLaunchSound = loadSound(soundPath + "m1.wav");
     missileSound       = DSound.LoadSound(DSound.SoundPath + "\\m2.wav");
     neutralizeSpeed(1500f);
     setSpan(0.1f, 0.1f);
 }
Ejemplo n.º 23
0
		public void playDestroy(bool isAI)
		{
			bool isAITemp = this.isAI;
			this.isAI = isAI;
			if (destroySound != null)
				DSound.unloadSound(ref destroySound);
			destroySound = loadSound((damage <= 0) ? destroyFile : hitFile);
			playSound(destroySound, true, false);
			this.isAI = isAITemp;
		}
Ejemplo n.º 24
0
 public MissileInterceptor(Weapons w)
     : base(w, "p" + (int)WeaponTypes.cruiseMissile)
 {
     type = WeaponTypes.missileInterceptor;
     weapon.decreaseAmmunitionFor(WeaponTypes.missileInterceptor);
     neutralizeSpeed(900f);
     setSpan(0.10f, 0.25f);
     launchSound  = loadSound(soundPath + "ci1.wav");
     missileSound = DSound.LoadSound(DSound.SoundPath + "\\ci2.wav");
 }
Ejemplo n.º 25
0
 public ExplosiveMissile(Weapons w)
     : base(w, "p" + (int)WeaponTypes.explosiveMissile)
 {
     weapon.decreaseAmmunitionFor(WeaponTypes.explosiveMissile);
     missileLaunchSound = loadSound(soundPath + "m1.wav");
     missileSound       = DSound.LoadSound(DSound.SoundPath + "\\m2.wav");
     neutralizeSpeed(1500f);
     setSpan(0.1f, 0.1f);
     followTarget = false;
 }
Ejemplo n.º 26
0
 public SAMMissile(Weapons w)
     : base(w, "p" + (int)WeaponTypes.samMissile)
 {
     weapon.decreaseAmmunitionFor(WeaponTypes.samMissile);
     neutralizeSpeed(3000f);
     launch    = loadSound(soundPath + "sam1.wav");
     moveSound = DSound.LoadSound(DSound.SoundPath + "\\bsg2.wav");
     setSpan(0.20f, 0.20f);
     followTarget = false;
 }
Ejemplo n.º 27
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);
     }
 }
Ejemplo n.º 28
0
 public static void NumWait()
 {
     while (DSound.isPlaying(soundFiles[globalCounter]))
     {
         if (nStop)
         {
             return;
         }
         Thread.Sleep(0);
     }
 }
Ejemplo n.º 29
0
 public BattleShipGuns(Weapons w)
     : base(w, "p" + (int)WeaponTypes.battleShipGuns)
 {
     weapon.decreaseAmmunitionFor(WeaponTypes.battleShipGuns);
     neutralizeSpeed(1000f);
     launch    = loadSound(soundPath + "bsg1.wav");
     moveSound = DSound.LoadSound(DSound.SoundPath + "\\bsg2.wav");
     setSpan(0.05f, 0.10f);
     followTarget = false;
     explodes     = (Common.getRandom(0, 1) == 0) ? false : true;
 }
Ejemplo n.º 30
0
        public override void onTick()
        {
            if (isFinished())
            {
                fireDisposeEvent();
                return;
            }
            if (finished && performing)
            {
                //The weapon is done doing what it needs to do, but a sound is still playing.
                //Do not free this weapon until the sound is done playing or the program will act up.
                if (hitSound != null)
                {
                    performing = DSound.isPlaying(hitSound);
                }
                return;
            }

            performing = true;
            playSound3d(missileSound, false, true);
            if (!inVerticalRange(10))
            {
                if (z > origTarget.z)
                {
                    z -= 10;
                }
                if (z < origTarget.z)
                {
                    z += 10;
                }
                if (Math.Abs(z - origTarget.z) <= 10)
                {
                    z = origTarget.z;
                }
            }
            direction = Degrees.GetDegreesBetween(x, y, origTarget.x, origTarget.y);
            base.onTick();
            if (inFiringRange())
            {
                missileSound.stop();
                hitSound = target.loadSound(target.soundPath + "m3-" + Common.getRandom(1, 2) + ".wav");
                target.playSound(hitSound, true, false);
                target.hit(target.damage, Interaction.Cause.destroyedByWeapon);
                fireHitEvent(target, target.damage);
                finished = true;
                return;
            }
            if (totalDistance > 30.0 || !Weapons.isValidLock(origTarget) || finished)
            {
                missileSound.stop();
                finished   = true;
                performing = false;
            }
        }