Пример #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;
     }
 }
Пример #2
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;
            }
        }
Пример #3
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));
            }
        }
Пример #4
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));
            }
        }
Пример #5
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));
            }
        }
Пример #6
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);
		}
Пример #7
0
 public override bool clearForRemoval()
 {
     if (damage > 0)
     {
         return(false);
     }
     return(destroySound != null && !DSound.isPlaying(destroySound));
 }
Пример #8
0
 private void playTaunt(String t)
 {
     if (taunt != null && DSound.isPlaying(taunt))
     {
         return;
     }
     taunt = DSound.LoadSound(t);
     DSound.PlaySound(taunt, true, false);
 }
Пример #9
0
 public static void NumWait()
 {
     while (DSound.isPlaying(soundFiles[globalCounter]))
     {
         if (nStop)
         {
             return;
         }
         Thread.Sleep(0);
     }
 }
Пример #10
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;
            }
        }
Пример #11
0
 private static void stopLastFile()
 {
     if (soundFiles != null &&
         soundFiles.Length > globalCounter &&
         soundFiles[globalCounter] != null)
     {
         if (DSound.isPlaying(soundFiles[globalCounter]))
         {
             soundFiles[globalCounter].Stop();
         }
     }
 }
Пример #12
0
 public bool isFinished()
 {
     if (moveSound == null)             //clean up has occurred
     {
         return(true);
     }
     if (DSound.isLooping(moveSound))
     {
         return(false);
     }
     return(!DSound.isPlaying(explodeSound));
 }
Пример #13
0
 public void uncall()
 {
     showInList   = false;
     direction    = Degrees.GetDegreesBetween(x, y, sx, sy);
     isCalling    = false;
     isConnecting = false;
     time         = 0;
     neutralizeSpeed(1500.0);
     if (message != null && DSound.isPlaying(message))
     {
         message.Stop();
     }
 }
Пример #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.
                performing = DSound.isPlaying(cannonLaunch);
                return;
            }

            performing = true;
            if (!inVerticalRange(10))
            {
                if (z < origTarget.z)
                {
                    z += 10;
                }
                if (z > origTarget.z)
                {
                    z -= 10;
                }
            }
            base.onTick();

            x = origTarget.x;
            y = origTarget.y;
            z = origTarget.z;

            if (inFiringRange())
            {
                cannonLaunch.Stop();
                origTarget.hit(true);
                fireHitEvent(origTarget, 0);
                weapon.lCSTarget = origTarget;
                finished         = true;
                return;
            }
            if (!DSound.isPlaying(cannonLaunch))
            {
                performing = false;
                finished   = true;
            }
        }
        /// <summary>
        /// Checks to see if this object can be disposed.
        ///</summary>
        ///<returns>True if the object can be disposed, false otherwise.</returns>
        public override bool readyToTerminate()
        {
            if (isProjectorStopped || dirty)
            {
                return(true);
            }

            if (explodeSound == null || (explodeSound != null && !DSound.isPlaying(explodeSound)))
            {             //game hasn't ended, or explode sound is playing
                if (Interaction.isGameFinished(true))
                {
                    System.Diagnostics.Trace.WriteLine(String.Format("shutdown {0}, demo expired {1}, abort {2}, player damage is {3}", Options.requestedShutdown, Options.demoExpired, Options.abortGame, (Mission.player == null)?0:Mission.player.damage));
                }
                return(isRequestedTerminated || Interaction.isGameFinished(true));
            }
            return(false);
        }
