コード例 #1
0
        /// <summary>
        /// Renders the game on the specified graphics instance
        /// </summary>
        /// <param name="graphicsInstance">Graphics instance to draw on</param>
        public void RenderGame(Graphics graphicsInstance)
        {
            if (graphicsInstance == null)
            {
                throw new ArgumentNullException();
            }

            GameCanvas.Clear();

            for (var row = 0; row < Game.Map.Cells.GetLength(0); row++)
            {
                for (var column = 0; column < Game.Map.Cells.GetLength(1); column++)
                {
                    var image = CellAppearance.GetCellImage(Game.Map.Cells[row, column]);
                    GameCanvas.Draw(image, new Coordinate {
                        Row = row, Column = column
                    });
                }
            }

            if (SelectedCell.HasValue)
            {
                GameCanvas.MarkCell(SelectedCell.Value);
            }

            GameCanvas.Render(graphicsInstance);
        }
コード例 #2
0
        /// <summary>
        /// Renders the label on the specified graphics instance
        /// </summary>
        /// <param name="graphicsInstance">Graphics instance to draw on</param>
        public void RenderLabel(Graphics graphicsInstance)
        {
            if (graphicsInstance == null)
            {
                throw new ArgumentNullException();
            }

            LabelCanvas.Clear();

            var indexesOfColumnsWithCards = Enumerable.Range(0, Game.Map.Size).Where(i => i % 2 == 0).ToArray();

            foreach (var index in indexesOfColumnsWithCards)
            {
                var image = CellAppearance.GetCellImage(Game.GoalCards[index / 2]);
                LabelCanvas.Draw(image, new Coordinate {
                    Row = 0, Column = index
                });
            }

            LabelCanvas.Render(graphicsInstance);
        }