public override void Update() { PreUpdate(); //movimientoCaja = TGCMatrix.Identity; //// Agrego a la lista de meshes colisionables tipo caja, todas las cosas del pedazo de escenario donde estoy contra las que puedo colisionar. //caja1Mesh = new MeshTipoCaja(caja1); //meshesColisionables = new ArrayList(); //meshesColisionables.Add(caja1Mesh); //// personaje.Update(); //escenarioActual.Update(); actualizarEscenario(); escenarioActual.AplicarGravedad(); foreach (Escenario escenario in escenarios.Values) { escenario.Update(); } escenarioActual.Colisiones(); if (Input.keyPressed(Key.Q)) { BoundingBox = !BoundingBox; } if (Input.keyPressed(Key.M)) { muteado = !muteado; } if (muteado) { cancionPpal.pause(); } else { cancionPpal.resume(); } if (cancionPpal.getStatus() != TgcMp3Player.States.Playing && !muteado) { cancionPpal.closeFile(); cancionPpal.play(true); } PostUpdate(); }
/// <summary> /// Método que reproduce la música de fondo. /// Tema: Drink up me hearties yo ho /// Autor: Hans Zimmer. /// Sólo se reproduce la música si está habilitado el modifier "Música de Fondo". /// </summary> public static void ReproducirMusicaDeFondo() { if (ParametrosDeConfiguracion.Sonido.MusicaDeFondo) { switch (Mp3Player.getStatus()) { case TgcMp3Player.States.Paused: Mp3Player.resume(); break; case TgcMp3Player.States.Stopped: Mp3Player.play(true); break; case TgcMp3Player.States.Open: Mp3Player.play(true); break; } } else { if (Mp3Player.getStatus() == TgcMp3Player.States.Playing) { Mp3Player.pause(); } } }
public void logicaPersecucion() { if (!colisionoMonstruoEnPersecucion) { direccionDePersecucion = this.personaje.Position - this.monstruo.Position; direccionDePersecucion = new Vector3(direccionDePersecucion.X, 0f, direccionDePersecucion.Z); direccionDePersecucion.Normalize(); } var realMovement = colisionadorMonstruo.moveCharacter(boundMonstruo, direccionDePersecucion * ElapsedTime * velocidadMonstruo, objetosColisionables); monstruo.move(realMovement); cargarSonido("grito.wav"); sound.play(); mp3Player.pause(); monstruo.playAnimation("Run", true); float angulo = (float)Math.Atan2(-direccionDePersecucion.X, direccionDePersecucion.Z); monstruo.rotateY(anguloAnterior - angulo); anguloAnterior = angulo; if (realMovement == new Vector3(0, 0, 0)) { colisionoMonstruoEnPersecucion = true; float unAngulo = (float)Math.PI / 2; direccionDePersecucion = new Vector3((float)Math.Cos(unAngulo + monstruo.Rotation.Y), 0, (float)Math.Sin(unAngulo + monstruo.Rotation.Y)); direccionDePersecucion.Normalize(); } else { colisionoMonstruoEnPersecucion = false; } efectoAlarma(true); }
public override void render(float elapsedTime) { Device d3dDevice = GuiController.Instance.D3dDevice; //Ver si cambio el MP3 string filePath = (string)GuiController.Instance.Modifiers["MP3-File"]; loadMp3(filePath); //Contro del reproductor por teclado TgcMp3Player player = GuiController.Instance.Mp3Player; TgcMp3Player.States currentState = player.getStatus(); if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.Y)) { if (currentState == TgcMp3Player.States.Open) { //Reproducir MP3 player.play(true); } if (currentState == TgcMp3Player.States.Stopped) { //Parar y reproducir MP3 player.closeFile(); player.play(true); } } else if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.U)) { if (currentState == TgcMp3Player.States.Playing) { //Pausar el MP3 player.pause(); } } else if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.I)) { if (currentState == TgcMp3Player.States.Paused) { //Resumir la ejecución del MP3 player.resume(); } } else if (GuiController.Instance.D3dInput.keyPressed(Microsoft.DirectX.DirectInput.Key.O)) { if (currentState == TgcMp3Player.States.Playing) { //Parar el MP3 player.stop(); } } //Render texto currentMusicText.render(); instruccionesText.render(); }
public override void Render() { PreRender(); //Ver si cambio el MP3 var filePath = (string)Modifiers["MP3-File"]; loadMp3(filePath); //Contro del reproductor por teclado var currentState = mp3Player.getStatus(); if (Input.keyPressed(Key.Y)) { if (currentState == TgcMp3Player.States.Open) { //Reproducir MP3 mp3Player.play(true); } if (currentState == TgcMp3Player.States.Stopped) { //Parar y reproducir MP3 mp3Player.closeFile(); mp3Player.play(true); } } else if (Input.keyPressed(Key.U)) { if (currentState == TgcMp3Player.States.Playing) { //Pausar el MP3 mp3Player.pause(); } } else if (Input.keyPressed(Key.I)) { if (currentState == TgcMp3Player.States.Paused) { //Resumir la ejecución del MP3 mp3Player.resume(); } } else if (Input.keyPressed(Key.O)) { if (currentState == TgcMp3Player.States.Playing) { //Parar el MP3 mp3Player.stop(); } } //Render texto currentMusicText.render(); instruccionesText.render(); PostRender(); }
public void pausa() { //Contro del reproductor var currentState = mp3Player.getStatus(); if (currentState == TgcMp3Player.States.Playing) { //Pausar el MP3 mp3Player.pause(); } }
public override void Update() { //Ver si cambio el MP3 var filePath = mp3FileModifier.Value; loadMp3(filePath); //Contro del reproductor por teclado var currentState = mp3Player.getStatus(); if (Input.keyPressed(Key.Y)) { if (currentState == TgcMp3Player.States.Open) { //Reproducir MP3 mp3Player.play(true); } if (currentState == TgcMp3Player.States.Stopped) { //Parar y reproducir MP3 mp3Player.closeFile(); mp3Player.play(true); } } else if (Input.keyPressed(Key.U)) { if (currentState == TgcMp3Player.States.Playing) { //Pausar el MP3 mp3Player.pause(); } } else if (Input.keyPressed(Key.I)) { if (currentState == TgcMp3Player.States.Paused) { //Resumir la ejecución del MP3 mp3Player.resume(); } } else if (Input.keyPressed(Key.O)) { if (currentState == TgcMp3Player.States.Playing) { //Parar el MP3 mp3Player.stop(); } } }
public void muteUnmute() { TgcMp3Player player = GuiController.Instance.Mp3Player; TgcMp3Player.States currentState = player.getStatus(); if (currentState == TgcMp3Player.States.Playing) { //Pausar el MP3 player.pause(); return; } else if (currentState == TgcMp3Player.States.Paused) { //Resumir la ejecución del MP3 player.resume(); } }
//Ver si cambio el MP3 public void verSiCambioMP3() { if (empezado == false) { loadMp3(archivo); reproducir(); empezado = true; return; } TgcMp3Player.States currentState = player.getStatus(); if (currentState == TgcMp3Player.States.Playing) { //Pausar el MP3 player.pause(); } if (currentState == TgcMp3Player.States.Paused) { //Resumir la ejecución del MP3 player.resume(); } }
public void pauseSonidos() { mp3BackgroundPlayer.pause(); stopSonidoCaminar(); }
public override Escena Update(float ElapsedTime) { frameNumber++; tiempoRestante -= ElapsedTime; if (tiempoRestante <= 0) { sonido.closeFile(); return(CambiarEscena(new EscenaGameOver(Camera, MediaDir, ShadersDir, DrawText, TimeBetweenUpdates, Input))); } dynamicsWorld.StepSimulation(ElapsedTime, 10, TimeBetweenUpdates); foreach (var turbo in turbos) { turbo.Update(ElapsedTime); } foreach (Jugador jugador in jugadores) { jugador.Update(ElapsedTime); // Esto quedo medio feo, capaz estaria bueno trasladar esta logica a Turbo? O a Jugador?: Turbo turboEnContacto = turbos.Find(turbo => turbo.CheckCollideWith(jugador)); // Nunca vamos a tocar mas de 1 turbo en simultaneo if (turboEnContacto != null) { jugador.RecogerTurbo(turboEnContacto); } } if (!animacionGol.Activo) { if (jugadorActivo.Acelerando /* && sonido.getStatus() == TgcMp3Player.States.Paused*/) { sonido.resume(); } else { sonido.pause(); } } pasto.Update(ElapsedTime); camara.Update(); pelota.Update(ElapsedTime); jugadorActivo.HandleInput(Input); if (PantallaDividida) { jugadorDos.HandleInput(Input); } if (Input.keyDown(Key.Escape)) { sonido.closeFile(); return(CambiarEscena(new EscenaMenu(Camera, MediaDir, ShadersDir, DrawText, TimeBetweenUpdates, Input))); } ui.TextoTurbo = jugadorActivo.Turbo.ToString(); ui.ColorTextoTurbo = Color.FromArgb(255, 255 - (int)(jugadorActivo.Turbo * 2.55), 255 - (int)(Math.Min(jugadorActivo.Turbo, 50) * 4.55)); if (PantallaDividida) { ui.TextoTurboDos = jugadorDos.Turbo.ToString(); ui.ColorTextoTurboDos = Color.FromArgb(255, 255 - (int)(jugadorDos.Turbo * 2.55), 255 - (int)(Math.Min(jugadorDos.Turbo, 50) * 4.55)); } ui.TextoGolAzul = golequipo1.ToString(); ui.TextoGolRojo = golequipo2.ToString(); ui.TextoReloj = String.Format("{0:0}:{1:00}", Math.Floor(tiempoRestante / 60), tiempoRestante % 60); if (animacionGol.Activo) { pelota.Cuerpo.ActivationState = ActivationState.IslandSleeping; animacionGol.Update(ElapsedTime); if (!animacionGol.Activo) { Reubicar(); } } else { if (arcos[0].CheckCollideWith(pelota)) { golequipo1++; sonido.closeFile(); sonido.FileName = MediaDir + "Music\\Gol.mp3"; sonido.play(false); animacionGol.AnimarGol(jugadores, Color.Blue); } if (arcos[1].CheckCollideWith(pelota)) { golequipo2++; sonido.closeFile(); sonido.FileName = MediaDir + "Music\\Gol.mp3"; sonido.play(false); animacionGol.AnimarGol(jugadores, Color.Red); } } return(this); }