Beispiel #1
0
        public void Execute()
        {
            var tracks = _gameBoard.GetTracks().ToList();

            string code = _trackCodec.Encode(_gameBoard.GetTracks().Select(t => t.Item3));

            Clipboard.SetText(code);
            MessageBox.Show("Your share code is:\n\n" + code + "\n\nIt has been copied to the clipboard.");
        }
Beispiel #2
0
        public override void Draw(SKCanvas canvas, RectangleF dirtyRect)
        {
            if (!_redraw)
            {
                return;
            }

            const int maxGridSize = PixelMapper.MaxGridSize;

            using var bitmap = new SKBitmap(maxGridSize, maxGridSize);

            using var tempCanvas = new SKCanvas(bitmap);
            tempCanvas.Clear(SKColor.Parse(Colors.VeryLightGray.HexCode));
            using var canvasWrapper = new SKCanvasWrapper(tempCanvas);

            foreach ((int, int, Track)track in _gameBoard.GetTracks())
            {
                (int x, int y) = _pixelMapper.CoordsToWorldPixels(track.Item1, track.Item2);
                tempCanvas.DrawRect(new SKRect(x, y, _trackParameters.CellSize + x, _trackParameters.CellSize + y), _paint);
            }

            tempCanvas.DrawRect(new SKRect(_pixelMapper.ViewPortX * -1, _pixelMapper.ViewPortY * -1, Math.Abs(_pixelMapper.ViewPortX) + _pixelMapper.ViewPortWidth, Math.Abs(_pixelMapper.ViewPortY) + _pixelMapper.ViewPortHeight), _viewPortPaint);

            canvas.DrawBitmap(bitmap, new SKRect(0, 0, maxGridSize, maxGridSize), new SKRect(0, 0, 100, 100));

            _redraw = false;
        }
Beispiel #3
0
        //public void Dispose()
        //{
        //    _paint.Dispose();
        //}

        public void Render(ICanvas canvas, int width, int height)
        {
            foreach ((int col, int row, Track track) in _gameBoard.GetTracks())
            {
                if (!track.Happy)
                {
                    continue;
                }

                (int x, int y) = _pixelMapper.CoordsToPixels(col, row);

                canvas.DrawRect(x, y, _parameters.CellSize, _parameters.CellSize, _paint);
            }
        }
        public void Render(SKCanvas canvas, int width, int height)
        {
            long now = _stopwatch.ElapsedMilliseconds;
            long timeSinceLastUpdate = now - _lastDrawTime;

            _lastDrawTime = now;

            int y = 1;

            canvas.DrawText((1000 / timeSinceLastUpdate) + " FPS", 0, (y++) * 25, _paint);

            canvas.DrawText(_gameBoard.GetTracks().Count() + " Tracks", 0, (y++) * 25, _paint);

            canvas.DrawText(_gameBoard.GetTrains().Count() + " Trains", 0, (y++) * 25, _paint);
        }
        public void Render(SKCanvas canvas, int width, int height)
        {
            foreach ((int col, int row, Track track) in _gameBoard.GetTracks())
            {
                canvas.Save();

                (int x, int y) = _pixelMapper.CoordsToPixels(col, row);

                canvas.Translate(x, y);

                canvas.ClipRect(new SKRect(0, 0, _parameters.CellSize, _parameters.CellSize), SKClipOperation.Intersect, false);

                _trackRenderer.Render(canvas, track, _parameters.CellSize);

                canvas.Restore();
            }
        }