Example #1
0
 public void recorrerCamino()
 {
     if (activarAnimacion)
     {
         Boolean i           = true;
         float   elapsedTime = GuiController.Instance.ElapsedTime;
         while (caminoIda[contador] != null && i)
         {
             if ((mesh.Position - caminoIda[contador]).Length() < 1f)
             {
                 contador++;
                 if (contador == cantidadWP)
                 {
                     activarAnimacion = false;
                     animada          = true;
                     sonidoPreSusto.stop();
                 }
             }
             else
             {
                 this.seguirA(caminoIda[contador], elapsedTime, 200f);
             }
             i = false;
         }
     }
 }
 public void playSonidoFruta()
 {
     if (estado_sonido)
     {
         //mp3FruitPlayer.play(false);
         SonidoMoneda.stop();
         SonidoMoneda.play(false);
     }
 }
Example #3
0
        public void Update(float elapsedTime)
        {
            if (!Playing)
            {
                return;
            }

            time += elapsedTime;

            int last_frame = current_frame;

            current_frame = (int)(time * FPS);

            // muy lento, compensar
            if (current_frame - last_frame > 2)
            {
                current_frame = last_frame + 2;
            }

            if (current_frame >= TotalFrames)
            {
                Playing = false;
                sound.stop();
                this.Dispose();
            }
            else
            {
                sprite.Texture = frames[current_frame];
            }
        }
Example #4
0
        public override void Render()
        {
            PreRender();

            //Ver si cambio el WAV
            var filePath = wavFileModifier.Value;

            loadSound(filePath);

            //Contro el input de teclado
            if (Input.keyPressed(Key.Y))
            {
                var playLoop = playLoopModifier.Value;
                sound.play(playLoop);
            }
            else if (Input.keyPressed(Key.O))
            {
                sound.stop();
            }

            //Render texto
            currentSoundText.render();
            instruccionesText.render();

            PostRender();
        }
        public override void Render()
        {
            PreRender();

            //Ver si cambio el WAV
            var filePath = (string)Modifiers["WAV-File"];

            loadSound(filePath);

            //Contro el input de teclado
            if (Input.keyPressed(Key.Y))
            {
                var playLoop = (bool)Modifiers["PlayLoop"];
                sound.play(playLoop);
            }
            else if (Input.keyPressed(Key.O))
            {
                sound.stop();
            }

            //Render texto
            currentSoundText.render();
            instruccionesText.render();

            PostRender();
        }
Example #6
0
        public override void render(float elapsedTime)
        {
            Device d3dDevice = GuiController.Instance.D3dDevice;

            //Ver si cambio el WAV
            string filePath = (string)GuiController.Instance.Modifiers["WAV-File"];

            loadSound(filePath);


            //Contro el input de teclado
            if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Y))
            {
                bool playLoop = (bool)GuiController.Instance.Modifiers["PlayLoop"];
                sound.play(playLoop);
            }
            else if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.O))
            {
                sound.stop();
            }


            //Render texto
            currentSoundText.render();
            instruccionesText.render();
        }
Example #7
0
        /// <summary>
        /// Método que reproduce el sonido ambiente (oceano).
        /// Sólo se reproduce el sonido si está habilitado el modifier "Sonido Ambiente".
        /// </summary>
        private static void ReproducirSonidoAmbiente()
        {
            if (!ParametrosDeConfiguracion.Sonido.SonidoAmbiente)
            {
                RuidoAmbienteOceano.stop();
                RuidoAmbienteSubmarino.stop();
                return;
            }

            if (Utiles.CamaraSumergida)
            {
                RuidoAmbienteOceano.stop();
                RuidoAmbienteSubmarino.play(true);
            }
            else
            {
                RuidoAmbienteSubmarino.stop();
                RuidoAmbienteOceano.play(true);
            }
        }
Example #8
0
        private void verificarConfiguracion()
        {
            //Ver si cambio el heightmap
            string selectedHeightmap = (string)GuiController.Instance.Modifiers["heightmap"];

            if (Parametros.getCurrentHMap() != selectedHeightmap)
            {
                //Volver a cargar el Heightmap
                Parametros.setCurrentHMap(selectedHeightmap);
                terrain.loadHeightmap(Parametros.getCurrentHMap(), Parametros.getCurrentScaleXZ(), Parametros.getCurrentScaleY(), new Vector3(0, 0, 0));
            }

            //Ver si cambio alguno de los valores de escala
            float selectedScaleXZ = (float)GuiController.Instance.Modifiers["scaleXZ"];
            float selectedScaleY  = (float)GuiController.Instance.Modifiers["scaleY"];

            if (Parametros.getCurrentScaleXZ() != selectedScaleXZ || Parametros.getCurrentScaleY() != selectedScaleY)
            {
                //Volver a cargar el Heightmap
                Parametros.setCurrentScaleXZ(selectedScaleXZ);
                Parametros.setCurrentScaleY(selectedScaleY);
                terrain.loadHeightmap(Parametros.getCurrentHMap(), Parametros.getCurrentScaleXZ(), Parametros.getCurrentScaleY(), new Vector3(0, 0, 0));
            }

            //Ver si cambio la textura del terreno
            string selectedTexture = (string)GuiController.Instance.Modifiers["texture"];

            if (Parametros.getCurrentTexture() != selectedTexture)
            {
                //Volver a cargar el DiffuseMap
                Parametros.setCurrentTexture(selectedTexture);
                terrain.loadTexture(Parametros.getCurrentTexture());
            }

            //Ver si cambio la opcion de activar sonidos
            if ((bool)GuiController.Instance.Modifiers["sonidoOceano"])
            {
                sonidoAmbienteOceano.play(true);
            }
            else
            {
                sonidoAmbienteOceano.stop();
            }

            if ((bool)GuiController.Instance.Modifiers.getValue("dia"))
            {
                crearSkyBoxDia();
            }
            else
            {
                crearSkyBoxNoche();
            }
        }
Example #9
0
        public void Update()
        {
            if (paused)
            {
                return;
            }
            if (delay > 0f)
            {
                delay -= VariablesGlobales.elapsedTime;
                return;
            }
            if (infinito)
            {
                sonido.play(true);
            }
            else if (!terminado)
            {
                if (duracion > 0.0f)
                {
                    duracion -= VariablesGlobales.elapsedTime;

                    try
                    {
                        sonido.play(true);
                    }
                    catch (System.Exception e)
                    {
                        terminado = true;
                    }
                }
                else
                {
                    terminado = true;
                    sonido.stop();
                }
            }
        }
