Exemplo n.º 1
0
 public void ResetGameState()
 {
     Board = new Board(_gameState.Problem.Width, _gameState.Problem.Height, 30, HexOrientation.Pointy);
     GraphicsEngine = new GraphicsEngine(Board);
     PreviousSize = Size.Empty;
     Refresh();
 }
Exemplo n.º 2
0
        private void buttonTestBoard_Click(object sender, EventArgs e)
        {
            Hexagonal.HexOrientation orientation = HexOrientation.Flat;
            Console.WriteLine(Convert.ToString(comboBoxOrientation.SelectedItem));


            switch (Convert.ToString(comboBoxOrientation.SelectedItem))
            {
            case "Flat":
                orientation = Hexagonal.HexOrientation.Flat;
                break;

            case "Pointy":
                orientation = Hexagonal.HexOrientation.Pointy;
                break;

            default:
                break;
            }

            Board board = new Board(Convert.ToInt32(textBoxHexBoardWidth.Text),
                                    Convert.ToInt32(textBoxHexBoardHeight.Text),
                                    Convert.ToInt32(textBoxHexSide.Text),
                                    orientation
                                    );

            board.BoardState.BackgroundColor      = Color.Green;
            board.BoardState.GridPenWidth         = Convert.ToInt32(textBoxPenWidth.Text);
            board.BoardState.ActiveHexBorderColor = Color.Red;
            board.BoardState.ActiveHexBorderWidth = Convert.ToInt32(textBoxPenWidth.Text);

            this.board          = board;
            this.graphicsEngine = new GraphicsEngine(board, Convert.ToInt32(textBoxXOffset.Text), Convert.ToInt32(textBoxtYOffset.Text));
        }
Exemplo n.º 3
0
        private void Form_Closing(object sender, FormClosingEventArgs e)
        {
            if (graphicsEngine != null)
            {
                graphicsEngine = null;
            }

            if (board != null)
            {
                board = null;
            }
        }
Exemplo n.º 4
0
        void Make()
        {
            int boardHeight = inputSettings.YMap;
            int boardWidth  = inputSettings.XMap;

            Hexagonal.HexOrientation orientation = HexOrientation.Pointy;
            widht = Math.Sqrt(3) / 2 * Convert.ToDouble(inputMapSettings.HexSide) * 2;
            heigt = Convert.ToDouble(inputMapSettings.HexSide) * 2;

            min.Text = "min:" + Convert.ToString(inputStatistics[parameterNumber].Min);
            max.Text = "max:" + Convert.ToString(inputStatistics[parameterNumber].Max);

            int positionOfBoardX = Convert.ToInt32(inputMapSettings.XOffset) + inputSettings.XMap * Width + Width / 2;
            int positionOfBoardY = Convert.ToInt32(inputMapSettings.YOffset) + inputSettings.YMap * Height;
            //positionOfBoardX * k + Convert.ToInt32(textBoxXOffset.Text);
            //positionOfBoardY * k + Convert.ToInt32(textBoxtYOffset.Text);

            int k = 0;

            Board board = new Board(boardWidth, boardHeight,
                                    Convert.ToInt32(inputMapSettings.HexSide),
                                    orientation);

            board.BoardState.BackgroundColor      = Color.Gray;
            board.BoardState.GridPenWidth         = Convert.ToInt32(inputMapSettings.PenWidth);
            board.BoardState.ActiveHexBorderColor = Color.Red;
            board.BoardState.ActiveHexBorderWidth = Convert.ToInt32(inputMapSettings.PenWidth) * 2;

            this.board          = board;
            this.graphicsEngine = new GraphicsEngine(board, positionOfBoardX * k + Convert.ToInt32(inputMapSettings.XOffset), positionOfBoardX * k + Convert.ToInt32(inputMapSettings.YOffset));

            int     beginX, beginY;
            int     currentNeuron = 0;
            decimal colorValue    = 0.0M;

            for (int i = 0; i < inputSettings.YMap; i++)
            {
                for (int j = 0; j < inputSettings.XMap; j++)
                {
                    beginY = Convert.ToInt32(heigt / 2) + Convert.ToInt32(inputMapSettings.YOffset);
                    if (i % 2 != 0)
                    {
                        beginX = Convert.ToInt32(widht) + Convert.ToInt32(inputMapSettings.XOffset);
                    }
                    else
                    {
                        beginX = Convert.ToInt32(widht / 2) + Convert.ToInt32(inputMapSettings.XOffset);
                    }
                    Point currentCell = new Point(beginX + Convert.ToInt32(widht * j), beginY + Convert.ToInt32(heigt / 2 + heigt / 4) * i);
                    Hex   currentHex  = board.FindHexMouseClick(currentCell);
                    if (inputStatistics[parameterNumber].Max == 0)
                    {
                        colorValue = 0.0M;
                    }
                    else
                    {
                        colorValue = (neuronsValue[parameterNumber, currentNeuron]) / Convert.ToDecimal(inputStatistics[parameterNumber].Max);
                    }
                    if (colorValue >= 0 && colorValue < 1)
                    {
                        int r = Convert.ToInt32((colorValue) * 255);
                        int b = Convert.ToInt32((1 - colorValue) * 255);
                        int g = Convert.ToInt32((1 - colorValue * 0.5M) * 255);
                        currentHex.HexState.BackgroundColor = Color.FromArgb(r, g, b);
                    }
                    else if (colorValue == 1)
                    {
                        currentHex.HexState.BackgroundColor = Color.FromArgb(255, 50, 0);
                    }
                    else
                    {
                        currentHex.HexState.BackgroundColor = Color.FromArgb(255, 255, 255);
                    }
                    currentNeuron++;
                }
            }
        }
Exemplo n.º 5
0
 public GraphicsEngine(Board board, int xOffset, int yOffset)
 {
     Initialize(board, xOffset, yOffset);
 }
Exemplo n.º 6
0
 public GraphicsEngine(Board board)
 {
     Initialize(board, 0, 0);
 }
Exemplo n.º 7
0
 private void Initialize(Board board, int xOffset, int yOffset)
 {
     this.board = board;
     boardXOffset = xOffset;
     boardYOffset = yOffset;
 }