Beispiel #1
0
        public void landPlayer()
        {
            playerLanded = true;
            Interaction.stopAndMute(true, true);
            moveSound.Stop();
            Common.fadeMusic();
            playMessage(DSound.SoundPath + "\\ac" + ((landedBefore) ? "6" : "5") + ".ogg");
            landedBefore = true;
            long mark = Environment.TickCount;

            ((Aircraft)Mission.player).rearm();
            ((Aircraft)Mission.player).restoreDamage(0);
            while (message.isPlaying())
            {
                if ((Environment.TickCount - mark) / 1000 >= 3 && (DXInput.isKeyHeldDown() || DXInput.isJSButtonHeldDown()))
                {
                    break;
                }
                Thread.Sleep(50);
            }
            message.stopOgg();
            playMessage(DSound.SoundPath + "\\ac7.ogg");
            while (message.isPlaying())
            {
                Thread.Sleep(500);
            }
            ((Aircraft)Mission.player).catapult();
            Common.startMusic();
            ((Aircraft)Mission.player).requestRefuel();
            playSound(moveSound, true, true);
            Interaction.resumeAndUnmute();
        }
        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
                {
                    missileLaunchSound.Pan = (ammunitionNumber + 1) / 2 * 2500; //give 1 to ammunition number so we can divide properly; adding 1 will make it evenly divisible by 2.
                }
                else
                {
                    missileLaunchSound.Pan = ammunitionNumber / 2 * -2500;
                }
                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);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Says something through the speech source.
        /// </summary>
        /// <param name="sayString">The string to speak</param>
        /// <param name="flag">The way the string should be spoken. For example, if noInterrupt is passed, then the thread is halted until the message is finished speaking. See the flags enum for a description of each flag.</param>
        public static void speak(string sayString, SpeakFlag flag)
        {
            if (flag == SpeakFlag.interruptableButStop || flag == SpeakFlag.noInterruptButStop)
            {
                purge();
            }
            string sayStringW = processText(sayString);

            lastSpokenString = sayString;
            if (source == SpeechSource.auto)
            {
                if (initializeJAWS() && sayThroughJAWS(sayString, flag == SpeakFlag.interruptableButStop || flag == SpeakFlag.noInterruptButStop))
                {
                    startSpeakTimerOn(sayStringW);
                }
                else if (((Environment.Is64BitProcess) ? nvdaController64_speakText(sayString) : nvdaController_speakText(sayString)) == 0)
                {
                    startSpeakTimerOn(sayStringW);
                }
            }
            else
            {
                // if we got down here, none of the other screen readers are loaded or source is SAPI
                initialize();
                voice.SpeakAsync(sayString);
                // Wait for SAPI to actually begin speaking, otherwise we'll get a race condition where a query to isSpeaking will return false if
                // SAPI takes a little while to start speaking the string.
                while (!isSpeaking())
                {
                    Thread.Sleep(0);
                }
            }
            if (flag == SpeakFlag.none)
            {
                return;
            }
            if (flag == SpeakFlag.interruptable || flag == SpeakFlag.interruptableButStop)
            {
                while (DXInput.isKeyHeldDown() || DXInput.isJSButtonHeldDown())                   // So the loop doesn't break if we hold ENTER for too long.
                {
                    if (!isSpeaking())
                    {
                        break;
                    }
                    Thread.Sleep(0);
                }
            }
            while (isSpeaking())
            {
                if (flag == SpeakFlag.interruptable || flag == SpeakFlag.interruptableButStop)
                {
                    if (DXInput.isKeyHeldDown() || DXInput.isJSButtonHeldDown())
                    {
                        break;
                    }
                }
                Thread.Sleep(10);
            }
        }
Beispiel #4
0
 public override void use()
 {
     direction = weapon.creator.direction;
     if (!isAI)
     {
         DXInput.startFireEffect();
     }
 }
Beispiel #5
0
 public override void use()
 {
     direction = Degrees.GetDegreesBetween(x, y, origTarget.x, origTarget.y);
     z         = origTarget.z;
     playSound(launchSound, true, false);
     if (!isAI)
     {
         DXInput.startFireEffect();
     }
 }
