Exemplo n.º 1
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            string c = "";
            bool   k = false;

            if (edit_menu_cell.king)
            {
                switch (edit_menu_cell.color)
                {
                case "white": { c = "black"; k = true; } break;

                case "black": { c = "empty"; k = true; } break;

                case "empty": { c = "white"; k = false; } break;
                }
            }
            else
            {
                switch (edit_menu_cell.color)
                {
                case "white": { c = "black"; k = false; } break;

                case "black": { c = "empty"; k = false; } break;

                case "empty": { c = "white"; k = true; } break;
                }
            }
            edit_menu_cell.king  = k;
            edit_menu_cell.color = c;
            edit_menu_cell.fill_image();
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            button1_Click(button1, new EventArgs());
            Cell temp = get_cell_for_coordinates(main, 2, 2);

            temp.color = "black";
            if (mode == 0)
            {
                temp.king = true;
            }
            temp.fill_image();

            temp       = get_cell_for_coordinates(main, 3, 3);
            temp.color = "white";
            temp.king  = true;
            temp.fill_image();

            temp       = get_cell_for_coordinates(main, 3, 5);
            temp.color = "white";
            temp.king  = true;
            temp.fill_image();

            temp       = get_cell_for_coordinates(main, 5, 5);
            temp.color = "white";
            temp.king  = true;
            temp.fill_image();

            temp       = get_cell_for_coordinates(main, 5, 7);
            temp.color = "white";
            temp.king  = true;
            temp.fill_image();

            temp       = get_cell_for_coordinates(main, 3, 7);
            temp.color = "white";
            temp.king  = true;
            temp.fill_image();

            английскиеToolStripMenuItem.Checked = false;
            русскиеToolStripMenuItem.Checked    = true;

            mode++;
            if (mode > 1)
            {
                mode = 0;
            }
        }
Exemplo n.º 3
0
        public void add_checker(int _j, int _i, string _color)
        {
            //проверка на добавление дубля
            if (get_cell_for_coordinates(main, _j, _i) != null)
            {
                return;
            }
            //создаем временные объекты в пустоте, издеваемся над ними
            Cell       c = new Cell(_j, _i, _color);
            PictureBox p = new PictureBox();
            double     k = panel1.Height / 1800d;

            p.Size      = new Size((int)(200 * k), (int)(200 * k));
            p.SizeMode  = PictureBoxSizeMode.Zoom;
            p.BackColor = Color.Transparent;
            p.Click    += new EventHandler(pictureBox_Click);
            p.Tag       = main.field_state.Count;

            //добавляем в массив и отрисовываем
            panel1.Controls.Add(p);
            c.picture = p;
            c.fill_image();
            main.field_state.Add(c);
        }
Exemplo n.º 4
0
        private void pictureBox_Click(object sender, EventArgs e)
        {
            Cell temp = main.field_state[(int)(sender as PictureBox).Tag] as Cell;

            //режим редактирования
            if (edit_mode)
            {
                if (temp.color != edit_menu_cell.color || temp.king != edit_menu_cell.king)
                {
                    temp.color = edit_menu_cell.color;
                    temp.king  = edit_menu_cell.king;
                    temp.fill_image();
                }
            }
            else
            //игровой режим
            {
                //клик на шашке
                if (temp.color != "empty")
                {
                    bool mark = temp.marked;
                    //чистим все отметки
                    clear_all_marks();

                    //в зависимости от отметки, ставим\убираем ее
                    temp.set_mark(!mark);
                    if (temp.marked)
                    {
                        last_marked = temp;
                        //рисуем доступные ходы
                        mas = new ChainsMas();
                        calc_all_cell_moves(mas, temp, 0, main);
                        paint_all_moves(mas);
                    }
                    else
                    {
                        last_marked = null;
                    }
                }
                else
                //клик по пустому месту
                {
                    //совершение хода
                    if (last_marked != null)
                    {
                        System.Collections.ArrayList chains = mas.get_all_high_important_chains();
                        if (chains.Count > 0)
                        {
                            //поиск move
                            foreach (Chain item in chains)
                            {
                                foreach (Move item_move in item.chain_s_moves)
                                {
                                    //совершение move
                                    if (item_move.cell_to == temp)
                                    {
                                        if (!item_move.jump)
                                        {
                                            //простой ход
                                            clear_all_marks();
                                            item_move.cell_to.color = (item.chain_s_moves[0] as Move).cell_from.color;
                                            item_move.cell_to.king  = item_move.cell_from.king;
                                            item_move.cell_to.fill_image();
                                            (item.chain_s_moves[0] as Move).cell_from.color = "empty";
                                            (item.chain_s_moves[0] as Move).cell_from.king  = false;
                                            (item.chain_s_moves[0] as Move).cell_from.fill_image();
                                        }
                                        else
                                        {
                                            //прыжок со съеданием
                                            string first_color = (item.chain_s_moves[0] as Move).cell_from.color;
                                            foreach (Move internal_move in item.chain_s_moves)
                                            {
                                                clear_all_marks();

                                                internal_move.cell_to.color = first_color;
                                                internal_move.cell_to.king  = internal_move.cell_from.king;
                                                internal_move.cell_to.set_mark(false);
                                                internal_move.cell_from.color = "empty";
                                                internal_move.cell_from.king  = false;
                                                internal_move.cell_from.set_mark(false);

                                                foreach (Cell c in internal_move.eated_cells)
                                                {
                                                    c.color = "empty";
                                                    c.king  = false;
                                                    c.fill_image();
                                                }
                                                //рекурсивно, вызываем этот же метод, если ходы еще есть
                                                mas = new ChainsMas();
                                                calc_all_cell_moves(mas, temp, 0, main);
                                                System.Collections.ArrayList imp_chains = mas.get_all_high_important_chains();
                                                if (mas != null && imp_chains.Count > 0)
                                                {
                                                    internal_move.cell_to.set_mark(true);
                                                    pictureBox_Click(sender, new EventArgs());
                                                }
                                                if (internal_move == item_move)
                                                {
                                                    break;
                                                }
                                            }
                                        }
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }