public Nivel(SpriteBatch spritebatch_, int index_) { lvlStatic = this; this.index = index_; Content = Juego.content; SpriteBatch = spritebatch_; LeerXML(); hud = new HUD(); setVidas(); oldState = Keyboard.GetState(); }
public Nivel(SpriteBatch spritebatch_, int index_) { asd = Juego.ContentMenus.Load<SpriteFont>("Fuentes/VidaFont"); lvlStatic = this; this.index = index_; Content = Juego.content; SpriteBatch = spritebatch_; LeerXML(); hud = new HUD(); setVidas(); oldState = Keyboard.GetState(); }
protected override void Update(GameTime gameTime) { CentroDePantalla = new Vector2(camara_.Posicion.X + GraphicsDevice.Viewport.Bounds.Width / 2, camara_.Posicion.Y + GraphicsDevice.Viewport.Bounds.Height / 2); KeyboardState teclado = Keyboard.GetState(); MouseState mouse = Mouse.GetState(); if (screenJuego == Screen.Jugando) { level1.Update(gameTime, teclado); if (KeyPress(teclado, Keys.Escape))//testeando metodo para un solo toque de tecla screenJuego = Screen.Pausa; } else if (screenJuego == Screen.Pausa) { if (KeyPress(teclado, Keys.Escape)) { screenJuego = Screen.Jugando; } } else if (screenJuego == Screen.GameOver) { if (KeyPress(teclado, Teclas.Disparar)) { screenJuego = Screen.Main; } } else if (screenJuego == Screen.Main) { MainMenu.Update(mouse); if (MainMenu.Botones[0].Click(mouse, mouseAnterior))//BOTON JUGAR { level1 = new Nivel(spriteBatch, 0); screenJuego = Screen.Jugando; } else if (MainMenu.Botones[1].Click(mouse, mouseAnterior))//BOTON CONTROLES { screenJuego = Screen.Controles; } else if (MainMenu.Botones[2].Click(mouse, mouseAnterior))//BOTON DIFICULTAD { screenJuego = Screen.Dificultad; } else if (MainMenu.Botones[3].Click(mouse, mouseAnterior))//BOTON NIVELES { System.Diagnostics.Process.Start(@"..\..\..\..\..\XNA Level editor\bin\Debug\XNA Level editor.exe"); } else if (MainMenu.Botones[4].Click(mouse, mouseAnterior))//BOTON SALIR { this.Exit(); } } else if (screenJuego == Screen.Dificultad) { DificultadMenu.Update(mouse); if (DificultadMenu.Botones[0].Click(mouse, mouseAnterior))//boton < { MenosDificultad(); } else if (DificultadMenu.Botones[2].Click(mouse, mouseAnterior))//boton > { MasDificultad(); } else if (DificultadMenu.Botones[3].Click(mouse, mouseAnterior))//boton atras { screenJuego = Screen.Main; } DificultadMenu.Botones[1].Texto_ = dificultad.ToString(); //texto boton q dice dificultad } else if (screenJuego == Screen.Controles) { ControlesMenu.Update(mouse); if (ControlesMenu.Botones[0].Click(mouse, mouseAnterior))//boton Izquierda { teclaASetear = "setIzquierda"; seteandoTecla = true; } else if (ControlesMenu.Botones[1].Click(mouse, mouseAnterior))//boton Derecha { teclaASetear = "setDerecha"; seteandoTecla = true; } else if (ControlesMenu.Botones[2].Click(mouse, mouseAnterior))//boton Saltar { teclaASetear = "setSaltar"; seteandoTecla = true; } else if (ControlesMenu.Botones[3].Click(mouse, mouseAnterior))//boton Disparar { teclaASetear = "setDisparar"; seteandoTecla = true; } else if (ControlesMenu.Botones[4].Click(mouse, mouseAnterior))//boton Atras { screenJuego = Screen.Main; } } if (seteandoTecla) setearTecla(teclado); mouseAnterior = mouse; base.Update(gameTime); tecladoAnterior = teclado; }
protected override void Update(GameTime gameTime) { CentroDePantalla = new Vector2(camara_.Posicion.X + GraphicsDevice.Viewport.Bounds.Width / 2, camara_.Posicion.Y + GraphicsDevice.Viewport.Bounds.Height / 2); KeyboardState teclado = Keyboard.GetState(); MouseState mouse = Mouse.GetState(); if (screenJuego == Screen.Jugando) { level1.Update(gameTime); if (KeyPress(teclado, Keys.Escape))//testeando metodo para un solo toque de tecla screenJuego = Screen.Pausa; } else if (screenJuego == Screen.Pausa) { if (KeyPress(teclado, Keys.Escape)) { screenJuego = Screen.Jugando; } else if (screenJuego == Screen.Creator) { levelCreator.Update(gameTime); } else if (screenJuego == Screen.Main) { MainMenu.Update(mouse); if (MainMenu.Botones[0].Click(mouse, mouseAnterior))//BOTON JUGAR { level1 = new Nivel(spriteBatch, 0); screenJuego = Screen.Jugando; } else if (MainMenu.Botones[1].Click(mouse, mouseAnterior))//BOTON CONTROLES { screenJuego = Screen.Controles; } else if (MainMenu.Botones[2].Click(mouse, mouseAnterior))//BOTON DIFICULTAD { screenJuego = Screen.Dificultad; } else if (MainMenu.Botones[3].Click(mouse, mouseAnterior))//BOTON NIVELES { levelCreator = new LevelCreator(); screenJuego = Screen.Creator; } else if (MainMenu.Botones[4].Click(mouse, mouseAnterior))//BOTON SALIR { this.Exit(); } } else if (screenJuego == Screen.Dificultad) { DificultadMenu.Update(mouse); if (DificultadMenu.Botones[0].Click(mouse, mouseAnterior))//boton < { MenosDificultad(); } else if (DificultadMenu.Botones[2].Click(mouse, mouseAnterior))//boton > { MasDificultad(); } else if (DificultadMenu.Botones[3].Click(mouse, mouseAnterior))//boton atras { screenJuego = Screen.Main; } DificultadMenu.Botones[1].Texto_ = dificultad.ToString(); //texto boton q dice dificultad } mouseAnterior = mouse; base.Update(gameTime); tecladoAnterior = teclado; } private void MenosDificultad() { if (dificultad == Dificultad.Facil) dificultad = Dificultad.Dificil; else if (dificultad == Dificultad.Medio) dificultad = Dificultad.Facil; else dificultad = Dificultad.Medio; }