public void startSound()
 {
     if (theSound != null)
     {
         theSound.play(false);
     }
 }
Exemplo n.º 2
0
        protected void CheckJumpStatus(GameModel gameModel)
        {
            if (rigidBody.InterpolationLinearVelocity.Y < -0.88f)
            {
                falling    = true;
                onTheFloor = false;
                canJump    = false;
            }

            if (falling)
            {
                if (rigidBody.InterpolationLinearVelocity.Y > -0.05f)
                {
                    falling    = false;
                    onTheFloor = true;
                    var sound = new Tgc3dSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "afterJump.wav", this.mesh.Transform.Origin, gameModel.DirectSound.DsDevice);
                    sound.MinDistance = 50f;
                    sound.play(false);
                }
            }

            if (onTheFloor && !falling)
            {
                canJump = true;
            }
        }
Exemplo n.º 3
0
        protected override void UpdateEntity(float ElapsedTime)
        {
            time += ElapsedTime;
            // solo setear si se esta usando el efecto?
            if (time < 1.5)
            {
                // si supera 1 no tiene sentido porque ningun canal tiene mas de uno (ver el if en el efecto)
                // 1.5 es para darle un delta porque si hacemos > 1 nunca va a llegar a 1
                efectoDesaparecer.SetValue("value", time);
            }
            // me fijo si se llego al tiempo y pongo estaOculto = true;
            if (!meAtaco)
            {
                if (ArrivedGoalPos())
                {
                    SetRandomGoalPos();
                }

                if (canDealDamage)
                {
                    Attack();
                }

                Move(goalPos, speed, ElapsedTime);

                sound.Position = mesh.Position;

                sound.play(true);
            }
        }
Exemplo n.º 4
0
 public override void Dispose(Device dsDevice)
 {
     sound             = new Tgc3dSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "machinegunDestroy.wav", mesh.Transform.Origin, dsDevice);
     sound.MinDistance = 34f;
     sound.play(false);
     mesh.Dispose();
     rigidBody.Dispose();
 }
Exemplo n.º 5
0
 public void seAbrioJugador()
 {
     if (llaves.juntoTodas())
     {
         sonidoAbrir.play();
         estado         = Estado.Abierta;
         abiertaJugador = true;
     }
 }
Exemplo n.º 6
0
        public void fire(int opposite, Device dsDevice)
        {
            rigidBody.WorldTransform = Matrix.Translation(opposite * shooter.meshAxisRadius.X * 0.8f, 0.265f, -shooter.meshAxisRadius.Z - shooter.currentSpeed * 0.01f - 0.47f) * Matrix.RotationY(shooter.yawPitchRoll.Y) * Matrix.Translation(shooter.Mesh.Transform.Origin.ToBsVector);
            rigidBody.ApplyCentralImpulse(new Vector3(shooter.frontVector.X, 0, shooter.frontVector.Z) * (25 + (FastMath.Sqrt(FastMath.Abs(shooter.currentSpeed)) / 2)));

            sound             = new Tgc3dSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "machinegun.wav", shooter.Mesh.Transform.Origin, dsDevice);
            sound.MinDistance = 50f;
            sound.play(false);
        }
Exemplo n.º 7
0
 public override void Dispose(Device dsDevice)
 {
     sound.stop();
     sound             = new Tgc3dSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "explosionStrong.wav", mesh.Transform.Origin, dsDevice);
     sound.MinDistance = 43f;
     sound.play(false);
     mesh.Dispose();
     rigidBody.Dispose();
 }
Exemplo n.º 8
0
        public override void fire(Device dsDevice)
        {
            rigidBody.WorldTransform = Matrix.Translation(0, 0.5f, -shooter.meshAxisRadius.Z - shooter.currentSpeed * 0.01f - 1.8f) * Matrix.RotationY(shooter.yawPitchRoll.Y) * Matrix.Translation(shooter.Mesh.Transform.Origin.ToBsVector);
            rigidBody.ApplyCentralImpulse(new Vector3(shooter.frontVector.X, 0, shooter.frontVector.Z) * (30 + (FastMath.Sqrt(FastMath.Abs(shooter.currentSpeed)) / 2)));

            sound             = new Tgc3dSound(Game.Default.MediaDirectory + Game.Default.FXDirectory + "power.wav", shooter.Mesh.Transform.Origin, dsDevice);
            sound.MinDistance = 48f;
            sound.play(false);
        }
Exemplo n.º 9
0
        public void SuenaEncendido(Auto auto)
        {
            Tgc3dSound sonar;

            sonar = new Tgc3dSound(MediaDir + "Musica\\Encendido.wav", auto.Mayas[0].Position, SonidoDevice)
            {
                MinDistance = 80f
            };

            sonar.play();
        }
