public void PruebaQueUnProyectilSoloPuedaMoverse4Casilleros() { Tablero tablero = new Tablero(); Proyectil proyectil = new Proyectil(); tablero.AgregarEntidadEnCasillero(proyectil, 0, 0); proyectil.MoverAbajo(); proyectil.MoverAbajo(); proyectil.MoverAbajo(); proyectil.MoverAbajo(); proyectil.CuandoPaseElTiempo(0); Assert.IsTrue(proyectil.FueDestruido()); }
public void PruebaQueCuandoUnProyectilExploteDanieAUnBombitaQueEsteAlLado() { Tablero tablero = new Tablero(); Bombita bombita = new Bombita(); tablero.AgregarEntidadEnCasillero(bombita, 4, 1);// Arranca en (0,0) Proyectil bomba = new Proyectil(); tablero.AgregarEntidadEnCasillero(bomba, 0, 2); bomba.MoverAbajo(); bomba.MoverAbajo(); bomba.MoverAbajo(); bomba.MoverAbajo(); Assert.AreEqual(4, bomba.Posicion.Fila); Assert.AreEqual(2, bomba.Posicion.Columna); bomba.CuandoPaseElTiempo(0); Assert.AreEqual(2, bombita.Vidas); }
public void PruebaQueUnProyectilCuandoSeEncuentraUnPersonajeLoDania() { Tablero tablero = new Tablero(); Proyectil proyectil = new Proyectil(); Bombita bombita = new Bombita(); tablero.AgregarEntidadEnCasillero(proyectil, 0, 0); tablero.AgregarEntidadEnCasillero(bombita, 1, 0); proyectil.MoverAbajo(); proyectil.CuandoPaseElTiempo(0); Assert.AreEqual(2, bombita.Vidas); }
private void MoverProyectil(Proyectil proyectil) { if (proyectil.Duenio.Direccion == "este") { if (proyectil.posicionEnVentana.X + Game1.TexturasBombas["proyectil"].Width >= tablero.Dimension * proyectil.Posicion.textura.Width) return; Casillero casilleroSup; try { casilleroSup = tablero.ObtenerCasillero(proyectil.Posicion.Fila, proyectil.Posicion.Columna + 1); } catch (Exception) { return; } if ((casilleroSup != null) && (proyectil.posicionEnVentana.X + Game1.TexturasBombas["proyectil"].Width / 2 >= casilleroSup.posicionEnVentana.X + casilleroSup.textura.Width / 2)) { proyectil.MoverDerecha(); } proyectil.posicionEnVentana.X += proyectil.Velocidad; } if (proyectil.Duenio.Direccion == "oeste") { if (proyectil.posicionEnVentana.X <= 0) return; Casillero casilleroSup; try { casilleroSup = tablero.ObtenerCasillero(proyectil.Posicion.Fila , proyectil.Posicion.Columna -1); } catch (Exception) { return; } if ((casilleroSup != null) && (proyectil.posicionEnVentana.X + Game1.TexturasBombas["proyectil"].Width / 2 <= casilleroSup.posicionEnVentana.X + casilleroSup.textura.Width / 2)) { proyectil.MoverIzquierda(); } proyectil.posicionEnVentana.X -= proyectil.Velocidad; } if (proyectil.Duenio.Direccion == "norte") { if (proyectil.posicionEnVentana.Y <= 0) return; Casillero casilleroSup; try { casilleroSup = tablero.ObtenerCasillero(proyectil.Posicion.Fila - 1, proyectil.Posicion.Columna); } catch (Exception) { return; } if ((casilleroSup != null) && (proyectil.posicionEnVentana.Y + Game1.TexturasBombas["proyectil"].Height / 2 <= casilleroSup.posicionEnVentana.Y + casilleroSup.textura.Height / 2)) { proyectil.MoverArriba(); } proyectil.posicionEnVentana.Y -= proyectil.Velocidad; } if (proyectil.Duenio.Direccion == "sur") { if (proyectil.posicionEnVentana.Y + Game1.TexturasBombas["proyectil"].Height >= tablero.Dimension * proyectil.Posicion.textura.Height) return; Casillero casilleroSup; try { casilleroSup = tablero.ObtenerCasillero(proyectil.Posicion.Fila + 1, proyectil.Posicion.Columna); } catch (Exception) { return; } if ((casilleroSup != null) && (proyectil.posicionEnVentana.Y + Game1.TexturasBombas["proyectil"].Height / 2 >= casilleroSup.posicionEnVentana.Y + casilleroSup.textura.Height / 2)) { proyectil.MoverAbajo(); } proyectil.posicionEnVentana.Y += proyectil.Velocidad; } }