Beispiel #6
0
 ////Returns true if another modifier for this same key assignment is pressed,
 ////false otherwise
 public static bool isModifierHeldFor(Aircraft.Action a)
 {
     if (keysData[(int)a - 1].modifier > 0)
     {
         if (DXInput.isKeyHeldDown((Key)keysData[(int)a - 1].modifier))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #7
0
        static void MoveCamera(ref DXCamera camera, float deltaTime)
        {
            float sprintMod = 0.5f;

            if (DXInput.IsKeyPressed(16))
            {
                sprintMod = 4.0f;
            }
            float moveSpeed = 2.0f * sprintMod;
            float rotSpeed  = 2.0f;

            if (DXInput.IsKeyPressed('A'))
            {
                camera.Translate(new DXVector(-moveSpeed * deltaTime, 0, 0, 1));
            }
            else if (DXInput.IsKeyPressed('D'))
            {
                camera.Translate(new DXVector(moveSpeed * deltaTime, 0, 0, 1));
            }

            if (DXInput.IsKeyPressed('W'))
            {
                camera.Translate(new DXVector(0, 0, moveSpeed * deltaTime, 1));
            }
            else if (DXInput.IsKeyPressed('S'))
            {
                camera.Translate(new DXVector(0, 0, -moveSpeed * deltaTime, 1));
            }

            if (DXInput.IsKeyPressed(37))
            {
                camera.Rotate(new DXVector(0, -rotSpeed * deltaTime, 0, 0));
            }
            else if (DXInput.IsKeyPressed(39))
            {
                camera.Rotate(new DXVector(0, rotSpeed * deltaTime, 0, 0));
            }

            if (DXInput.IsKeyPressed(38))
            {
                camera.Rotate(new DXVector(-rotSpeed * deltaTime, 0, 0, 0));
            }
            else if (DXInput.IsKeyPressed(40))
            {
                camera.Rotate(new DXVector(rotSpeed * deltaTime, 0, 0, 0));
            }
            camera.Update();
        }
Beispiel #8
0
 public override void use()
 {
     direction = Degrees.GetDegreesBetween(x, y, origTarget.x, origTarget.y);
     z         = origTarget.z;
     time      = Environment.TickCount;
     playSound(launchSound, true, false);
     if (isAI)
     {
         if (origTarget is Aircraft)
         {
             ((Aircraft)origTarget).notifyOf(Notifications.missileLaunch, true);
         }
         return;
     }
     DXInput.startCruiseMissileEffect();
     fox = loadSound(soundPath + "fox3.wav");
     playSound(fox, true, false);
 }
Beispiel #9
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();
            }
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            DXWindow           window           = new DXWindow();
            DXRenderingManager renderingManager = new DXRenderingManager();

            DXCamera camera = new DXCamera();

            DXDeltaTime deltaTimer = new DXDeltaTime();

            window.Create(Process.GetCurrentProcess(),
                          "Test",
                          1280,
                          720,
                          false);

            renderingManager.Init(window);

            DXStaticMesh cubeMesh = new DXStaticMesh();

            DXTexture texture      = new DXTexture();
            DXTexture normal       = new DXTexture();
            DXTexture metallic     = new DXTexture();
            DXTexture displacement = new DXTexture();

            DXDrawable drawable = new DXDrawable();

            DXDirectionalLight directionalLight = new DXDirectionalLight(renderingManager, window);

            directionalLight.Init();


            directionalLight.Intensity = 10;
            directionalLight.SetDirection(new DXVector(0, -1, -1, 0));
            directionalLight.Update();

            bool loadSucceeded = true;

            if (cubeMesh.Init())
            {
                if (cubeMesh.LoadStaticMesh("../../Models/Cube.fbx"))
                {
                    if (!cubeMesh.CreateBuffer(renderingManager))
                    {
                        loadSucceeded = false;
                    }
                }
            }

            if (!texture.LoadDDSTexture("../../Texture/Brick/Brick_diffuse.DDS", true, renderingManager))
            {
                loadSucceeded = false;
            }
            if (!normal.LoadDDSTexture("../../Texture/Brick/Brick_normal.DDS", true, renderingManager))
            {
                loadSucceeded = false;
            }
            if (!metallic.LoadDDSTexture("../../Texture/Brick/Brick_metallic.DDS", true, renderingManager))
            {
                loadSucceeded = false;
            }
            if (!displacement.LoadDDSTexture("../../Texture/Brick/Brick_height.DDS", true, renderingManager))
            {
                loadSucceeded = false;
            }

            drawable.SetStaticMesh(cubeMesh);
            drawable.SetTexture(texture);
            drawable.SetNormalMap(normal);
            drawable.SetMetallicMap(metallic);
            drawable.SetDisplacementMap(displacement);
            drawable.SetPosition(new DXVector(0, 0, -5, 1));
            drawable.Update();

            camera.SetPosition(new DXVector(0, 0, 0, 1));
            camera.SetDirection(new DXVector(0, 0, -1, 0));
            camera.Update();

            deltaTimer.Init();
            while (window.IsOpen && loadSucceeded)
            {
                float deltaTime = deltaTimer.GetDeltaTime();
                if (window.Updating())
                {
                    //Window is updating
                }

                MoveCamera(ref camera, deltaTime);

                if (DXInput.IsKeyPressed('Q'))
                {
                    directionalLight.Queue();
                }

                drawable.Draw(renderingManager);
                renderingManager.Flush(camera);
            }
            texture.Release();
            normal.Release();
            metallic.Release();
            displacement.Release();
            cubeMesh.Release();

            directionalLight.Release();


            renderingManager.Release();
        }