Exemplo n.º 10
0
        public void Init()
        {
            //seteamos atributos particulares de las naves
            health       = 50;
            score        = 2;
            tiempoMuerte = 5f;
            Device d3dDevice = GuiController.Instance.D3dDevice;

            MESH_SCALE     = 0.5f;
            attackDamage   = 50;
            MOVEMENT_SPEED = 225f;
            //cargamos el mesh
            //las naves no tienen skeletalMesh
            this.mesh = GameManager.Instance.ModeloNave.clone("Nave");


            SPAWN_HEIGHT = 1000f;
            giroInicial  = Matrix.RotationY(0);

            //realizamos el init() comun a todos los enemigos
            base.Init();

            mesh.Effect    = GameManager.Instance.envMap;
            mesh.Technique = "SimpleEnvironmentMapTechnique";
            mesh.Effect.SetValue("lightColor", ColorValue.FromColor(Color.White));
            mesh.Effect.SetValue("lightPosition", TgcParserUtils.vector3ToFloat4Array(new Vector3(0, 1400, 0)));
            mesh.Effect.SetValue("eyePosition", TgcParserUtils.vector3ToFloat4Array(CustomFpsCamera.Instance.getPosition()));
            mesh.Effect.SetValue("lightIntensity", 0.3f);
            mesh.Effect.SetValue("lightAttenuation", 1.0f);
            mesh.Effect.SetValue("reflection", 0.65f);

            //Cargar variables de shader de Material. El Material en realidad deberia ser propio de cada mesh. Pero en este ejemplo se simplifica con uno comun para todos
            mesh.Effect.SetValue("materialEmissiveColor", ColorValue.FromColor(Color.Black));
            mesh.Effect.SetValue("materialAmbientColor", ColorValue.FromColor(Color.White));
            mesh.Effect.SetValue("materialDiffuseColor", ColorValue.FromColor(Color.White));
            mesh.Effect.SetValue("materialSpecularColor", ColorValue.FromColor(Color.White));
            mesh.Effect.SetValue("materialSpecularExp", 9);

            mesh.Effect.SetValue("texCubeMap", GameManager.Instance.cubeMap);

            //creamos las boundingbox
            //a pesar de que las naves no tienen legs ni head, le seteamos boxes "vacias" para no tener problemas con Excepciones de null
            HEADSHOT_BOUNDINGBOX = new TgcBoundingBox();
            CHEST_BOUNDINGBOX    = this.mesh.BoundingBox.clone();
            LEGS_BOUNDINGBOX     = new TgcBoundingBox();
            //carga de sonido
            SonidoMovimiento             = new Tgc3dSound(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Audio\\Robot\\ufoHum.wav", getPosicionActual());
            SonidoMovimiento.MinDistance = 130f;
            SonidoMovimiento.play(true);
        }
Exemplo n.º 11
0
 public void Dissapear(Device dsDevice)
 {
     if (IsPresent)
     {
         IsPresent = false;
         Mesh.Dispose();
         timer = respawnTime;
     }
     if (dsDevice != null)
     {
         sound             = new Tgc3dSound(SoundPath, Position, dsDevice);
         sound.MinDistance = 150f;
         sound.play(false);
     }
 }
Exemplo n.º 12
0
        public Mostro()
        {
            mesh = Map.GetMeshFromScene("Esqueleto2-TgcScene.xml");

            musica             = new Tgc3dSound(g.game.MediaDir + "tambo_tambo-la_cumbita.wav", pos, g.game.DirectSound.DsDevice);
            musica.MinDistance = 60f;

            g.game.DirectSound.Listener3d.Position = g.camera.eyePosition;

            musica.play(true);

            g.mostro = this;

            lookAt = new TGCVector3(0.5f, 0, 0.5f);
            lookin = new TGCVector3(0, 0, -1);
            mode   = -1;
        }
Exemplo n.º 13
0
 public Disparo(TGCVector3 startPosition, TGCVector3 targetPosition, TGCVector3 size, Color color, string soundPath, Microsoft.DirectX.DirectSound.Device device)
 {
     vida                 = Stopwatch.StartNew();
     ShouldDie            = false;
     modelo               = TGCBox.fromSize(size, color);
     modelo.AutoTransform = true;
     modelo.Position      = startPosition;
     MovementDirection    = TGCVector3.Normalize(targetPosition - startPosition);
     modelo.Rotation      = new TGCVector3(ObtenerRotacionX(new TGCVector3(0, 0, 1), MovementDirection), ObtenerRotacionY(new TGCVector3(0, 0, 1), MovementDirection), 0);
     this.OOB             = TgcBoundingOrientedBox.computeFromAABB(modelo.BoundingBox);
     //this.OOB.move(this.MovementDirection);
     this.OOB.rotate(modelo.Rotation);
     this.sonido        = new Tgc3dSound(soundPath, modelo.Position, device);
     sonido.Position    = modelo.Position;
     sonido.MinDistance = 50f;
     sonido.play();
     //modelo.BoundingBox.transform(TGCMatrix.RotationYawPitchRoll(modelo.Rotation.Y,modelo.Rotation.X,0));
 }
Exemplo n.º 14
0
 public override void Activar()
 {
     sonido.Position = Mesh.Position;
     sonido.play(true);
 }
Exemplo n.º 15
0
        public void recorrerCamino(Vector3 posCam)
        {
            float   elapsedTime = GuiController.Instance.ElapsedTime;
            Boolean i           = true;

            switch (estado)
            {
            case Estado.RecorriendoIda:
                sonidoPerseguir.stop();
                sonidoCaminar.play(true);
                while (caminoIda[contador] != null && i)
                {
                    if ((mesh.Position - caminoIda[contador]).LengthSq() < 1f)
                    {
                        contador++;
                        if (contador == cantidadWP)
                        {
                            contador = 0;
                            estado   = Estado.RecorriendoVuelta;
                        }
                    }
                    else
                    {
                        if (bloqueadoMov)
                        {
                            tiempoBloqueado -= 50f * elapsedTime;
                            selectedAnim     = animationList[0];
                            mesh.playAnimation(selectedAnim, true);
                            if (tiempoBloqueado < 0f)
                            {
                                tiempoBloqueado = 100f;
                                bloqueadoMov    = false;
                                selectedAnim    = animationList[1];
                                mesh.playAnimation(selectedAnim, true);
                            }
                        }
                        else
                        {
                            this.seguirA(caminoIda[contador], elapsedTime, VELOCIDAD_MOVIMIËNTO);
                        }
                        i = false;
                    }
                }


                break;

            case Estado.RecorriendoVuelta:
                sonidoPerseguir.stop();
                sonidoCaminar.play(true);
                while (caminoVuelta[contador] != null && i)
                {
                    if ((mesh.Position - caminoVuelta[contador]).LengthSq() < 1f)
                    {
                        contador++;
                        if (contador == cantidadWP)
                        {
                            contador = 0;
                            estado   = Estado.RecorriendoIda;
                        }
                    }
                    else
                    {
                        if (bloqueadoMov)
                        {
                            tiempoBloqueado -= 50f * elapsedTime;
                            selectedAnim     = animationList[0];
                            mesh.playAnimation(selectedAnim, true);
                            if (tiempoBloqueado < 0f)
                            {
                                tiempoBloqueado = 100f;
                                bloqueadoMov    = false;
                                selectedAnim    = animationList[1];
                                mesh.playAnimation(selectedAnim, true);
                            }
                        }
                        else
                        {
                            this.seguirA(caminoVuelta[contador], elapsedTime, VELOCIDAD_MOVIMIËNTO);
                        }
                        i = false;
                    }
                }


                break;

            case Estado.Parado:
                sonidoCaminar.stop();
                Vector3 direccion = caminoOriginal[1] - mesh.Position;
                direccion.Normalize();
                direccion.Y = 0;
                mesh.rotateY((float)Math.Atan2(direccion.X, direccion.Z) - mesh.Rotation.Y - Geometry.DegreeToRadian(180f));
                break;

            case Estado.Persiguiendo:
                sonidoCaminar.stop();
                sonidoPerseguir.play(true);
                selectedAnim = animationList[2];
                mesh.playAnimation(selectedAnim, true);
                seguirASlider(posCam, elapsedTime, VELOCIDAD_MOVIMIENTO_CORRER);
                dejarDePerseguir(posCam);
                break;
            }
        }
Exemplo n.º 16
0
        public void Init()
        {
            //seteamos atributos particulares del robot
            health = 100;
            score  = 1;
            Device d3dDevice = GuiController.Instance.D3dDevice;

            MESH_SCALE   = 0.5f;
            tiempoMuerte = 5f;
            attackDamage = 25;
            //cargamos el mesh
            //Despues de agregar el skeletalMesh dejamos de renderizar este mesh, pero igual lo utilizamos para calcular muchas cosas
            this.mesh = GameManager.Instance.ModeloRobot.clone("robot");

            giroInicial = Matrix.RotationY(-(float)Math.PI / 2);


            //carga de animaciones
            TgcSkeletalLoader skeletalLoader = new TgcSkeletalLoader();

            skeletalMesh = skeletalLoader.loadMeshAndAnimationsFromFile(
                GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\" + "Robot-TgcSkeletalMesh.xml",
                new string[] {
                GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\" + "Caminando-TgcSkeletalAnim.xml",
                GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\" + "Patear-TgcSkeletalAnim.xml",
                GuiController.Instance.ExamplesMediaDir + "SkeletalAnimations\\Robot\\" + "Arrojar-TgcSkeletalAnim.xml",
            });

            skeletalMesh.playAnimation("Caminando", true);
            skeletalMesh.AnimationEnds += this.onAnimationEnds;

            skeletalMesh.Effect = GameManager.Instance.skeletalEnvMap;
            //skeletalMesh.Technique = "SkeletalEnvMap";

            skeletalMesh.Effect.SetValue("lightColor", ColorValue.FromColor(Color.White));
            skeletalMesh.Effect.SetValue("lightPosition", TgcParserUtils.vector3ToFloat4Array(new Vector3(0, 1400, 0)));
            skeletalMesh.Effect.SetValue("eyePosition", TgcParserUtils.vector3ToFloat4Array(CustomFpsCamera.Instance.getPosition()));
            skeletalMesh.Effect.SetValue("lightIntensity", 0.3f);
            skeletalMesh.Effect.SetValue("lightAttenuation", 0.3f);
            skeletalMesh.Effect.SetValue("reflection", 0.65f);

            //Cargar variables de shader de Material. El Material en realidad deberia ser propio de cada mesh. Pero en este ejemplo se simplifica con uno comun para todos
            skeletalMesh.Effect.SetValue("materialEmissiveColor", ColorValue.FromColor(Color.Black));
            skeletalMesh.Effect.SetValue("materialAmbientColor", ColorValue.FromColor(Color.White));
            skeletalMesh.Effect.SetValue("materialDiffuseColor", ColorValue.FromColor(Color.White));
            skeletalMesh.Effect.SetValue("materialSpecularColor", ColorValue.FromColor(Color.White));
            skeletalMesh.Effect.SetValue("materialSpecularExp", 7);

            skeletalMesh.Effect.SetValue("texCubeMap", GameManager.Instance.cubeMap);

            skeletalMesh.setColor(Color.Peru);

            //realizamos el init() comun a todos los enemigos
            base.Init();
            //Creamos boundingBox nuevas para la cabeza, pecho y piernas del robot
            HEADSHOT_BOUNDINGBOX = this.mesh.BoundingBox.clone();
            CHEST_BOUNDINGBOX    = this.mesh.BoundingBox.clone();
            LEGS_BOUNDINGBOX     = this.mesh.BoundingBox.clone();
            Matrix escalabox     = Matrix.Scaling(new Vector3(0.43f, 0.3f, 0.43f));
            Matrix traslationbox = Matrix.Translation(new Vector3(0, 90f, 0));

            HEADSHOT_BOUNDINGBOX.transform(escalabox * traslationbox);
            posicionActualHeadshot = escalabox * traslationbox * posicionActual;
            Matrix escalabox2     = Matrix.Scaling(new Vector3(0.6f, 0.3f, 0.6f));
            Matrix traslationbox2 = Matrix.Translation(new Vector3(0, 50f, 0));

            CHEST_BOUNDINGBOX.transform(escalabox2 * traslationbox2);
            posicionActualChest = escalabox2 * traslationbox2 * posicionActual;
            Matrix escalabox3     = Matrix.Scaling(new Vector3(0.4f, 0.38f, 0.4f));
            Matrix traslationbox3 = Matrix.Translation(new Vector3(0, 0f, 0));

            LEGS_BOUNDINGBOX.transform(escalabox3 * traslationbox3);
            posicionActualLegs = escalabox3 * traslationbox3 * posicionActual;


            skeletalMesh.AutoTransformEnable = false;

            //carga de sonido
            SonidoMovimiento             = new Tgc3dSound(GuiController.Instance.AlumnoEjemplosMediaDir + "Los_Borbotones\\Audio\\Robot\\servomotor.wav", getPosicionActual());
            SonidoMovimiento.MinDistance = 70f;
            SonidoMovimiento.play(true);

            //setBaseEffect();
            skeletalMesh.computeNormals();
        }
Exemplo n.º 17
0
 public void seAbrio()
 {
     sonidoAbrir.play();
     estado = Estado.Abierta;
 }