private void DrawBlock(RenderTarget target, RenderStates states) { if (_gameController.Game != null) { var nextShape = _gameController.Game.NextShape; if (nextShape != null) { var shapeWidth = nextShape.Blocks.Max(b => b.X) - nextShape.Blocks.Min(b => b.X) + 1; var shapeHeight = nextShape.Blocks.Max(b => b.Y) - nextShape.Blocks.Min(b => b.Y) + 1; var shape = new UIShape(nextShape, PositionX + (Width - shapeWidth * UIBlock.Size) / 2 - (nextShape.X + nextShape.Blocks.Min(b => b.X)) * UIBlock.Size, PositionY + (Height - shapeHeight * UIBlock.Size) / 2 - (nextShape.Y + nextShape.Blocks.Min(b => b.Y)) * UIBlock.Size); shape.Draw(target, states); } } }
private void DrawBlocks(RenderTarget target, RenderStates states) { if (_gameController.Game != null) { for (var i = 0; i < _gameController.Game.Width; i++) { for (var j = 0; j < _gameController.Game.Height; j++) { if (_gameController.Game.Blocks[i, j] != null) { var block = new UIBlock(_gameController.Game.Blocks[i, j], PositionX, PositionY); block.Draw(target, states); } } } if (_gameController.Game?.Shape != null) { var shape = new UIShape(_gameController.Game.Shape, PositionX, PositionY); shape.Draw(target, states); } } }