Exemplo n.º 1
1
        protected override void OnResize(EventArgs e)
        {
            if (panels.GetLength(0) < _rows || panels.GetLength(1) < _cols)
            {
                panels = new Panel[_rows, _cols];
                
            }
            

            for (int i = 0; i < _rows; i++)
                for (int j = 0; j < _cols; j++)
                {
                    if (panels[i,j] == null)
                        panels[i, j] = new Panel();

                    Rectangle rect = GetRect(i, j);
                    panels[i, j].Width = rect.Width;
                    panels[i, j].Height = rect.Width;
                    panels[i, j].Top = rect.Top;
                    panels[i, j].Left = rect.Left;

                }
            base.OnResize(e);

        }
Exemplo n.º 2
0
        // init procedure of the gameboard
        //TODO: settings menu for color scheme etc., change arguments of loadBoard
        private void loadBoard(object sender, EventArgs e)
        {
            PrivateFontCollection pfc = new PrivateFontCollection();
            //pfc.AddFontFile(ChessProject.Properties.Resources.);


            var colorDark  = Color.DarkGray;
            var colorLight = Color.White;

            _chessBoardPanels = new Panel[gridSize, gridSize];

            for (var n = 0; n < gridSize; n++)
            {
                for (var m = 0; m < gridSize; m++)
                {
                    //each loop is one tile created
                    var newPanel = new Panel
                    {
                        Size     = new Size(tileSize, tileSize),
                        Location = new Point(tileSize * n, tileSize * m)
                    };
                    newPanel.BorderStyle = BorderStyle.FixedSingle;

                    //testing label - for debugging purposes uncomment label code (currently not working)

                    /*var newLabel = new Label
                     * {
                     *  //location is relative to the containing object - aka the panel
                     *  Size = new Size(10, 10),
                     *  Location = new Point(0, 0)
                     * };
                     * newLabel.Font = new Font(pfc.Families[0], 15, FontStyle.Regular);
                     * newLabel.Text = Convert.ToString(tileSize * n);
                     * newPanel.Controls.Add(newLabel);
                     */

                    //add to Form's Controls so that they show up
                    Controls.Add(newPanel);
                    _chessBoardPanels[n, m] = newPanel;

                    //set the method for handling the user clicking a square on the board
                    newPanel.MouseDown += new MouseEventHandler(boardClickHandler);

                    //background color of the panel
                    if (n % 2 == 0)
                    {
                        newPanel.BackColor = m % 2 != 0 ? colorDark : colorLight;
                    }
                    else
                    {
                        newPanel.BackColor = m % 2 != 0 ? colorLight : colorDark;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public Map()
        {
            x    = y = 0;
            newX = newY = 0;

            _isTransitioning = false;

            _panels = new Panel[, ] {
                {
                    new Panel(new int[, ] {
                        { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 },
                    }),
                    new Panel(new int[, ] {
                        { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 },
                    })
                },
                {
                    new Panel(new int[, ] {
                        { 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                    }),
                    new Panel(new int[, ] {
                        { 1, 1, 1, 1, 0, 0, 1, 1, 1, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
                        { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
                    })
                }
            };
        }
Exemplo n.º 4
0
        public Map()
        {
            x = y = 0;
            newX = newY = 0;

            _isTransitioning = false;

            _panels = new Panel[,] {
                {
                    new Panel(new int[,] {
                        {1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 1, 1, 1, 0, 0, 1, 1, 1, 1},
                    }),
                    new Panel(new int[,] {
                        {1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 1, 1, 1, 0, 0, 1, 1, 1, 1},
                    })
                },
                {
                    new Panel(new int[,] {
                        {1, 1, 1, 1, 0, 0, 1, 1, 1, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                    }),
                    new Panel(new int[,] {
                        {1, 1, 1, 1, 0, 0, 1, 1, 1, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
                        {1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
                    })
                }
            };
        }
Exemplo n.º 5
0
 private void Remove_board()
 {
     if (board != null)
     {
         foreach (Panel b in board)
         {
             pnl_Pixels.Controls.Remove(b);
         }
     }
     board = new Panel[0, 0];
 }
Exemplo n.º 6
0
 private void InitPanels()
 {
     map = new Panel[8, 8];
     for (int x = 0; x < 8; x++)
     {
         for (int y = 0; y < 8; y++)
         {
             map[x, y] = AddPanel(x, y);
         }
     }
 }
 public Form1()
 {
     InitializeComponent();
     board        = new Panel[12, 11];
     palleteColor = new Color[] { Color.Blue, Color.Red, Color.Green, Color.Yellow, Color.Orange };
     pallete      = new Pen[palleteColor.Length];
     for (int i = 0; i < palleteColor.Length; i++)
     {
         pallete[i] = new Pen(palleteColor[i], 4);
     }
     InitializeBoard();
 }
Exemplo n.º 8
0
        private void FunLifeForm_Load(object sender, EventArgs e)
        {
            _gridSize         = 15;
            _panelSize        = 15;
            gridSizeBox.Text  = @"15";
            panelSizeBox.Text = @"15";

            _thisGeneration = new Panel[_gridSize, _gridSize];
            _nextGeneration = new Panel[_gridSize, _gridSize];

            SetUpBoard(_thisGeneration);
        }
Exemplo n.º 9
0
        public void getValueTest()
        {
            BoardGen board = new BoardGen();

            Panel[,] gen = board.GenerateBoard();
            Piece TestPiece = new Bishop("WBishop", gen[3, 4], true);

            if (TestPiece.getValue(board) != 31)
            {
                Assert.Fail();
            }
        }
Exemplo n.º 10
0
        protected void IniciarPartida_Click(object sender, EventArgs e)
        {
            try
            {
                filas    = Int32.Parse(Filas.Text.ToString());
                columnas = Int32.Parse(Columnas.Text.ToString());

                if ((filas <= 20) & (columnas <= 20) & (filas >= 6) & (columnas >= 6) & (colores1 > 0) & (colores2 > 0) & (filas % 2 == 0) & (columnas % 2 == 0))
                {
                    Tablerox             = new int[filas, columnas];
                    TableroCambiarColorx = new int[filas, columnas];
                    TableroBotonesx      = new Button[filas, columnas];
                    TableroPanelesx      = new Panel[filas, columnas];

                    for (int x = 0; x < filas; x++)
                    {
                        for (int y = 0; y < columnas; y++)
                        {
                            Tablerox[x, y]             = 0;
                            TableroCambiarColorx[x, y] = 1;
                        }
                    }

                    if (!aperturaper)
                    {
                        int mitadx = columnas / 2;
                        int mitady = filas / 2;

                        Tablerox[mitadx, mitady]         = 2;
                        Tablerox[mitadx + 1, mitady]     = 1;
                        Tablerox[mitadx, mitady + 1]     = 1;
                        Tablerox[mitadx + 1, mitady + 1] = 2;
                    }

                    Othello_Xtreme.Tablero             = Tablerox;
                    Othello_Xtreme.TableroBottones     = TableroBotonesx;
                    Othello_Xtreme.TableroCambiarColor = TableroCambiarColorx;
                    Othello_Xtreme.TableroPaneles      = TableroPanelesx;


                    Othello_Xtreme.aperturaper = aperturaper;
                    Othello_Xtreme.rInverso    = rInverso;
                    Othello_Xtreme.columnas    = columnas;
                    Othello_Xtreme.filas       = filas;
                    Othello_Xtreme.ColoresJ1   = ColoresJ1;
                    Othello_Xtreme.ColoresJ2   = ColoresJ2;


                    Response.Redirect("OthelloXtreme.aspx");
                }
            }
            catch (FormatException) { }
        }
Exemplo n.º 11
0
 public void TestPiecesLocation()
 {
     //This ensures that pieces are in the
     //correct relative positions
     Panel[,] board = gen.GenerateBoard();
     foreach (Piece p in gen.getPieces())
     {
         if (p.getType().Contains("Pawn") &&
             (p.getPanel().Location.Y != 40) &&
             (p.getPanel().Location.Y != 240))
         {
             Assert.Fail();
         }
         if (p.getType().Contains("Rook") &&
             (p.getPanel().Location.Y != 0) &&
             (p.getPanel().Location.Y != 280) &&
             (p.getPanel().Location.X != 0) &&
             (p.getPanel().Location.X != 280))
         {
             Assert.Fail();
         }
         if (p.getType().Contains("Knight") &&
             (p.getPanel().Location.Y != 0) &&
             (p.getPanel().Location.Y != 280) &&
             (p.getPanel().Location.X != 40) &&
             (p.getPanel().Location.X != 240))
         {
             Assert.Fail();
         }
         if (p.getType().Contains("Bishop") &&
             (p.getPanel().Location.Y != 0) &&
             (p.getPanel().Location.Y != 280) &&
             (p.getPanel().Location.X != 80) &&
             (p.getPanel().Location.X != 200))
         {
             Assert.Fail();
         }
         if (p.getType().Contains("Queen") &&
             (p.getPanel().Location.Y != 0) &&
             (p.getPanel().Location.Y != 280) &&
             (p.getPanel().Location.X != 120))
         {
             Assert.Fail();
         }
         if (p.getType().Contains("King") &&
             (p.getPanel().Location.Y != 0) &&
             (p.getPanel().Location.Y != 280) &&
             (p.getPanel().Location.X != 160))
         {
             Assert.Fail();
         }
     }
 }
Exemplo n.º 12
0
        private void draw_around(int x, int y, Panel[,] grid, int [,] lab, int size, bool first)
        {
            if (first)
            {
                int cell_size = 20;
                int lock_y    = 13;
                for (int i = 0; i <= size - 1; i++)
                {
                    int lock_x = 103;

                    for (int j = 0; j <= size - 1; j++)
                    {
                        grid[i, j]          = new Panel();
                        grid[i, j].Location = new Point(lock_x, lock_y);
                        grid[i, j].Width    = cell_size;
                        grid[i, j].Height   = cell_size;
                        this.Controls.Add(grid[i, j]);
                        //Draw(lab[i, j], grid[i, j]);

                        lock_x += cell_size + 1;
                    }
                    lock_y += cell_size + 1;
                }
            }
            int add_i = -size / 2;
            int add_j;

            for (int i = 0; i <= size - 1; i++)
            {
                add_j = -size / 2;
                for (int j = 0; j <= size - 1; j++)
                {
                    if (x + add_j >= 0 && x + add_j <= lab_size - 1 && y + add_i >= 0 && y + add_i <= lab_size - 1)
                    {
                        if (i != size / 2 || j != size / 2)
                        {
                            Draw(lab[y + add_i, x + add_j], grid[i, j]);
                        }
                        else
                        {
                            Draw(3, grid[i, j]);
                        }
                    }
                    else
                    {
                        Draw(0, grid[i, j]);
                    }
                    add_j++;
                }
                add_i++;
            }
        }
Exemplo n.º 13
0
        public Form1()
        {
            InitializeComponent();

            bRow = 6;
            bCol = 6;
            bW   = 50;
            bH   = 50;
            bGap = 5;

            fW = bGap + ((bW + bGap) * bRow);
            fH = bGap + ((bH + bGap) * (bCol + 2));
            fX = 10;
            fY = 10;

            AP           = new Panel();
            AP.BackColor = Color.White;
            AP.Size      = new Size(fW, fH);
            AP.Location  = new Point(10, 10);
            this.Controls.Add(AP);

            SP = new Panel[bRow];
            for (int i = 0; i < bRow; i++)
            {
                SP[i]           = new Panel();
                SP[i].BackColor = Color.Black;
                SP[i].Size      = new Size(bW, bH);
                SP[i].Location  = new Point((i * (bW + bGap)) + bGap, bGap);
                SP[i].Click    += new EventHandler(SP_Click);
                AP.Controls.Add(SP[i]);
            }

            BP = new Panel[bRow, bCol];
            for (int j = 0; j < bCol; j++)
            {
                for (int i = 0; i < bRow; i++)
                {
                    BP[i, j]           = new Panel();
                    BP[i, j].BackColor = Color.OrangeRed;
                    BP[i, j].Size      = new Size(bW, bH);
                    BP[i, j].Location  = new Point((i * (bW + bGap)) + bGap, (j * (bH + bGap)) + (bH + (2 * bGap)));
                    BP[i, j].Click    += new EventHandler(BP_Click);
                    AP.Controls.Add(BP[i, j]);
                }
            }

            EP           = new Panel();
            EP.BackColor = Color.Black;
            EP.Size      = new Size(fW - (bGap * 2), bH);
            EP.Location  = new Point(bGap, bGap + (bH + bGap) * (bCol + 1));
            AP.Controls.Add(EP);
        }
Exemplo n.º 14
0
 private void CopyPanels(Panel[,] panelTo, Panel[,] panelFrom)
 {
     for (var n = 0; n < _gridSize; n++)
     {
         for (var m = 0; m < _gridSize; m++)
         {
             var panel = panelFrom[n, m];
             panelTo[n, m] = new Panel {
                 Size = panel.Size, Location = panel.Location, BackColor = panel.BackColor, ForeColor = panel.ForeColor
             };
         }
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// Create the chessboard GUI
        /// </summary>
        private void CreateChessBoard()
        {
            //Some local variables
            var clr1 = System.Drawing.ColorTranslator.FromHtml("#63b8ff");
            var clr2 = System.Drawing.ColorTranslator.FromHtml("#c6e2ff");

            //The size of the form
            this.Size = new Size(1000, 1000);

            // Initialize the "chess board"
            chessBoardPanels = new Panel[gridSize, gridSize];

            // Double for loop to handle all rows and columns
            for (var n = 1; n < gridSize; n++)     //Columns
            {
                for (var m = 1; m < gridSize; m++) //Rows
                {
                    // Create new Panel control which will be one cell in the chessboard
                    var newPanel = new Panel
                    {
                        Size     = new Size(tileSize, tileSize),
                        Location = new Point(tileSize * n + 200, tileSize * m + 100)
                    };

                    //Add the column that say 1 to 8
                    AddCol1To8(m);

                    // Add newPanel to Form's Controls so that they show up
                    Controls.Add(newPanel);

                    //Add the final row that say a to h
                    AddRowAToH(n);

                    // add to our 2d array of panels for future use
                    chessBoardPanels[n, m] = newPanel;

                    //Add border for each cell
                    chessBoardPanels[n, m].BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

                    // Change color to alternate color for the backgrounds
                    if (n % 2 == 0)
                    {
                        newPanel.BackColor = m % 2 != 0 ? clr1 : clr2;
                    }
                    else
                    {
                        newPanel.BackColor = m % 2 != 0 ? clr2 : clr1;
                    }
                }
            }
        }
Exemplo n.º 16
0
        private void initColorPanels()
        {
            colorPanels = new Panel[panelXCount, panelYCount];

            pnlContainer.Width  = panelXCount * panelWidth;
            pnlContainer.Height = panelYCount * panelHeight;

            pnlContainer.Controls.Clear();

            for (int i = 0; i < colorPanels.GetLength(0); i++)
            {
                initColorPanelRow(i);
            }
        }
Exemplo n.º 17
0
 public void TestPiecesOnBoard()
 {
     //This ensures all pieces are of a valid type
     Panel[,] board = gen.GenerateBoard();
     String[] pieces = { "BPawn",   "WPawn",   "BRook",  "WRook",  "BKnight", "WKnight",
                         "BBishop", "WBishop", "BQueen", "WQueen", "BKing",   "WKing" };
     foreach (Piece p in gen.getPieces())
     {
         if (!(pieces.Contains(p.getType())))
         {
             Assert.Fail();
         }
     }
 }
Exemplo n.º 18
0
        public Overlay(DesktopMatrix matrix)
        {
            InitializeComponent();
            _matrix = matrix;
            Messenger.Default.Register <DesktopUpdateMessage>(this, OnDesktopUpdate);
            Messenger.Default.Register <ExitMessage>(this, OnExitMessage);

            _tiles = new Panel[, ]
            {
                { Holder00, Holder01, Holder02 },
                { Holder10, Holder11, Holder12 },
                { Holder20, Holder21, Holder22 }
            };
        }
Exemplo n.º 19
0
 //Constructor
 public LevelManager(Form instance)
 {
     this.screen = instance;
     this.Width  = 45;
     this.Height = 45;
     this.RefX   = 12;
     this.RefY   = 12;
     GameState   = "playing";
     GamePoint   = 0;
     RowCount    = 14;
     ColumnCount = 6;
     boxes       = new Panel[ColumnCount, RowCount];
     mine        = new Mine();
 }
Exemplo n.º 20
0
        public frmMain()
        {
            InitializeComponent();

            pictureBoxes = new Panel[16, 28] {
                { pic000, pic010, pic020, pic030, pic040, pic050, pic060, pic070, pic080, pic090, pic0A0, pic0B0, pic0C0, pic0D0, pic0E0, pic0F0, pic100, pic110, pic120, pic130, pic140, pic150, pic160, pic170, pic180, pic190, pic1A0, pic1B0 },
                { pic001, pic011, pic021, pic031, pic041, pic051, pic061, pic071, pic081, pic091, pic0A1, pic0B1, pic0C1, pic0D1, pic0E1, pic0F1, pic101, pic111, pic121, pic131, pic141, pic151, pic161, pic171, pic181, pic191, pic1A1, pic1B1 },
                { pic002, pic012, pic022, pic032, pic042, pic052, pic062, pic072, pic082, pic092, pic0A2, pic0B2, pic0C2, pic0D2, pic0E2, pic0F2, pic102, pic112, pic122, pic132, pic142, pic152, pic162, pic172, pic182, pic192, pic1A2, pic1B2 },
                { pic003, pic013, pic023, pic033, pic043, pic053, pic063, pic073, pic083, pic093, pic0A3, pic0B3, pic0C3, pic0D3, pic0E3, pic0F3, pic103, pic113, pic123, pic133, pic143, pic153, pic163, pic173, pic183, pic193, pic1A3, pic1B3 },
                { pic004, pic014, pic024, pic034, pic044, pic054, pic064, pic074, pic084, pic094, pic0A4, pic0B4, pic0C4, pic0D4, pic0E4, pic0F4, pic104, pic114, pic124, pic134, pic144, pic154, pic164, pic174, pic184, pic194, pic1A4, pic1B4 },
                { pic005, pic015, pic025, pic035, pic045, pic055, pic065, pic075, pic085, pic095, pic0A5, pic0B5, pic0C5, pic0D5, pic0E5, pic0F5, pic105, pic115, pic125, pic135, pic145, pic155, pic165, pic175, pic185, pic195, pic1A5, pic1B5 },
                { pic006, pic016, pic026, pic036, pic046, pic056, pic066, pic076, pic086, pic096, pic0A6, pic0B6, pic0C6, pic0D6, pic0E6, pic0F6, pic106, pic116, pic126, pic136, pic146, pic156, pic166, pic176, pic186, pic196, pic1A6, pic1B6 },
                { pic007, pic017, pic027, pic037, pic047, pic057, pic067, pic077, pic087, pic097, pic0A7, pic0B7, pic0C7, pic0D7, pic0E7, pic0F7, pic107, pic117, pic127, pic137, pic147, pic157, pic167, pic177, pic187, pic197, pic1A7, pic1B7 },
                { pic008, pic018, pic028, pic038, pic048, pic058, pic068, pic078, pic088, pic098, pic0A8, pic0B8, pic0C8, pic0D8, pic0E8, pic0F8, pic108, pic118, pic128, pic138, pic148, pic158, pic168, pic178, pic188, pic198, pic1A8, pic1B8 },
                { pic009, pic019, pic029, pic039, pic049, pic059, pic069, pic079, pic089, pic099, pic0A9, pic0B9, pic0C9, pic0D9, pic0E9, pic0F9, pic109, pic119, pic129, pic139, pic149, pic159, pic169, pic179, pic189, pic199, pic1A9, pic1B9 },
                { pic00A, pic01A, pic02A, pic03A, pic04A, pic05A, pic06A, pic07A, pic08A, pic09A, pic0AA, pic0BA, pic0CA, pic0DA, pic0EA, pic0FA, pic10A, pic11A, pic12A, pic13A, pic14A, pic15A, pic16A, pic17A, pic18A, pic19A, pic1AA, pic1BA },
                { pic00B, pic01B, pic02B, pic03B, pic04B, pic05B, pic06B, pic07B, pic08B, pic09B, pic0AB, pic0BB, pic0CB, pic0DB, pic0EB, pic0FB, pic10B, pic11B, pic12B, pic13B, pic14B, pic15B, pic16B, pic17B, pic18B, pic19B, pic1AB, pic1BB },
                { pic00C, pic01C, pic02C, pic03C, pic04C, pic05C, pic06C, pic07C, pic08C, pic09C, pic0AC, pic0BC, pic0CC, pic0DC, pic0EC, pic0FC, pic10C, pic11C, pic12C, pic13C, pic14C, pic15C, pic16C, pic17C, pic18C, pic19C, pic1AC, pic1BC },
                { pic00D, pic01D, pic02D, pic03D, pic04D, pic05D, pic06D, pic07D, pic08D, pic09D, pic0AD, pic0BD, pic0CD, pic0DD, pic0ED, pic0FD, pic10D, pic11D, pic12D, pic13D, pic14D, pic15D, pic16D, pic17D, pic18D, pic19D, pic1AD, pic1BD },
                { pic00E, pic01E, pic02E, pic03E, pic04E, pic05E, pic06E, pic07E, pic08E, pic09E, pic0AE, pic0BE, pic0CE, pic0DE, pic0EE, pic0FE, pic10E, pic11E, pic12E, pic13E, pic14E, pic15E, pic16E, pic17E, pic18E, pic19E, pic1AE, pic1BE },
                { pic00F, pic01F, pic02F, pic03F, pic04F, pic05F, pic06F, pic07F, pic08F, pic09F, pic0AF, pic0BF, pic0CF, pic0DF, pic0EF, pic0FF, pic10F, pic11F, pic12F, pic13F, pic14F, pic15F, pic16F, pic17F, pic18F, pic19F, pic1AF, pic1BF }
            };

            picEnemies = new PictureBox[6] {
                picEnemy1, picEnemy2, picEnemy3, picEnemy4, picEnemy5, picEnemy6
            };
            picReentryPoints = new PictureBox[4] {
                picReentry1, picReentry2, picReentry3, picReentry4
            };
            mnuLevelElements = new ToolStripMenuItem[10] {
                mnuLevelItem_00, mnuLevelItem_01, mnuLevelItem_02, mnuLevelItem_03, mnuLevelItem_04, mnuLevelItem_05, mnuLevelItem_06, mnuLevelItem_07, mnuLevelItem_08, mnuLevelItem_09
            };
            tsElements = new ToolStripButton[11] {
                tsElement0, tsElement1, tsElement2, tsElement3, tsElement4, tsElement5, tsElement6, tsElement7, tsElement8, tsElement9, tsElement10
            };

            initControlsRecursive(pnlLevel.Controls);
            mnuElementSelect.Tag = 1;

            for (int x = 0; x < tsElements.Length; x++)
            {
                tsElements[x].Paint += tsElement_Paint;
                tsElements[x].Click += tsElement_Click;
            }

            for (int x = 0; x < picReentryPoints.Length; x++)
            {
                picReentryPoints[x].Click += picReentryPoints_Click;
            }
        }
Exemplo n.º 21
0
        private void FormLabirint_Load(object sender, EventArgs e)
        {
            int i, j;
            int ocupat;

            labirint           = new Panel[nrLinii, nrcoloane];
            dwh                = this.Width / (nrcoloane + 2);
            pictureBox1.Height = dwh;
            pictureBox1.Width  = dwh;
            pictureBox2.Height = dwh;
            pictureBox2.Width  = dwh;
            pictureBox3.Height = dwh;
            pictureBox3.Width  = dwh;
            pictureBox4.Height = dwh;
            pictureBox4.Width  = dwh;
            this.Height        = dwh * 18;
            for (i = 0; i < nrLinii; i++)
            {
                for (j = 0; j < nrcoloane; j++)
                {
                    labirint[i, j]        = new Panel();
                    labirint[i, j].Height = dwh;
                    labirint[i, j].Width  = dwh;
                    labirint[i, j].Top    = dwh * (i + 1);
                    labirint[i, j].Left   = dwh * (j + 1);
                    ocupat = rd.Next(3);
                    if (ocupat == 1)
                    {
                        labirint[i, j].BackColor = Color.Black;
                    }
                    else
                    {
                        labirint[i, j].BackColor = Color.CadetBlue;
                    }
                    this.Controls.Add(labirint[i, j]);
                }
            }

            CautLocLiber(out liniecurentadragon, out coloanacurentadragon);
            PlaseazaPersonaj(liniecurentadragon, coloanacurentadragon, pictureBox1);
            CautLocLiber(out liniecurentafoarfeca1, out coloanacurentafoarfeca1);
            PlaseazaPersonaj(liniecurentafoarfeca1, coloanacurentafoarfeca1, pictureBox2);
            CautLocLiber(out liniecurentafoarfeca2, out coloanacurentafoarfeca2);
            PlaseazaPersonaj(liniecurentafoarfeca2, coloanacurentafoarfeca2, pictureBox3);
            CautLocLiber(out liniecurentafoarfeca3, out coloanacurentafoarfeca3);
            PlaseazaPersonaj(liniecurentafoarfeca3, coloanacurentafoarfeca3, pictureBox4);

            timer1.Start();
        }
Exemplo n.º 22
0
    void Awake()
    {
        Panels = new Panel[boardColumns.Value, boardRows.Value];

        for (int row = 0; row < boardRows.Value; row++)
        {
            for (int column = 0; column < boardColumns.Value; column++)
            {
                Panels[column, row]        = Instantiate(panelPrefab, parentTransform);
                Panels[column, row].name   = string.Format(panelName.Value, column, row);
                Panels[column, row].Column = column;
                Panels[column, row].Row    = row;
            }
        }
    }
Exemplo n.º 23
0
        private void RestartBoard()
        {
            var gridSize  = Convert.ToInt32(gridSizeBox.Text);
            var panelSize = Convert.ToInt32(panelSizeBox.Text);

            if (CorrectGridSizes(gridSize, panelSize))
            {
                _gridSize  = gridSize;
                _panelSize = panelSize;
                ClearBoard();
                _thisGeneration = new Panel[_gridSize, _gridSize];
                _nextGeneration = new Panel[_gridSize, _gridSize];
                SetUpBoard(_thisGeneration);
            }
        }
Exemplo n.º 24
0
 //
 //设置框架大小
 //
 public void setWH(int w, int h, int landmineNum)
 {
     if (w < 0 || h < 0 || landmineNum < 0)
     {
         MessageBox.Show("数据出错,长宽或雷数不能小于 0 ");
     }
     Width          = w;
     Height         = h;
     nlandmines     = landmineNum;
     panel          = new Panel[Width, Height];
     label          = new Label[Width, Height];
     mark           = new int[Width, Height];
     landmines      = new bool[Width, Height];
     markCount      = landmineNum;
     oldLandmineNum = nlandmines;
 }
Exemplo n.º 25
0
 void Awake()
 {
     Panels = new Panel[Columns, Rows];
     for (int row = 0; row < Rows; row++)
     {
         for (int column = 0; column < Columns; column++)
         {
             Vector3 position = new Vector3(column, row, 0f);
             Panels[column, row]      = Instantiate(PanelPrefab, position, Quaternion.identity);
             Panels[column, row].name = "Panel [" + column + ", " + row + "]";
             Panels[column, row].transform.SetParent(PanelParent.transform, false);
             Panels[column, row].Column = column;
             Panels[column, row].Row    = row;
         }
     }
 }
        // event handler of Form Load... init things here
        private void Form_Load(object sender, EventArgs e)
        {
            const int tileSize = 40;
            const int gridSize = 8;
            var       clr1     = Color.DarkGray;
            var       clr2     = Color.White;

            // initialize the "chess board"
            _chessBoardPanels = new Panel[gridSize, gridSize];

            // double for loop to handle all rows and columns
            for (var n = 0; n < gridSize; n++)
            {
                for (var m = 0; m < gridSize; m++)
                {
                    // create new Panel control which will be one
                    // chess board tile
                    var newPanel = new Panel
                    {
                        Size     = new Size(tileSize, tileSize),
                        Location = new Point(tileSize * n + 50, tileSize * m + 50)
                    };

                    // add to Form's Controls so that they show up
                    Controls.Add(newPanel);

                    // add to our 2d array of panels for future use
                    _chessBoardPanels[n, m] = newPanel;

                    // color the backgrounds
                    if (n % 2 == 0)
                    {
                        newPanel.BackColor = m % 2 != 0 ? clr1 : clr2;
                    }
                    else
                    {
                        newPanel.BackColor = m % 2 != 0 ? clr2 : clr1;
                    }

                    //set image layout to stretch for all squares
                    _chessBoardPanels[n, m].BackgroundImageLayout = ImageLayout.Stretch;
                }
            }

            //initiate starting position for chess pieces
            startPosition();
        }
Exemplo n.º 27
0
 void InitializeGame()
 {
     seed       = Environment.TickCount;
     rnd        = new Random(seed);
     rnd        = new Random(seed + rnd.Next(0, 100));
     it_list    = new List <Item>();
     its_number = new List <int>();
     for (int i = 0; i < 4; i++)
     {
         its_number.Add(ItemReset());
     }
     p1_it_count = 0;
     //パネルセット初期化
     panel_data1 = new Panel[3, 4];
     panel_data2 = new Panel[3, 4];
     for (int i = 0; i < panel_data1.GetLength(0); i++)
     {
         for (int j = 0; j < panel_data1.GetLength(1); j++)
         {
             panel_data1[i, j] = new Panel(p_list[rnd.Next(0, 4)], rnd.Next(0, 4));
         }
     }
     for (int i = 0; i < panel_data2.GetLength(0); i++)
     {
         for (int j = 0; j < panel_data2.GetLength(1); j++)
         {
             panel_data2[i, j] = new Panel(p_list[rnd.Next(0, 4)], rnd.Next(0, 4));
         }
     }
     c_list = new List <Cursor>();
     c_list.Add(new Cursor("Player1", cs, playerImage[0], scoreImage, wk, ar, Vector2.Zero, panel_data1, new Vector2(h_margin, v_margin),
                           new Keys[6] {
         Keys.W, Keys.D, Keys.S, Keys.A, Keys.Q, Keys.E
     }, oc, 1, cr_se1, pz_se, it_se, fd_se));
     c_list.Add(new Cursor("Player2", cs, playerImage[1], scoreImage, wk, ar, Vector2.Zero, panel_data2,
                           new Vector2(window_width - h_margin - pn_size * panel_data2.GetLength(0), v_margin),
                           new Keys[6] {
         Keys.NumPad8, Keys.NumPad6, Keys.NumPad5, Keys.NumPad4, Keys.NumPad7, Keys.NumPad9
     }, sq, 3, cr_se2, pz_se, it_se, fd_se));
     start = false;
     end   = false;
     inter = 0;
     MediaPlayer.IsRepeating = true;
     clm         = false;
     co_nm       = Color.White;
     freezeCount = FREEZEWAIT;
 }
Exemplo n.º 28
0
        protected override ControlCollection CreateControlsInstance()
        {
            panels = new Panel[_rows, _cols];
            for (int i = 0; i < _rows; i++)
                for (int j = 0; j < _cols; j++)
                {
                    panels[i, j] = new Panel();
                    Rectangle rect = GetRect(i,j);
                    panels[i, j].Width = rect.Width;
                    panels[i, j].Height = rect.Width;
                    panels[i, j].Top = rect.Top;
                    panels[i, j].Left = rect.Left;

                }

            return base.CreateControlsInstance();
        }
Exemplo n.º 29
0
 //Load Mine
 public void Load(Panel[,] boxes)
 {
     for (int i = 0; i < guessCount; i++)
     {
         RowNumber    = rnd.Next(0, 6);
         ColumnNumber = rnd.Next(0, 14);
         if ((string)boxes[RowNumber, ColumnNumber].Tag == "init")
         {
             boxes[RowNumber, ColumnNumber].Tag = "mine";
             Delete(boxes);
             refX        = RowNumber;
             refY        = ColumnNumber;
             guessCount -= 1;
             break;
         }
     }
 }
Exemplo n.º 30
0
 private void DrawShip(int horizontal, int vertical, int[,] array, ref Panel[,] panel, int x, int y)
 {
     for (int i = x; i < x + horizontal; i++)
     {
         for (int j = y; j < y + vertical; j++)
         {
             if (Battleships.CheckPlace(x, y, horizontal, vertical, fieldArray1, ref place) == true)
             {
                 panel[i, j].BackgroundImage = Properties.Resources.NewGreen;
             }
             else
             {
                 panel[i, j].BackgroundImage = Properties.Resources.NewRed;
             }
         }
     }
 }
Exemplo n.º 31
0
 private void CreatePanel(int pos, Panel[,] panel)
 {
     for (int i = 0; i < 10; i++)
     {
         for (int j = 0; j < 10; j++)
         {
             Panel cell = new MyPanel();
             cell.Size                  = new Size(47, 46);
             cell.BackColor             = System.Drawing.Color.Transparent;
             cell.BackgroundImageLayout = ImageLayout.Stretch;
             cell.MouseEnter           += new EventHandler(Panel_Hover);
             cell.MouseClick           += new MouseEventHandler(Panel_Click);
             cell.Location              = new Point(pos + ((47 + 1) * i), 48 + ((46 + 1) * j));
             panel[i, j]                = cell;
             this.Controls.Add(cell);
         }
     }
 }
Exemplo n.º 32
0
        public void Startup()
        {
            Resize();

            panels = new Panel[size, size];

            field = new Field(size, minesCount);
            field.PlantMines();
            field.CountMines();

            AddPanels();

            game = true;

            now = DateTime.Now;

            timer.Start();
        }
Exemplo n.º 33
0
    void AddWord(string word, ColorType type)
    {
        enemyManager.SetEnemyWord(word, type);

        Panel[,] shufflesPanels = this.ShuffledPanels();
        int wordLength = word.Length;
        int count      = 0;

        foreach (Panel p in shufflesPanels)
        {
            if (p.char_ == null && count < wordLength)
            {
                string ch = word.Substring(count, 1);
                p.PutChar(ch, type);
                count++;
            }
        }
    }
Exemplo n.º 34
0
        /// <summary>
        /// Handles the Click event of the btnGenerateBoard control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void btnGenerateBoard_Click(object sender, EventArgs e)
        {
            int boardSize = int.Parse(txtBoardSize.Text);
            int numOfMen = int.Parse(txtNumOfMen.Text);
            int numOfWomen = int.Parse(txtNumOfWomen.Text);
            m_numOfGenerations = int.Parse(cmbNumOfGenerations.Text);

            var board = new Board(boardSize);

            BoardStrategyParameters parameters = GetStrategyParameters();
            IBoardStrategy strategy = BoardStrategyFactory.CreateStrategy(parameters);

            m_boardManager = new BoardManager(board, strategy);
            m_boardManager.PopulateBoard(numOfMen, numOfWomen);

            m_boardPanels = new Panel[boardSize, boardSize];

            InitializeBoardGraphics(m_boardManager.Board);

            btnRunAutomata.Enabled = true;
        }
Exemplo n.º 35
0
        public MainWindow()
        {
            InitializeComponent();

            gridSizeX = 500;
            gridSizeY = 500;

            for (int i = 0; i < gridSizeX; i++) caGrid.ColumnDefinitions.Add(new ColumnDefinition());
            for (int i = 0; i < gridSizeY; i++) caGrid.RowDefinitions.Add(new RowDefinition());

            cells = new Panel[gridSizeX, gridSizeY];
            for (int i = 0; i < gridSizeX; i++) {
                for (int j = 0; j < gridSizeY; j++) {
                    cells[i,j] = new DockPanel();
                    cells[i,j].Background = Brushes.White;
                    Grid.SetColumn(cells[i,j], i);
                    Grid.SetRow(cells[i,j], j);
                    caGrid.Children.Add(cells[i,j]);
                }
            }
        }
Exemplo n.º 36
0
        /// <summary>
        /// Constructor.
        /// Initializes the random component, as well as an array representing the game board
        /// Fills the game board with panels
        /// Calculates the total number of mines in the game and adds them to the game board
        /// </summary>
        /// <param name="height"></param>
        /// <param name="width"></param>
        public GameForm(int height, int width)
        {
            InitializeComponent();
            random = new Random();
            this.height = height;
            this.width = width;

            grid = new Panel[width, height];
            int totalMines = (width * height) / 6;

            this.ClientSize = new Size(width * 40, height * 40);
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Panel panel = new Panel(x, y);
                    panel.MouseDown += PanelClicked;
                    this.Controls.Add(panel);
                    grid[x, y] = panel;
                }
            }
            AssignMines(totalMines);
        }
Exemplo n.º 37
0
 public Searcher(int tileSize, int tileCount)
 {
     this.subBoard = new Panel[tileCount, tileCount];
     this.tileSize = tileSize;
     this.tileCount = tileCount;
 }
Exemplo n.º 38
0
        public SearchResult Search(Panel[,] board, Player player, int alpha, int beta, int depth)
        {
            if (depth <= 0 || isEndState(board))
            {
                return new SearchResult(null, player.Evaluate(board));
            }
            else /* wiecej do sprawdzenia*/
            {
                List<Point> possible_moves = Explore(board, player.Color);
                SearchResult best = new SearchResult(null, alpha);
                if (possible_moves.Capacity == 0)
                {
                    /* turn is lost  - chceck next player*/
                    possible_moves = Explore(board, player.OpponentColor);
                    if (possible_moves.Capacity == 0)
                    {
                        //koniec gry - psrawdzenie czy jest zwyciezca
                        switch (Math.Sign(PlayersDiffCount(board, player)))
                        {
                            case -1:
                                best = new SearchResult(null, Int16.MinValue);
                                break;
                            case 0:
                                best = new SearchResult(null, 0);
                                break;
                            case 1:
                                best = new SearchResult(null, Int16.MaxValue);
                                break;
                        }

                    }
                    else
                    { /* gra trwa nadal - brak ruchow do sprawdzenia*/
                        best = Search(board, player.Opponent, -beta, -alpha, depth - 1).negate();
                    }
                }
                else
                {//spardzenie wyniku dla kazdego ruchu na liscie

                    foreach (Point p in possible_moves)
                    {
                        //przepisanie Panel zeby nie zmieniac wartosci na oryginale
                        subBoard = new Panel[tileCount, tileCount];
                        for(int i=0;i<tileCount;i++)
                            for (int j = 0; j < tileCount; j++)
                            {
                                subBoard[i, j] = new Panel();
                                subBoard[i, j].Bounds = board[i, j].Bounds;
                                subBoard[i, j].Tag = board[i, j].Tag;

                            }

                        makeMove(ref subBoard, p, player.Color);
                        int score = Search( subBoard, player.Opponent, -beta, -alpha, depth - 1).negate().Score;
                        if (alpha < score)
                        {
                            alpha = score;
                            best = new SearchResult(p, score);
                        }
                        /**alpha beta prunning**/
                        if (alpha >= beta)
                        {
                            return best;
                        }
                    }

                }
                return best;

            }
        }
Exemplo n.º 39
0
 private void InitPics()
 {
     pics = new Panel[picsX, picsY];
     for (int i = 0; i < picsX; i++)
     {
         for (int j = 0; j < picsY; j++)
         {
             pics[i, j] = new Panel();
             pics[i, j].Width = 10;
             pics[i, j].Height = 10;
             pics[i, j].Left = i * 10;
             pics[i, j].Top = j * 10;
             if (i == picsX / 2 && j == picsY / 2)
             {
                 pics[i, j].BorderStyle = BorderStyle.FixedSingle;
             }
             pnl.Controls.Add(pics[i, j]);
         }
     }
 }
Exemplo n.º 40
0
        public SearchResult simpleSearch(Panel[,] board, Player player, int depth)
        {
            if (depth <= 0 || isEndState(board))
            {
                return new SearchResult(null, player.Evaluate(board));
            }
            else
            {
                List<Point> possible_moves = Explore(board, player.Color);
                SearchResult best = new SearchResult(null, Int16.MinValue);
                if (possible_moves.Capacity == 0)
                {
                    possible_moves = Explore(board, player.OpponentColor);
                    if (possible_moves.Capacity == 0)
                    {
                        switch (Math.Sign(PlayersDiffCount(board, player)))
                        {
                            case -1:
                                best = new SearchResult(null, Int16.MinValue);
                                break;
                            case 0:
                                best = new SearchResult(null, 0);
                                break;
                            case 1:
                                best = new SearchResult(null, Int16.MaxValue);
                                break;
                        }

                    }
                    else
                    {
                        best = simpleSearch(board, player.Opponent, depth - 1).negate();
                    }
                }
                else
                {
                    foreach (Point p in possible_moves)
                    {
                        //przepisanie Panel zeby nie zmieniac wartosci na oryginale
                    subBoard = new Panel[tileCount, tileCount];
                        for (int i = 0; i < tileCount; i++)
                            for (int j = 0; j < tileCount; j++)
                            {
                                subBoard[i, j] = new Panel();
                                subBoard[i, j].Bounds = board[i, j].Bounds;
                                subBoard[i, j].Tag = board[i, j].Tag;

                            }
                        makeMove(ref subBoard, p, player.Color);
                        int score = simpleSearch(subBoard, player.Opponent, depth - 1).negate().Score;
                        if (best.Score < score)
                        {
                            best = new SearchResult(p, score);
                        }

                    }
                }
                return best;
            }
        }
Exemplo n.º 41
0
        //Инициализация динамических компонентов для отображения
        private void InitializeDynamicComponent()
        {
			ClearTimeLineComponents();  

            photos = new Bitmap[sets.Count];
            timePanels = new Panel[sets.Count, 3];
            offsetTimeX = new float[sets.Count];
            infoPanels = new Panel[sets.Count];
            infoLabels = new Label[sets.Count, 9];
            photoPanels = new Panel[sets.Count];
            offsetTextBox = new TextBox[sets.Count];
            this.SuspendLayout();
            this.MinimumSize = new Size(585 + 10 + 30 + (int)((HEIHT_PANEL_INFO + HEIGHT_TIME_LINE * 3) * 4.0 / 3.0),
				(HEIHT_PANEL_INFO + HEIGHT_TIME_LINE * 3) * sets.Count + panel1.Location.Y + 12 + 27);
            this.MaximumSize = new Size(585 + 10 + 30 + (int)((HEIHT_PANEL_INFO + HEIGHT_TIME_LINE * 3) * 4.0 / 3.0),
				(HEIHT_PANEL_INFO + HEIGHT_TIME_LINE * 3) * sets.Count + panel1.Location.Y + 12 + 27);
            panel1.Size = new Size(585 + 10 + (int)((HEIHT_PANEL_INFO + HEIGHT_TIME_LINE * 3) * 4.0 / 3.0), 
				(HEIHT_PANEL_INFO + HEIGHT_TIME_LINE * 3) * sets.Count);
            panelWidth = panel1.Width;
            timeWidth = panel1.Width - 10 - (int)((HEIHT_PANEL_INFO + HEIGHT_TIME_LINE * 3) * 4.0 / 3.0);
            for (int i = 0; i < sets.Count; i++)
            {
                //infoPanels
                infoPanels[i] = new Panel();
                infoPanels[i].Location = new System.Drawing.Point(0, HEIGHT_TIME_LINE * i * 3 + HEIHT_PANEL_INFO * i);
                infoPanels[i].Size = new System.Drawing.Size(timeWidth, HEIHT_PANEL_INFO);
                infoPanels[i].Name = "infopan" + i;
                infoPanels[i].Parent = panel1;
                infoPanels[i].Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                for (int j = 0; j < 3; j++)
                {
                    //timePanels
                    timePanels[i, j] = new Panel();
                    timePanels[i, j].Location = new System.Drawing.Point(0,j * HEIGHT_TIME_LINE + HEIGHT_TIME_LINE * i * 3 + HEIHT_PANEL_INFO * (i + 1));
                    timePanels[i, j].Size = new System.Drawing.Size(timeWidth, HEIGHT_TIME_LINE);
                    timePanels[i, j].Name = "pan" + i;
                    timePanels[i, j].Parent = panel1;
                    timePanels[i, j].Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
                    timePanels[i, j].MouseDown += new MouseEventHandler(TimePanel_MouseDown);
                    timePanels[i, j].MouseUp += new MouseEventHandler(TimePanel_MouseUp);
                    timePanels[i, j].MouseMove += new MouseEventHandler(TimePanel_MouseMove);
                    timePanels[i, j].Paint +=new PaintEventHandler(TimePanel_Paint);
                }
                //infoLabels
                for (int j = 0; j < 9; j++)
                {
                    infoLabels[i, j] = new Label();
                    //infoLabels[i, j].AutoSize = true;
                    infoLabels[i, j].Name = "lab" + i;
                    switch (j / 2)
                    { 
                        case 0:
                            infoLabels[i, j].Location = new System.Drawing.Point(0, 20 * (j % 2) + 3);
                            infoLabels[i, j].Size = new System.Drawing.Size(128, 15);
                            break;
                        case 1:
                            infoLabels[i, j].Location = new System.Drawing.Point(127, 20 * (j % 2) + 3);
                            infoLabels[i, j].Size = new System.Drawing.Size(125, 15);
                            break;
                        case 2:
                            infoLabels[i, j].Location = new System.Drawing.Point(273, 20 * (j % 2) + 3);
                            infoLabels[i, j].Size = new System.Drawing.Size(90, 15);
                            break;
                        case 3:
                            infoLabels[i, j].Location = new System.Drawing.Point(365, 20 * (j % 2) + 3);
                            infoLabels[i, j].Size = new System.Drawing.Size(110, 15);
                            break;
                        case 4:
                            infoLabels[i, j].Location = new System.Drawing.Point(475, 20 * (j % 2) + 3);
                            infoLabels[i, j].Size = new System.Drawing.Size(112, 15);
                            break;
                    }
                    infoLabels[i, j].Parent = infoPanels[i];                    
                }
                infoLabels[i, 0].Text = "Модель фотоаппарата:";
                infoLabels[i, 1].Text = "Имя Файла:";
                infoLabels[i, 8].Text = "Смещение (секунд):";
                int k = 0;
                foreach(String s in sets.Keys)
                {
                    if (k == i)
                    {
                        infoLabels[i, 2].Text = s;
                        break;
                    }
                    k++;
                }
                infoLabels[i, 4].Text = "Текущее время:";
                infoLabels[i, 5].Text = "Время фото:";

                photoPanels[i] = new Panel();
                photoPanels[i].Location = new System.Drawing.Point(timeWidth + 10, HEIGHT_TIME_LINE * i * 3 + HEIHT_PANEL_INFO * i + 1);
                photoPanels[i].Size = new System.Drawing.Size((int)((HEIHT_PANEL_INFO + HEIGHT_TIME_LINE * 3) * 4.0 / 3.0), 
					HEIHT_PANEL_INFO + HEIGHT_TIME_LINE * 3 - 1);
                photoPanels[i].Name = "photopan" + i;
                photoPanels[i].Parent = panel1;
                photoPanels[i].BorderStyle = BorderStyle.FixedSingle;
                photoPanels[i].Anchor = AnchorStyles.Right;
                photoPanels[i].Paint +=new PaintEventHandler(PhotoPanel_Paint);

                offsetTextBox[i] = new TextBox();
                offsetTextBox[i].Location = new System.Drawing.Point(475, 18);
                offsetTextBox[i].Size = new System.Drawing.Size(110,15);
                offsetTextBox[i].Name = "offsettextbox";
                offsetTextBox[i].Parent = infoPanels[i];
                offsetTextBox[i].Text = "0";
                offsetTextBox[i].Anchor = AnchorStyles.Top | AnchorStyles.Left;
            }
            label5.Visible = true;
            trackBar1.Visible = true;
            panel1.Visible = true;
            this.ResumeLayout(false);
            this.PerformLayout();
            dateShowPhoto = DateTime.MinValue;
        }
Exemplo n.º 42
0
    void Start()
    {
        map = new Panel[Width, Height];
        var sw = scaler.referenceResolution.x;
        var sh = scaler.referenceResolution.y;
        var panelWidth = Width * displayRatio > Height ? sw / Width : sh / Height;
        for(int i = 0; i < Width; i ++){
            for(int j = 0; j < Height; j++){
                var go = CreatePanel(Vector3.zero);
                go.transform.localPosition = new Vector3(i * panelWidth - sw / 2 + panelWidth / 2, j * panelWidth - sh / 2 + panelWidth / 2, 0);
                go.GetComponent<RectTransform>().sizeDelta = Vector2.one * panelWidth;
                go.transform.SetParent(mapRoot.transform);
                var p = go.GetComponent<Panel>();
                p.moveCost = Random.Range(1, 4);
                p.SetNum(p.moveCost);
                map[i, j] = p;
            }
        }

        CreateMap();
    }
Exemplo n.º 43
0
        public Game(Game_Panel gamePanel, int boardSize, string FuncW, string FuncB, bool test_mode)
        {
            WhiteSemaphore = new Semaphore(0, 1);
            BlackSemaphore = new Semaphore(1, 1);
            whitePlayer = new Player(FuncW, "W",boardSize);
            blackPlayer = new Player(FuncB, "B",boardSize);
            whitePlayer.setOpponent(blackPlayer);
            blackPlayer.setOpponent(whitePlayer);

            this.gamePanel = gamePanel;
            this.boardSize = boardSize;
            this.test_mode = test_mode;
            ///z zasad gry: Czarny zawsze zaczyna gre!
            turn = Turn.B;

            int squareSize = boardSize / 3;
            tileSize = (gamePanel.gameBoard.Width) / boardSize;
            int gridSize = boardSize;
            int half = gridSize / 2;

            // inicjalizacja planszy
            Tiles = new Panel[gridSize, gridSize];

            for (var n = 0; n < gridSize; n++)
            {
                for (var m = 0; m < gridSize; m++)
                {
                    var newPanel = new Panel
                    {
                        Size = new Size(tileSize, tileSize),
                        Location = new Point(tileSize * n, tileSize * m)
                    };

                    Tiles[n, m] = newPanel;

                    // color the backgrounds
                    if (n % 2 == 0)
                    {
                        newPanel.BackgroundImage = (System.Drawing.Image)(Image.FromFile("GreenField.png"));
                        newPanel.Tag = "G";
                    }
                    else
                    {
                        newPanel.BackgroundImage = (System.Drawing.Image)(Image.FromFile("GreenField.png"));
                        newPanel.Tag = "G";
                    }
                    newPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
                    if ((n < squareSize && m < squareSize) || (n >= 2 * squareSize && m >= 2 * squareSize) || (n < squareSize && m >= 2 * squareSize) || (m < squareSize && n >= 2 * squareSize))
                    {
                        newPanel.BackgroundImage = (System.Drawing.Image)(Image.FromFile("EmptyField.png"));
                        newPanel.Tag = "E";
                    }

                    gamePanel.gameBoard.Controls.Add(newPanel);
                }
            }

            ///ustawienie 4 pionkow na srodku planszy
            Panel p = Tiles[half, half];
            p.BackgroundImage = (System.Drawing.Image)(Image.FromFile("WField.png"));
            p.Tag = "W";
            p = Tiles[half - 1, half - 1];
            whitePlayer.Points++;
            p.BackgroundImage = (System.Drawing.Image)(Image.FromFile("WField.png"));
            p.Tag = "W";
            whitePlayer.Points++;
            p = Tiles[half, half - 1];
            p.BackgroundImage = (System.Drawing.Image)(Image.FromFile("BlackField.png"));
            p.Tag = "B";
            blackPlayer.Points++;
            p = Tiles[half - 1, half];
            p.BackgroundImage = (System.Drawing.Image)(Image.FromFile("BlackField.png"));
            p.Tag = "B";
            blackPlayer.Points++;

            //TEST MODE - testowanie interakcji GUI z logiką gry (naprzemienne klikanie myszką pol)
            if (test_mode)
            {
                for (var n = 0; n < gridSize; n++)
                {
                    for (var m = 0; m < gridSize; m++)
                    {
                        if (Tiles[n, m].Tag.ToString() == "G")
                        {
                            this.Tiles[n, m].Click += new System.EventHandler(this.Tile_Click);
                            this.Tiles[n, m].MouseEnter += new System.EventHandler(this.Tile_Enter);
                            this.Tiles[n, m].MouseLeave += new System.EventHandler(this.Tile_Leave);
                        }
                    }
                }
            }
            //w przeciwnym przypadku naprzemienne uruchamianie graczy
            else
            {
                searcher = new Searcher(tileSize, boardSize);
                Start();
            }
        }