Пример #16
0
        /// <summary>
        /// Moves the person.
        /// </summary>
        /// <param name="movementDirection">The direction to move in.</param>
        /// <param name="force">True if the person should move regardless of whether the step sound is playing or not; false otherwise.</param>
        public void move(MovementDirection movementDirection, bool force)
        {
            if (lastStepSound != null)
            {
                if (!force && DSound.isPlaying(lastStepSound))
                {
                    return;
                }
                lastStepSound.Stop();
            }

            int lx = x;
            int ly = y;

            if (movementDirection == MovementDirection.north)
            {
                ly++;
            }
            else if (movementDirection == MovementDirection.east)
            {
                lx++;
            }
            else if (movementDirection == MovementDirection.south)
            {
                ly--;
            }
            else
            {
                lx--;
            }
            foreach (FightObject o in things)
            {
                if (o.isBlocked(lx, ly))
                {
                    o.playCrashSound(lx, ly);
                    return;
                }
            }
            if (grabTarget != null)
            {
                grabTarget.updateCoordinates(x, y);
            }
            updateCoordinates(lx, ly);
            playSound(lastStepSound = stepSound[Common.getRandom(0, stepSound.Length - 1)], true, false);
        }
Пример #17
0
 private void playMessage(String o, bool wait)
 {
     if (message != null)
     {
         message.Stop();
     }
     message = DSound.LoadSound(o);
     DSound.PlaySound(message, true, false);
     if (wait)
     {
         Interaction.stopAndMute(true);
         while (DSound.isPlaying(message))
         {
             Thread.Sleep(100);
         }
         Interaction.resumeAndUnmute();
     }             //if wait
 }
Пример #18
0
 public void connect()
 {
     Interaction.stopAndMute(true);
     playMessage(DSound.SoundPath + "\\rf12.wav");
     ((Aircraft)Mission.player).rearm();
     ((Aircraft)Mission.player).restoreDamage(
         (int)(Mission.player.maxDamagePoints * 0.30));
     ((Aircraft)Mission.player).restartEngine(false);
     while (DSound.isPlaying(message))
     {
         Thread.Sleep(500);
     }
     uncall();
     ((Aircraft)Mission.player).requestRefuel();
     Mission.refuelCount++;
     Mission.writeToFile();
     Interaction.resumeAndUnmute();
 }
Пример #19
0
 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);
         }
     }
 }
Пример #20
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 sound will get cut.
                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);
                target.hit(Common.getRandom(101, 200), Interaction.Cause.destroyedByWeapon);
                fireHitEvent(target, target.damage);
                finished = true;
                return;
            }
            if (totalDistance > 15.0)
            {
                missileSound.stop();
                explode();
                finished   = true;
                performing = (missileHitSound != null && DSound.isPlaying(missileHitSound)) || (expl != null && DSound.isPlaying(expl));
            }
        }
Пример #21
0
        private static void showDevices()
        {
            InputDeviceCollection dList = null;
            ////holds keyboards
            InputDeviceCollection dList2 = null;

            ////holds game controllers
            dList = DirectInput.GetDevices(DeviceClass.Keyboard, DeviceEnumerationFlags.AttachedOnly);
            ////enumerator for keyboards
            dList2 = DirectInput.GetDevices(DeviceClass.GameController, DeviceEnumerationFlags.AttachedOnly);
            ////enumerator for all game controllers

            DeviceInstance[] devList = null;
            devList = (DeviceInstance[])(Array.CreateInstance(typeof(DeviceInstance),
                                                              (dList2 == null) ? 1 : 2));
            foreach (DeviceInstance d in dList)
            {
                devList[0] = d;
                break;
            }
            if (dList2 != null)
            {
                foreach (DeviceInstance d in dList2)
                {
                    devList[1] = d;
                    break;
                }
            }
            string[] devListSTR = new string[(dList2 == null) ? 1 : 2];
            devListSTR[0] = "mainmenu_5_1_1.wav";
            if (dList2 != null)
            {
                devListSTR[1] = "mainmenu_5_1_2.wav";
            }
            int mindex = Common.sVGenerateMenu(null, devListSTR);

            if (mindex == -1)
            {
                return;
            }
            ////exit menu
            if (mindex > 0)
            {
                ////chose joystick
                ////so config it
                dxInput.DInputInit(Common.mainGUI.Handle, devList[mindex].InstanceGuid);
                configureJS(devList[mindex].InstanceGuid);
                KeyMap.readFromFile();
                SecondarySoundBuffer confirm = DSound.LoadSound(DSound.NSoundPath + "\\gce.wav");
                DSound.PlaySound(confirm, true, false);
                while (DSound.isPlaying(confirm))
                {
                    Thread.Sleep(10);
                }
                DSound.unloadSound(confirm);
                confirm = null;
            }
            else
            {
                if (dxInput.JSDevice != null)
                {
                    dxInput.JSDevice.Unacquire();
                    dxInput.JSDevice = null;
                }         //if !null
                KeyMap.readFromFile();
            }             //if chose keyboard
        }
