コード例 #1
0
        public void makeGame()
        {
            Disk disk1 = new Disk(1, lbl_Disk1.Width, lbl_Disk1.BackColor, 1);
            Disk disk2 = new Disk(2, lbl_Disk2.Width, lbl_Disk2.BackColor, 1);
            Disk disk3 = new Disk(3, lbl_Disk3.Width, lbl_Disk3.BackColor, 1);
            Disk disk4 = new Disk(4, lbl_Disk4.Width, lbl_Disk4.BackColor, 1);
            board = new Board(disk1, disk2, disk3, disk4);

            lbl_Disks[0] = lbl_Disk1;
            lbl_Disks[1] = lbl_Disk2;
            lbl_Disks[2] = lbl_Disk3;
            lbl_Disks[3] = lbl_Disk4;
        }
コード例 #2
0
        private void anyDisk_MouseDown(object sender, MouseEventArgs e)
        {
            DragDropEffects result = DragDropEffects.None;

            Label lbl_Disk = sender as Label;
            selectedDiskObj = board.FindDisk(lbl_Disk);

            if (board.CanStartMove(selectedDiskObj))
            {
                result = lbl_Disk.DoDragDrop(0, DragDropEffects.All);
            }
            else
            {
                MessageBox.Show("The movement is invalid !");
            }

            if (result != DragDropEffects.None)
            {
                ExecuteMove(lbl_Disk, selectedDiskObj.getDiskID());
            }
        }
コード例 #3
0
        //reset the game
        private void Reset()
        {
            board.ResetBoard();
            txt_Count.Text = "0";
            txt_Moves.Text = "";
            Disk disk1 = new Disk(1, lbl_Disk1.Width, lbl_Disk1.BackColor, 1);
            Disk disk2 = new Disk(2, lbl_Disk2.Width, lbl_Disk2.BackColor, 1);
            Disk disk3 = new Disk(3, lbl_Disk3.Width, lbl_Disk3.BackColor, 1);
            Disk disk4 = new Disk(4, lbl_Disk4.Width, lbl_Disk4.BackColor, 1);
            board = new Board(disk1, disk2, disk3, disk4);

            lbl_Disk1.Location = new Point(195, 190);
            lbl_Disk2.Location = new Point(182, 230);
            lbl_Disk3.Location = new Point(165, 270);
            lbl_Disk4.Location = new Point(146, 310);
        }