Exemple #1
0
        void PaintGrid()
        {
            Position        p          = new Position();
            SolidColorBrush brushColor = SnakeColor.GetColorBrush(SnakeColor.ColorPalette.WHITE);

            for (int y = 0; y < GameState.sideCellCount; y++)
            {
                p.Y = y;
                for (byte x = 0; x < GameState.sideCellCount; x++)
                {
                    p.X = x;
                    var cellContent = GameState.grid.GetCellAt(p).content;

                    switch (cellContent)
                    {
                    case CellContent.Empty:
                        var color = Color.FromRgb((byte)((x * 6) + (y * 5)), (byte)((x * 3) + (y * 0)), (byte)((x * 1) + (y * 3)));
                        brushColor = new SolidColorBrush(color);
                        break;

                    case CellContent.Apple:
                        brushColor = SnakeColor.GetColorBrush(SnakeColor.ColorPalette.RED);
                        break;

                    case CellContent.Spikes:
                        brushColor = SnakeColor.GetColorBrush(SnakeColor.ColorPalette.BLACK);
                        break;
                    }

                    SetCellColor(p, brushColor);
                }
            }
        }
Exemple #2
0
        private void menuItem3_Click(object sender, System.EventArgs e)
        {
            //食物颜色设置
            SnakeColor temp = new SnakeColor();

            if (temp.ShowDialog(this) == DialogResult.OK)
            {
                this.foodColor = temp.Color;
                temp.Dispose();
            }
        }
Exemple #3
0
 private void Window_ContentRendered(object sender, EventArgs e)
 {
     SetCellColor(GameState.snake.GetHeadPosition(), SnakeColor.GetColorBrush(SnakeColor.ColorPalette.GREEN));
 }