private void CheckNeighborsLoopForm() { for (int i = 0; i < worldMap.row; i++) { for (int j = 0; j < worldMap.col; j++) { double outgoing = worldMap.weatherMap[i][j].Cell.OutgoingRain / 4; if (outgoing > .3) { if (i - 1 >= 0) { WeatherSim.SetIncomingRain(worldMap.weatherMap[i - 1][j].Cell, outgoing); } if (i + 1 < worldMap.row) { WeatherSim.SetIncomingRain(worldMap.weatherMap[i + 1][j].Cell, outgoing); } if (j - 1 >= 0) { WeatherSim.SetIncomingRain(worldMap.weatherMap[i][j - 1].Cell, outgoing); } if (j + 1 < worldMap.row) { WeatherSim.SetIncomingRain(worldMap.weatherMap[i][j + 1].Cell, outgoing); } } } } }
private void ContainerMap_OutgoingRainEvent1(object sender, OutgoingRainEventArgs e) { double outgoing = worldMap.weatherMap[e.Row][e.Column].Cell.OutgoingRain / 4; if (outgoing > .3) { if (e.Row - 1 >= 0) { try { WeatherSim.SetIncomingRain(worldMap.weatherMap[e.Row - 1][e.Column].Cell, outgoing); } catch (NullReferenceException ex) { worldMap.weatherMap[e.Row - 1][e.Column].Cell = new CellData(r, e.Row, e.Column); Console.WriteLine(ex.Message); } } if (e.Row + 1 < worldMap.row) { try { WeatherSim.SetIncomingRain(worldMap.weatherMap[e.Row + 1][e.Column].Cell, outgoing); } catch (NullReferenceException ex) { worldMap.weatherMap[e.Row + 1][e.Column].Cell = new CellData(r, e.Row, e.Column); Console.WriteLine(ex.Message); } } if (e.Column - 1 >= 0) { try { WeatherSim.SetIncomingRain(worldMap.weatherMap[e.Row][e.Column - 1].Cell, outgoing); } catch (NullReferenceException ex) { worldMap.weatherMap[e.Row][e.Column - 1].Cell = new CellData(r, e.Row, e.Column); Console.WriteLine(ex.Message); } } if (e.Column + 1 < worldMap.row) { try { WeatherSim.SetIncomingRain(worldMap.weatherMap[e.Row][e.Column + 1].Cell, outgoing); } catch (NullReferenceException ex) { worldMap.weatherMap[e.Row][e.Column + 1].Cell = new CellData(r, e.Row, e.Column); Console.WriteLine(ex.Message); } } } }