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)); } }
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); } } } }
/// <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); } }
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 }
public override void free() { DSound.unloadSound(ref missileLaunchSound); DSound.unloadSound(ref missileSound); DSound.unloadSound(ref missileHitSound); DSound.unloadSound(ref missileExplodeSound); }
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; } }
public override void free() { base.free(); DSound.unloadSound(ref launchSound); DSound.unloadSound(ref missileSound); DSound.unloadSound(ref hitSound); }
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); } } }
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; }
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); }
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; } }
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; } }
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)); } }
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)); } }
/// <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); }
public override bool clearForRemoval() { if (damage > 0) { return(false); } return(destroySound != null && !DSound.isPlaying(destroySound)); }
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); }
private void playTaunt(String t) { if (taunt != null && DSound.isPlaying(taunt)) { return; } taunt = DSound.LoadSound(t); DSound.PlaySound(taunt, true, false); }
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); }
/// <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); } }
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"); }
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); }
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; }
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"); }
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; }
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; }
/// <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); } }
public static void NumWait() { while (DSound.isPlaying(soundFiles[globalCounter])) { if (nStop) { return; } Thread.Sleep(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; }
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; } }