/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here try { jugador = new Jugador(); tiempoPrevio = TimeSpan.Zero; tiempoMaximo = TimeSpan.FromSeconds(0.5f); nivelJuego = new Nivel(); menu = new Menu(); menu.inicializar(GraphicsDevice.Viewport, Content); marcaNivel = new Item(Content, ""); //agregado para proveer animacion animacionJugador = new AnimacionElementos(); guardar = new BD(); } catch (Exception) { } base.Initialize(); }
public void inicializar(Viewport viewport, ContentManager contenedor, AnimacionElementos PlayerAnimation, Vector2 pPosicion, float pVelocidad, SoundEffect disparo) { try { animacion = PlayerAnimation; proyectiles = new List <Proyectil>(); posicion = pPosicion; velocidad = pVelocidad; this.contenedor = contenedor; this.viewport = viewport; this.disparo = disparo; } catch (Exception) { } }
public void inicializar(Vector2 pPosicion, float pVelocidad, Viewport viewport, int pDesplazamiento, AnimacionElementos animacion) { try { this.animacion = animacion; this.viewport = viewport; posicion = pPosicion; velocidad = pVelocidad; activo = true; this.desplazamiento = pDesplazamiento; } catch (Exception) { } }
void agregarExplosion(Vector2 posicion) { try { AnimacionElementos animacionExplosion = new AnimacionElementos(); if ((int)texturaEnemigoNivel.asteoide == (int)nivelActual) { Texture2D texturaAnimacion = contenedor.Load <Texture2D>("Imagenes/ExplosionAsteoide"); animacionExplosion.Inicialize(texturaAnimacion, posicion, 134, 134, 12, 30, Color.White, 1f, false); } else { Texture2D texturaAnimacion = contenedor.Load <Texture2D>("Imagenes/ExplosionMarciano"); animacionExplosion.Inicialize(texturaAnimacion, posicion, 60, 64, 21, 30, Color.White, 1f, false); } explosiones.Add(animacionExplosion); } catch (Exception) { } }
public void agregarEnemigo() { try { Enemigo enemigo = new Enemigo(); Texture2D texturaE; texturaE = contenedor.Load <Texture2D>(texturaEnemigo[(int)nivelActual]); animacionEnemigo = new AnimacionElementos(); if ((int)texturaEnemigoNivel.asteoide == (int)nivelActual) { animacionEnemigo.Inicialize(texturaE, Vector2.Zero, 35, 35, 8, 150, Color.White, 1f, true); } else { animacionEnemigo.Inicialize(texturaE, Vector2.Zero, 50, 45, 6, 150, Color.White, 1f, true); } int posicionAncho = generarPosicionAleatoria(nivelActual); if (nivelActual == (int)nivel.facil) { enemigo.inicializar(new Vector2(posicionAncho, 0 - animacionEnemigo.FrameHeight), velocidadEnemigo, viewport, generarDesplazamiento(posicionAncho), animacionEnemigo); enemigo.danio = 15; } else if (nivelActual == (int)nivel.medio) { enemigo.inicializar(new Vector2(posicionAncho, 0 - animacionEnemigo.FrameHeight), velocidadEnemigo, viewport, generarDesplazamiento(posicionAncho), true, animacionEnemigo); enemigo.danio = 10; } else { enemigo.inicializar(new Vector2(posicionAncho, 0 - animacionEnemigo.FrameHeight), velocidadEnemigo, viewport, generarDesplazamiento(posicionAncho), true, animacionEnemigo); enemigo.danio = 5; } enemigos.Add(enemigo); } catch (Exception) { } }