Example #10
0
        public override void Init()
        {
            vida       = 100;
            sprintTime = 0;
            tiredTime  = 0;
            running    = false;

            hitSound    = new TgcStaticSound();
            breathSound = new TgcStaticSound();
            walkSound   = new TgcStaticSound();
            runSound    = new TgcStaticSound();

            sniper = new Sniper();
            sniper.Init();
            launcher = new RocketLauncher();
            launcher.Init();

            weapon = sniper;
            weapon.muzzle.scale = weapon.scaleMuzzle;

            //Mesh auxiliar para el sonido
            TgcSceneLoader loader = new TgcSceneLoader();
            TgcScene       scene2 = loader.loadSceneFromFile(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Meshes\\svd\\svd-TgcScene.xml");

            meshAuxiliarParaSonido = scene2.Meshes[0];

            //hago que los 3dSound sigan al arma
            GuiController.Instance.DirectSound.ListenerTracking = meshAuxiliarParaSonido;
            ///////////////CONFIGURAR CAMARA PRIMERA PERSONA CUSTOM//////////////////
            //Camara en primera persona, tipo videojuego FPS
            //Solo puede haber una camara habilitada a la vez. Al habilitar la camara FPS se deshabilita la camara rotacional
            //Por default la camara FPS viene desactivada
            GuiController.Instance.RotCamera.Enable = false;
            CustomFpsCamera.Instance.Enable         = true;
            GuiController.Instance.CurrentCamera    = CustomFpsCamera.Instance;
            //Configurar posicion y hacia donde se mira
            CustomFpsCamera.Instance.setCamera(new Vector3(0, 930, 0), new Vector3(-400, 930, 0));

            prevEye = CustomFpsCamera.Instance.eye;
            //cargar sonido
            breathSound.loadSound(breathingSoundDir, HUDManager.Instance.PLAYER_VOLUME);
            hitSound.loadSound(hitSoundDir, HUDManager.Instance.PLAYER_VOLUME);
            //reproducir sonido de respawn
            playSound(walkSound, walkSoundDir, true);
            playSound(runSound, runSoundDir, true);
            runSound.stop();
            walkSound.stop();
        }
Example #11
0
        public override void Update()
        {
            //Ver si cambio el WAV
            var filePath = wavFileModifier.Value;

            loadSound(filePath);

            //Controlo el input de teclado
            if (Input.keyPressed(Key.Y))
            {
                var playLoop = playLoopModifier.Value;
                sound.play(playLoop);
            }
            else if (Input.keyPressed(Key.O))
            {
                sound.stop();
            }
        }
 public static void detener()
 {
     helicoptero.stop();
 }
 public void stop()
 {
     musica.stop();
 }
 public void ParaMotor()
 {
     Aceleracion.stop();
 }
Example #15
0
        public override void Update(float elapsedTime)
        {
            /* string weap = (string)GuiController.Instance.Modifiers.getValue("Arma");
             * switch (weap)
             * {
             *   case "Sniper":
             *       weapon = sniper;
             *       break;
             *
             *   case "Rocket Launcher":
             *       weapon = launcher;
             *       break;
             * }*/



            //update de la pos del mesh auxiliar
            meshAuxiliarParaSonido.Position = CustomFpsCamera.Instance.eye;
            //Procesamos input de teclado
            TgcD3dInput input = GuiController.Instance.D3dInput;

            //Seteamos las teclas
            if (GuiController.Instance.D3dInput.buttonDown(TgcD3dInput.MouseButtons.BUTTON_LEFT) && weapon.FIRE_DELAY <= 0)
            {
                weapon.FIRE_DELAY          = weapon.MAX_DELAY;
                weapon.muzzle.MUZZLE_DELAY = weapon.muzzle.MAX_DELAY;
                weapon.muzzle.TIME_RENDER  = weapon.muzzle.MAX_RENDER;
                weapon.fireWeapon();
                CustomFpsCamera.Instance.rotateSmoothly(-0.30f, -1.5f, 0);
            }

            if (weapon.FIRE_DELAY > 0)
            {
                weapon.FIRE_DELAY -= elapsedTime;
            }
            if (weapon.muzzle.MUZZLE_DELAY > 0)
            {
                weapon.muzzle.MUZZLE_DELAY -= elapsedTime;
            }
            if (weapon.muzzle.TIME_RENDER > 0)
            {
                weapon.muzzle.TIME_RENDER -= elapsedTime;
            }


            if (GuiController.Instance.D3dInput.buttonPressed(TgcD3dInput.MouseButtons.BUTTON_RIGHT) && ZOOM_DELAY <= 0.5f)
            {
                ZOOM_DELAY = MAX_ZOOM_DELAY;
                HUDManager.Instance.zoomCamera();
            }

            if (GuiController.Instance.D3dInput.keyDown(Key.LeftShift) && sprintTime < MAX_SPRINT_TIME)
            {
                CustomFpsCamera.Instance.MovementSpeed = 3 * CustomFpsCamera.DEFAULT_MOVEMENT_SPEED;
                sprintTime += elapsedTime;
                if (!running)
                {
                    runSound.play(true);
                    walkSound.stop();
                    running = true;
                }
                if (sprintTime > MAX_SPRINT_TIME)
                {
                    breathSound.play(true);
                    tiredTime = 0;
                }
            }
            else
            {
                CustomFpsCamera.Instance.MovementSpeed = CustomFpsCamera.DEFAULT_MOVEMENT_SPEED;
                tiredTime += elapsedTime;
                if (running)
                {
                    runSound.stop();
                    walkSound.play(true);
                    running = false;
                }
                if (tiredTime > TIRED_TIME && sprintTime != 0)
                {
                    breathSound.stop();
                    sprintTime = 0;
                }
            }

            if (ZOOM_DELAY > 0)
            {
                ZOOM_DELAY -= elapsedTime;
            }

            //muzzleFlash.Position = WEAPON_OFFSET;

            weapon.Update(elapsedTime);

            //Maxima inclinacion sobre terreno
            float yActual;
            float yAnterior;
            float movspeed = CustomFpsCamera.Instance.MovementSpeed;

            GameManager.Instance.interpoledHeight(CustomFpsCamera.Instance.eye.X, CustomFpsCamera.Instance.eye.Z, out yActual);
            GameManager.Instance.interpoledHeight(prevEye.X, prevEye.Z, out yAnterior);
            double diferenciaPotenciada = Math.Pow((yActual - yAnterior) / (movspeed * elapsedTime), 2);

            if (diferenciaPotenciada >= intensidadMaximaEscalable)
            {
                CustomFpsCamera.Instance.eye = prevEye;
                CustomFpsCamera.Instance.reconstructViewMatrix(false);
            }


            //Colision de la camara con sliding
            List <TgcMesh> obstaculos = new List <TgcMesh>();

            obstaculos = GameManager.Instance.quadTree.findMeshesToCollide(CustomFpsCamera.Instance.boundingBox);

            foreach (TgcMesh obstaculo in obstaculos)
            {
                if (!obstaculo.Name.StartsWith("ArbustoComplejo"))
                {
                    Vector3 dirMov = CustomFpsCamera.Instance.eye - prevEye;

                    TgcCollisionUtils.BoxBoxResult result = TgcCollisionUtils.classifyBoxBox(CustomFpsCamera.Instance.boundingBox, obstaculo.BoundingBox);
                    if (result == TgcCollisionUtils.BoxBoxResult.Adentro || result == TgcCollisionUtils.BoxBoxResult.Atravesando)
                    {
                        CustomFpsCamera.Instance.eye = prevEye + new Vector3(dirMov.X, 0, 0);
                        CustomFpsCamera.Instance.reconstructViewMatrix(false);
                        TgcCollisionUtils.BoxBoxResult resultX = TgcCollisionUtils.classifyBoxBox(CustomFpsCamera.Instance.boundingBox, obstaculo.BoundingBox);
                        if (resultX == TgcCollisionUtils.BoxBoxResult.Adentro || resultX == TgcCollisionUtils.BoxBoxResult.Atravesando)
                        {
                            CustomFpsCamera.Instance.eye = prevEye + new Vector3(0, 0, dirMov.Z);
                            CustomFpsCamera.Instance.reconstructViewMatrix(false);

                            TgcCollisionUtils.BoxBoxResult resultZ = TgcCollisionUtils.classifyBoxBox(CustomFpsCamera.Instance.boundingBox, obstaculo.BoundingBox);
                            if (resultZ == TgcCollisionUtils.BoxBoxResult.Adentro || resultZ == TgcCollisionUtils.BoxBoxResult.Atravesando)
                            {
                                CustomFpsCamera.Instance.eye = prevEye;
                            }
                        }
                        break;
                    }
                }
            }

            if (prevEye == CustomFpsCamera.Instance.eye)
            {
                walkSound.stop();
                runSound.stop();
            }
            else if (!running)
            {
                walkSound.play(true);
            }

            prevEye = CustomFpsCamera.Instance.eye;
        }
Example #16
0
 public void stopPersecucion()
 {
     respiroPersecucion.stop();
 }
Example #17
0
 public void stopMerlusa()
 {
     respiro.stop();
 }
Example #18
0
 public void stopSonidoRespiracionCadaTanto()
 {
     respiracionCadaTanto.stop();
 }
Example #19
0
 public void stopSonidoMonstruo()
 {
     monstruo.stop();
 }
Example #20
0
 public void stopFondo()
 {
     fondoSonido.stop();
 }
Example #21
0
 private void stopSound()
 {
     sound.stop();
 }
 public void ParaMusica()
 {
     Musica.stop();
 }
        public void Update(TgcD3dInput input)
        {
            Fisica.dynamicsWorld.StepSimulation(1 / 60f, 10);
            CuerpoRigidoAuto.ActivationState = ActivationState.ActiveTag;
            CuerpoRigidoAuto.AngularVelocity = TGCVector3.Empty.ToBulletVector3();
            float fuerzaMotor = 0;

            //Movimientos Adelante-Atras
            if (EnElPiso())
            {
                CuerpoRigidoAuto.SetDamping(0.32f, 0.1f);
                if (input.keyDown(TeclaAcelerar))
                {
                    if (Velocidad >= 0)
                    {
                        Direccion   = 1;
                        fuerzaMotor = 14000f * ElapsedTime;
                        if (FXActivado)
                        {
                            sonidoAceleracion.play(true);
                        }
                        else
                        {
                            sonidoAceleracion.stop();
                        }
                    }
                }
                else if (input.keyDown(TeclaAtras))
                {
                    if (Velocidad <= 5f)
                    {
                        Direccion   = -1;
                        fuerzaMotor = 300f;
                        if (FXActivado)
                        {
                            sonidoAceleracion.play(true);
                        }
                        else
                        {
                            sonidoAceleracion.stop();
                        }
                    }
                }
                else
                {
                    fuerzaMotor = 0f;
                    sonidoAceleracion.stop();
                }

                //Movimientos Derecha-Izquierda
                if (input.keyDown(TeclaIzquierda))
                {
                    CuerpoRigidoAuto.ApplyImpulse(new TGCVector3(1, 0, 0).ToBulletVector3() * FuerzaAlGirar(), new TGCVector3(20, 10, -60).ToBulletVector3());
                    CuerpoRigidoAuto.ApplyImpulse(new TGCVector3(-1, 0, 0).ToBulletVector3() * FuerzaAlGirar(), new TGCVector3(20, 10, 60).ToBulletVector3());
                    GradosRuedaAlDoblar = FastMath.Max(GradosRuedaAlDoblar - 0.04f, -0.7f);
                }
                else if (input.keyDown(TeclaDerecha))
                {
                    CuerpoRigidoAuto.ApplyImpulse(new TGCVector3(-1, 0, 0).ToBulletVector3() * FuerzaAlGirar(), new TGCVector3(20, 10, -60).ToBulletVector3());
                    CuerpoRigidoAuto.ApplyImpulse(new TGCVector3(1, 0, 0).ToBulletVector3() * FuerzaAlGirar(), new TGCVector3(20, 10, 60).ToBulletVector3());
                    GradosRuedaAlDoblar = FastMath.Min(GradosRuedaAlDoblar + 0.04f, 0.7f);
                }
                else
                {
                    GradosRuedaAlDoblar = 0;
                }

                //Movimientos Freno
                if (input.keyDown(TeclaFreno))
                {
                    CuerpoRigidoAuto.Friction = 8f;
                    if (FXActivado)
                    {
                        frenada.play();
                    }
                }
                else
                {
                    CuerpoRigidoAuto.Friction = FriccionAuto;
                }

                //Movimientos Salto
                if (input.keyPressed(TeclaSalto))
                {
                    FuerzaSalto = 21f;
                    CuerpoRigidoAuto.ApplyCentralImpulse(VectorSalto.ToBulletVector3() * FuerzaSalto * Velocidad);
                }
            }
            else
            {
                CuerpoRigidoAuto.SetDamping(0f, 0f);
                if (input.keyDown(TeclaIzquierda))
                {
                    GradosRuedaAlDoblar = FastMath.Max(GradosRuedaAlDoblar - 0.04f, -0.7f);
                }
                else if (input.keyDown(TeclaDerecha))
                {
                    GradosRuedaAlDoblar = FastMath.Min(GradosRuedaAlDoblar + 0.04f, 0.7f);
                }
            }
            float impulso = 0;

            if (Velocidad < 15)
            {
                impulso = fuerzaMotor;
            }
            else if (Velocidad >= 15 && Velocidad < 35)
            {
                impulso = 1.8f * fuerzaMotor;
            }
            else if (Velocidad >= 35 && Velocidad < 60)
            {
                impulso = 3.2f * fuerzaMotor;
            }
            else if (Velocidad >= 60 && Velocidad < 80)
            {
                impulso = 4.2f * fuerzaMotor;
            }
            else if (Velocidad >= 80 && Velocidad < 100)
            {
                impulso = 5.2f * fuerzaMotor;
            }
            else
            {
                impulso = FastMath.Min(7f * fuerzaMotor, 1020f);
            }
            CuerpoRigidoAuto.ApplyCentralImpulse(impulso * VersorDirector.ToBulletVector3() * Direccion);
        }
 public void DetenerSonido()
 {
     player.stop();
 }
 public void ParaTribuna()
 {
     Tribuna.stop();
 }
        private void Move(TGCVector3 movement, float ElapsedTime)
        {
            TGCVector3 lastPos = mesh.Position;

            mesh.Position += movement;
            colision.stop();
            if (estaEnNave)
            {
                // todo: chequear colisiones con la mesa y silla
                //Check for collisions
                bool          collided = false;
                List <TGCBox> meshes   = InteriorNave.Instance().obtenerParedes();
                foreach (var pared in meshes)
                {
                    var result = TgcCollisionUtils.classifyBoxBox(mesh.BoundingBox, pared.BoundingBox);
                    if (result == TgcCollisionUtils.BoxBoxResult.Adentro ||
                        result == TgcCollisionUtils.BoxBoxResult.Atravesando)
                    {
                        collided = true;
                        break;
                    }
                }
                if (!collided)
                {
                    List <TgcMesh> elementosMesa = MesaNave.Instance().meshes();
                    foreach (var elemento in elementosMesa)
                    {
                        //var result = TgcCollisionUtils.testAABBAABB(mesh.BoundingBox, elemento.BoundingBox);
                        var result = TgcCollisionUtils.testAABBAABB(new TgcBoundingAxisAlignBox(new TGCVector3(mesh.Position.X, elemento.Position.Y, mesh.Position.Z), mesh.Position), elemento.BoundingBox);
                        if (result)
                        {
                            collided = true;
                            break;
                        }
                    }
                }
                if (!collided)
                {
                    List <TgcMesh> elementosSilla = SillaInterior.Instance().meshes();
                    foreach (var elemento in elementosSilla)
                    {
                        //var result = TgcCollisionUtils.testAABBAABB(mesh.BoundingBox, elemento.BoundingBox);
                        var result = TgcCollisionUtils.testAABBAABB(new TgcBoundingAxisAlignBox(new TGCVector3(mesh.Position.X, elemento.Position.Y, mesh.Position.Z), mesh.Position), elemento.BoundingBox);
                        if (result)
                        {
                            collided = true;
                            break;
                        }
                    }
                }
                if (!collided)
                {
                    List <TgcMesh> elementosTimon = TimonInterior.Instance().meshes();
                    foreach (var elemento in elementosTimon)
                    {
                        var result = TgcCollisionUtils.testAABBAABB(mesh.BoundingBox, elemento.BoundingBox);
                        if (result)
                        {
                            collided = true;
                            break;
                        }
                    }
                }
                //If any collision then go to last position.
                if (collided)
                {
                    mesh.Position = lastPos;
                    colision.play(true);
                }
                if (mesh.Position != lastPos)
                {
                    walking.play(true);
                }
                else
                {
                    walking.stop();
                }
            }
            else
            {
                // todo: manejamos que la colision de la nave haga que el player entre y sacamos lo del press en la "o"?
                bool           collided = false;
                List <TgcMesh> meshes   = Nave.Instance().obtenerMeshes();
                foreach (var meshNave in meshes)
                {
                    var result = TgcCollisionUtils.testAABBAABB(mesh.BoundingBox, meshNave.BoundingBox);
                    if (result)
                    {
                        collided = true;
                        break;
                    }
                }
                //If any collision then go to last position.
                if (collided)
                {
                    mesh.Position = lastPos;
                    colision.play(true);
                    return;
                }

                List <Entity> entities = Entities.GetEntities();
                foreach (var entity in entities)
                {
                    var result = TgcCollisionUtils.testAABBAABB(mesh.BoundingBox, entity.GetMesh().BoundingBox);
                    if (result)
                    {
                        collided = true;
                        break;
                    }
                }
                //If any collision then go to last position.
                if (collided)
                {
                    mesh.Position = lastPos;
                    colision.play(true);
                    return;
                }
                if (mesh.Position.X > 1000f || mesh.Position.X < -1000f || mesh.Position.Z > 1000f || mesh.Position.Z < -1000f)
                {
                    // limitamos cuanto se puede mover el jugador
                    mesh.Position = lastPos;
                    colision.play(true);
                }
                // colisiones contra elementos del mar
            }
        }
Example #27
0
        /// <summary>
        ///     Se llama en cada frame.
        ///     Se debe escribir toda la lógica de computo del modelo, así como también verificar entradas del usuario y reacciones
        ///     ante ellas.
        /// </summary>
        public override void Update()
        {
            PreUpdate();
            if (disposing)
            {
                PostUpdate();
                return;
            }
            time += ElapsedTime;
            effect.SetValue("health", Player.Health());

            Hud.Update(Input);
            estaEnAlgunMenu = Hud.GetCurrentStatus() == Hud.Status.MainMenu || Hud.GetCurrentStatus() == Hud.Status.Instructions;

            //Que no se pueda hacer nada si estas en game over salvo dar enter
            if (Hud.GetCurrentStatus() == Hud.Status.GameOver || Hud.GetCurrentStatus() == Hud.Status.Win)
            {
                // si gano hay que hacer update del tiburon para verlo desaparecer
                if (Hud.GetCurrentStatus() == Hud.Status.Win)
                {
                    shark.Update(ElapsedTime);
                }
                PostUpdate();
                return;
            }
            if ((estadoAnterior == Hud.Status.MainMenu || estadoAnterior == Hud.Status.Instructions) && !estaEnAlgunMenu)
            {
                // me meto en la nave cuando paso del menu
                estaEnNave = true;
                Player.Update(ElapsedTime, ref estaEnNave, true);
            }
            estadoAnterior = Hud.GetCurrentStatus();
            if (estaEnAlgunMenu && !disposing)
            {
                sonidoUnderwater.play(true);
                // update de elementos de agua
                nave.Update();
                Oceano.Update(time);
                oceano.Update();
                Particulas.Update(time);
                foreach (var pez in peces)
                {
                    pez.Update(ElapsedTime);
                }
                foreach (var coral in corales)
                {
                    coral.Update(ElapsedTime);
                }
                foreach (var metal in metales)
                {
                    metal.Update(ElapsedTime);
                }
                foreach (var piedra in piedras)
                {
                    piedra.Update(ElapsedTime);
                }

                fog.updateValues();
                effect.SetValue("ColorFog", fog.Color.ToArgb());
                effect.SetValue("CameraPos", TGCVector3.TGCVector3ToFloat4Array(Camera.Position));
                effect.SetValue("StartFogDistance", fog.StartDistance);
                effect.SetValue("EndFogDistance", fog.EndDistance);
                effect.SetValue("Density", fog.Density);
                effect.SetValue("eyePos", TGCVector3.TGCVector3ToFloat3Array(Camera.Position));
            }
            if (!estaEnAlgunMenu)
            {
                arma.Update();
                if (estaEnNave)
                {
                    interiorNave.Update();
                    sharkSound.stop();
                    sonidoUnderwater.stop();
                    efectoInterior.SetValue("eyePos", TGCVector3.TGCVector3ToFloat3Array(Camera.Position));
                }
                else
                {
                    sonidoUnderwater.play(true);
                    // update de elementos de agua
                    nave.Update();
                    Oceano.Update(time);
                    oceano.Update();
                    Particulas.Update(time);

                    DateTime actualTimestamp = DateTime.Now;
                    // Mostrar Tiburon cada X cantidad de tiempo
                    if (actualTimestamp.Subtract(timestamp).TotalSeconds > 15)
                    {
                        shark.Spawn();
                        timestamp = actualTimestamp;
                    }
                    shark.Update(ElapsedTime);

                    foreach (var pez in peces)
                    {
                        pez.Update(ElapsedTime);
                    }
                    foreach (var coral in corales)
                    {
                        coral.Update(ElapsedTime);
                    }
                    foreach (var metal in metales)
                    {
                        metal.Update(ElapsedTime);
                    }
                    foreach (var piedra in piedras)
                    {
                        piedra.Update(ElapsedTime);
                    }

                    fog.updateValues();
                    effect.SetValue("ColorFog", fog.Color.ToArgb());
                    effect.SetValue("CameraPos", TGCVector3.TGCVector3ToFloat4Array(Camera.Position));
                    effect.SetValue("StartFogDistance", fog.StartDistance);
                    effect.SetValue("EndFogDistance", fog.EndDistance);
                    effect.SetValue("Density", fog.Density);
                    effect.SetValue("eyePos", TGCVector3.TGCVector3ToFloat3Array(Camera.Position));
                }

                //Camara y jugador
                FPSCamara.Update(ElapsedTime);

                Player.Update(ElapsedTime, ref estaEnNave);
            }

            // esto se hace siempre
            //Lockear mouse
            Cursor.Position = mousePosition;
            PostUpdate();
        }
Example #28
0
 public override void Desactivar()
 {
     estaActivada = false;
     sonidoAntorcha.stop();
 }
 public void stopSonidoCaminar()
 {
     SonidoCaminar.stop();
 }
 public void UnLoad()
 {
     _Sound.stop();
 }