public void MoverVehiculo(Orientacion orient) { if (this.Esquina == null) { throw new VehiculoNoPosicionadoInexistenteException(); } if (this.Esquina.GetEsquina(orient) == null) { throw new EsquinaInexistenteException(); } bool sePuedeMover = true; this.movimientos++; Obstaculo obstaculo = this.Esquina.GetCuadra(orient).Obstaculo; if (obstaculo != null) { obstaculo.Penalizar(this); sePuedeMover = obstaculo.PermiteMover(this); } if (this.Esquina.GetCuadra(orient).Sorpresa != null) { this.Esquina.GetCuadra(orient).Sorpresa.Accionar(this); } if (sePuedeMover) { this.Esquina = this.Esquina.GetEsquina(orient); } }
private Cuadra GeneradorDeCuadra(Random random) { Sorpresa[] sorpresasRandom = new Sorpresa[3]; sorpresasRandom[0] = new SorpresaFavorable(); sorpresasRandom[1] = new SorpresaDesfavorable(); sorpresasRandom[2] = new SorpresaCambioVehiculo(); Obstaculo[] obstaculosRandom = new Obstaculo[3]; obstaculosRandom[0] = new Pozo(); obstaculosRandom[1] = new Piquete(); obstaculosRandom[2] = new ControlPolicial(); Sorpresa sorpresaElegida = null; Obstaculo obstaculoElegido = null; if (random.Next(10) < 4) { sorpresaElegida = sorpresasRandom[random.Next(3)]; } if (random.Next(10) < 4) { obstaculoElegido = obstaculosRandom[random.Next(3)]; } return(new Cuadra(sorpresaElegida, obstaculoElegido)); }
public Cuadra(Sorpresa sorParametro, Obstaculo obsParametro) { this.sorpresa = sorParametro; this.obstaculo = obsParametro; }