public override void Update() { KeyboardState key = Keyboard.GetState(); if (key.IsKeyDown(Keys.Space) && anteriorTecla > 8) { nombre += " "; anteriorTecla = 0; } else if (key.IsKeyDown(Keys.Back) && anteriorTecla > 6 && nombre.Length > 0) { nombre = nombre.Substring(0, nombre.Length - 1); anteriorTecla = 0; } else if (key.IsKeyDown(Keys.Enter) && anteriorTecla > 3) { if (PantallaPuntuaciones.ComprobarNombre(nombre)) { PantallaPuntuaciones.puntuaciones[nombre] = Protagonista.puntuacion; SobreescribirDatos(); } else { PantallaPuntuaciones.puntuaciones.Add(nombre, Protagonista.puntuacion); CargarDatos(); } PantallaManager.actualPantalla = 10; PantallaInicio.teclaTimer = 0; Protagonista.puntuacion = 0; anteriorTecla = 0; } else if (key.IsKeyDown(Keys.Escape) && anteriorTecla > 3) { PantallaManager.actualPantalla = 10; PantallaInicio.teclaTimer = 0; Protagonista.puntuacion = 0; anteriorTecla = 0; } else if (anteriorTecla > 8 && key.GetPressedKeys().Length > 0) { foreach (Keys k in key.GetPressedKeys()) { if (k.GetHashCode() >= 65 && k.GetHashCode() <= 90) { nombre += k.ToString(); anteriorTecla = 0; } } } else { anteriorTecla++; } }
public PantallaManager() { controlMusica = 0; pantallas = new Pantalla[12]; pantallas[0] = new Nivel1(); pantallas[1] = new Nivel2(); pantallas[2] = new Nivel3(); pantallas[3] = new Nivel4(); pantallas[4] = new Nivel5(); pantallas[5] = new Nivel6(); pantallas[6] = new Nivel7(); pantallas[7] = new PantallaPuntuaciones(); pantallas[8] = new PantallaSalir(); pantallas[9] = new PantallaFin(); pantallas[10] = new PantallaInicio(); pantallas[11] = new PantallaGuardado(); }