Пример #22
0
		public override bool clearForRemoval()
		{
			if (damage > 0)
				return false;
			return destroySound != null && !DSound.isPlaying(destroySound);
		}
Пример #23
0
        public void move()
        {
            if (isAI)
            {
                throwMissile(Interaction.player);
                lockOnPerson(Interaction.player);
                if (shootTarget != null)
                {
                    shootPerson(shootTarget);
                }
                moveMissiles();
            }
            if (beingGrabbed)
            {
                return;
            }
            if (isStunned())
            {
                playSound(stunSound, false, true);
                return;
            }
            else if (DSound.isPlaying(stunSound))
            {
                stunSound.Stop();
            }
            if (isAI)
            {
                if (!isInPanicMode && (double)(damage / maxDamage) * 100 <= 40)
                {
                    isInPanicMode = true;
                }
                if (isInPanicMode)
                {
                    if (Common.getRandom(1, 100) <= 2)
                    {
                        seekRandomCoordinates();
                    }
                }
                if (isInRange(Interaction.player))
                {
                    if (grabTarget == null)
                    {
                        punchSomeone(Interaction.player, 50);
                        if (!seeking && !Interaction.player.isStunned())
                        {
                            if (grabSomeone(Interaction.player))
                            {
                                seekRandomFurniture();
                            }
                        }
                    }
                    else if (!seeking)                         //If someone's already being held.
                    {
                        if (Common.getRandom(1, 100) < 30)
                        {
                            letGoOfTarget();
                        }
                        else
                        {
                            tossTarget();
                            if (Common.getRandom(1, 2) == 1)
                            {
                                seekRandomCoordinates();
                            }
                        }
                    }
                }
                else                   //if not in range
                {
                    startSeeking(Interaction.player);
                }
                seek();
            }
            else                 //if not AI
            {
                if (DXInput.isFirstPress(Key.Space))
                {
                    punchSomeone(null, 100);
                }

                if (DXInput.isKeyHeldDown(Key.LeftShift) || DXInput.isKeyHeldDown(Key.RightShift))
                {
                    block();
                }
                else
                {
                    stopBlocking();
                }

                if (DXInput.isKeyHeldDown(Key.LeftControl) || DXInput.isKeyHeldDown(Key.RightControl))
                {
                    grabSomeone(null);
                }
                else if (grabTarget != null)
                {
                    tossTarget();
                }

                if (DXInput.isKeyHeldDown(Key.Up))
                {
                    move(Person.MovementDirection.north, DXInput.isFirstPress(Key.Up));
                }
                else if (DXInput.isKeyHeldDown(Key.Right))
                {
                    move(Person.MovementDirection.east, DXInput.isFirstPress(Key.Right));
                }
                else if (DXInput.isKeyHeldDown(Key.Down))
                {
                    move(Person.MovementDirection.south, DXInput.isFirstPress(Key.Down));
                }
                else if (DXInput.isKeyHeldDown(Key.Left))
                {
                    move(Person.MovementDirection.west, DXInput.isFirstPress(Key.Left));
                }
                if (DXInput.isFirstPress(Key.F6))
                {
                    decreaseMusicVolume();
                }
                if (DXInput.isFirstPress(Key.F7))
                {
                    increaseMusicVolume();
                }
            }
            if (swinging && (DateTime.Now - startSwingTime).TotalMilliseconds > 200)
            {
                doPunch();
            }
        }