public void Boot(List <Wall> walls, int multiplier) { if (BlockHeight % multiplier != 0) { multiplier = 1; } ArrayHeight = ArrayHeight * multiplier; ArrayWidth = ArrayWidth * multiplier; BlockHeight = BlockHeight / multiplier; BlockWidth = BlockWidth / multiplier; HeatBlocks = new HeatBlock[ArrayWidth, ArrayHeight]; for (int i = 0; i < ArrayWidth; i++) { for (int j = 0; j < ArrayHeight; j++) { HeatBlock hb = new HeatBlock(); hb.Size = new PointF(BlockWidth, BlockHeight); hb.Position = new PointF(i * hb.Size.X, j * hb.Size.Y); walls.ForEach(w => { if (w.getDistance(hb.Position) < 1) { hb.Alpha = 0.01F; } }); HeatBlocks[i, j] = hb; } } }
public void Boot(List <Wall> walls) { HeatBlocks = new HeatBlock[ArrayWidth, ArrayHeight]; for (int i = 0; i < ArrayWidth; i++) { for (int j = 0; j < ArrayHeight; j++) { HeatBlock hb = new HeatBlock(); hb.Size = new PointF(BlockWidth, BlockHeight); hb.Position = new PointF(i * hb.Size.X, j * hb.Size.Y); walls.ForEach(w => { if (w.getDistance(hb.Position) < 1) { hb.Alpha = 0.1F; } }); HeatBlocks[i, j] = hb; } } /*HeatBlocks[0, 0].FixedTemperature = true; * HeatBlocks[0, 0].Temperature = 250;*/ }
private void ClickHandler(MouseEventArgs me) { if (Simulate) { PointF clicked = new PointF(me.X, me.Y); HeatBlock selected = HeatTransferController.GetNearestBlock(clicked); selected.FixedTemperature = true; selected.Temperature = 250; CreateLogInvoke(string.Format("Fire started at X:{0}-Y:{1}", me.X, me.Y)); } }
private void pictureBox1_Click(object sender, EventArgs e) { MouseEventArgs me = (MouseEventArgs)e; PointF clicked = new PointF(me.X, me.Y); HeatBlock selected = HeatTransferController.GetNearestBlock(clicked); selected.FixedTemperature = true; selected.Temperature = 250; label1.Text = clicked.X.ToString() + "-" + clicked.Y.ToString(); //this.HumanController.Humans.First().Target = clicked; //this.HumanController.Humans.ForEach(h => h.PathFind(FloorPlanController.EmergencyDoors)); }
public void CalculateThread(int verticalDiv, int horizontalDiv) { CalculationStopper.Restart(); List <Thread> threads = new List <Thread>(); for (int vertical = 0; vertical < verticalDiv; vertical++) { for (int horizontal = 0; horizontal < horizontalDiv; horizontal++) { int vertical_copy = vertical; int horizontal_copy = horizontal; threads.Add(new Thread(() => { int _widthBase = (ArrayWidth / horizontalDiv); int _heightBase = (ArrayHeight / verticalDiv); int borderWidthLower = _widthBase * horizontal_copy; int borderWidthUpper = _widthBase * (horizontal_copy + 1); int borderHeightLower = _heightBase * vertical_copy; int borderHeightUpper = _heightBase * (vertical_copy + 1); for (int i = borderWidthLower; i < borderWidthUpper; i++) { for (int j = borderHeightLower; j < borderHeightUpper; j++) { HeatBlock hb = HeatBlocks[i, j]; float left = i == 0 ? hb.Temperature : HeatBlocks[i - 1, j].Temperature; float right = i == ArrayWidth - 1 ? hb.Temperature : HeatBlocks[i + 1, j].Temperature; float top = j == ArrayHeight - 1 ? hb.Temperature : HeatBlocks[i, j + 1].Temperature; float botton = j == 0 ? hb.Temperature : HeatBlocks[i, j - 1].Temperature; hb.CalculateColor(left, right, top, botton); } } })); } } threads.ForEach(t => t.Start()); threads.ForEach(t => t.Join()); CalculationStopper.Stop(); CalculationTime = CalculationStopper.ElapsedTicks; }
public void Calculate() { for (int i = 0; i < ArrayWidth; i++) { for (int j = 0; j < ArrayHeight; j++) { HeatBlock hb = HeatBlocks[i, j]; float left = i == 0 ? hb.Temperature : HeatBlocks[i - 1, j].Temperature; float right = i == ArrayWidth - 1 ? hb.Temperature : HeatBlocks[i + 1, j].Temperature; float top = j == ArrayHeight - 1 ? hb.Temperature : HeatBlocks[i, j + 1].Temperature; float botton = j == 0 ? hb.Temperature : HeatBlocks[i, j - 1].Temperature; hb.CalculateColor(left, right, top, botton); } } }
public HeatBlock GetNearestBlock(PointF point) { HeatBlock minimum = HeatBlocks[0, 0]; for (int i = 0; i < ArrayWidth; i++) { for (int j = 0; j < ArrayHeight; j++) { if (Vector.GetDistanceBetweenPoints(HeatBlocks[i, j].Center, point) < Vector.GetDistanceBetweenPoints(minimum.Center, point)) { minimum = HeatBlocks[i, j]; } } } return(minimum); }
public void Calculate() { CalculationStopper.Restart(); for (int i = 0; i < ArrayWidth; i++) { for (int j = 0; j < ArrayHeight; j++) { HeatBlock hb = HeatBlocks[i, j]; float left = i == 0 ? hb.Temperature : HeatBlocks[i - 1, j].Temperature; float right = i == ArrayWidth - 1 ? hb.Temperature : HeatBlocks[i + 1, j].Temperature; float top = j == ArrayHeight - 1 ? hb.Temperature : HeatBlocks[i, j + 1].Temperature; float botton = j == 0 ? hb.Temperature : HeatBlocks[i, j - 1].Temperature; hb.CalculateColor(left, right, top, botton); } } CalculationStopper.Stop(); CalculationTime = CalculationStopper.ElapsedTicks; }