public Game(IGameBoard gameBoard, IEnumerable <ILayerRenderer> boardRenderers, IPixelMapper pixelMapper, IImageFactory imageFactory, ITimer renderLoop, IEnumerable <IScreen> screens, IImageCache imageCache) { _gameBoard = gameBoard; _boardRenderers = boardRenderers; _pixelMapper = pixelMapper; _imageFactory = imageFactory; _renderLoop = renderLoop; _screens = screens; _imageCache = imageCache; foreach (IScreen screen in _screens) { screen.Changed += (s, e) => _imageCache.SetDirty(screen); } foreach (ICachableLayerRenderer renderer in _boardRenderers.OfType <ICachableLayerRenderer>()) { renderer.Changed += (s, e) => _imageCache.SetDirty(renderer); } _renderLayerDrawTimes = _boardRenderers.ToDictionary(x => x, x => InstrumentationBag.Add <ElapsedMillisecondsTimedStat>(GetLayerDiagnosticsName(x))); _screenDrawTimes = _screens.ToDictionary(x => x, x => InstrumentationBag.Add <ElapsedMillisecondsTimedStat>(GetLayerDiagnosticsName(x))); _renderCacheDrawTimes = _boardRenderers.Where(x => x is ICachableLayerRenderer).ToDictionary(x => x, x => InstrumentationBag.Add <ElapsedMillisecondsTimedStat>("Draw-Cache-" + x.Name.Replace(" ", ""))); _pixelMapper.ViewPortChanged += (s, e) => _imageCache.SetDirtyAll(_boardRenderers); _renderLoop.Elapsed += (s, e) => DrawFrame(); _renderLoop.Interval = RenderInterval; _renderLoop.Start(); _gameBoard.Initialize(_pixelMapper.Columns, _pixelMapper.Rows); }