private void Action() { if (!_isPause) { Dictionary <Vector2Int, bool> newStage = new Dictionary <Vector2Int, bool>(); foreach (Cell cell in _cells.Values) { //int numberNeighbours = cell.GetNumberNeighbours(); int numberNeighbours = GetNumberNeighbours(cell.Position); if (cell.IsAlive) { if (Rules.Kill(numberNeighbours)) { newStage.Add(cell.Position, false); } } else { if (Rules.Born(numberNeighbours)) { newStage.Add(cell.Position, true); } } } foreach (var position in newStage.Keys) { Cell cell = _cells[position]; if (newStage[position]) { cell.Born(); } else { cell.Kill(); } } } Invoke(nameof(Action), SLEEP_TIME); }