public void MultiStep(int stepCount) { StepInfo stepInfos = new StepInfo(); for (int step = 0; step < stepCount; step++) { StepInfo stepInfo = area.NextStep(); foreach (Cell cell in stepInfo.ChangedCells) { stepInfos.AddCell(cell); } } foreach (Cell cell in stepInfos.ChangedCells) { if (!rectangles.ContainsKey(cell)) { continue; } Rectangle rectangle = rectangles[cell]; if (rectangle != null) { RefreshRectangle(rectangle, cell); } } }
void TestCellWorld() { CellArea cellArea = new CellArea(70, 35); bool repeat = true; int iteration = 0; while (repeat) { cellArea.NextStep(); double energySum = cellArea.Monsters.Sum(m => m.Energy); if (energySum > 2000f) { break; } if (++iteration % 2000 == 0) { Console.SetCursorPosition(0, 0); Console.WriteLine(iteration + " => " + energySum.ToString("f2") + " "); Console.Out.Flush(); } } do { for (int i = 0; i < cellArea.Monsters.Count; i++) { cellArea.NextStep(); } PrintCellArea(cellArea); Console.WriteLine("Press spacebar to continue "); }while (Console.ReadKey(false).Key == ConsoleKey.Spacebar); }