示例#1
0
        private void initialise_btn_Click(object sender, EventArgs e)
        {
            //  Display user input
            Output_initPage_textbox.AppendText("Grid size: " + thisGrid.HorizontalCells.ToString() + " " +
                thisGrid.VerticalCells.ToString() + " " + Environment.NewLine + Environment.NewLine);

            //  A robot needs these parameters to start: x coordinate, y coordinate, orientation, x origin, y origin, gridth width, grid height
            //  Tell robot 1 how big the battlefield is and give it its coordinates
            robot_1 = new Robot(Int32.Parse(robot_1_positionX_cbox.Text), Int32.Parse(robot_1_positionY_cbox.Text), robot_1_orientation_cbox.Text, origin_x, origin_y, thisGrid.HorizontalCells, thisGrid.VerticalCells);
            string R1_currentPosition = robot_1_positionX_cbox.Text + " " + robot_1_positionY_cbox.Text + " " + robot_1_orientation_cbox.Text;
            string R1_newPosition = robot_1.calculatePlannedPosition(robot1_FirstMove_textbox.Text);

            //  Display user input
            Output_initPage_textbox.AppendText("******* Robot 1 *******" + Environment.NewLine +
                "Initial Position: " + R1_currentPosition + Environment.NewLine +
                "First move: " + robot1_FirstMove_textbox.Text + Environment.NewLine +
                "New Position: " + R1_newPosition + Environment.NewLine + Environment.NewLine);

            //  Tell robot 2 how big the battlefield is and give it its coordinates
            robot_2 = new Robot(Int32.Parse(robot_2_positionX_cbox.Text), Int32.Parse(robot_2_positionY_cbox.Text), robot_2_orientation_cbox.Text, origin_x, origin_y, thisGrid.HorizontalCells, thisGrid.VerticalCells);
            string R2_currentPosition = robot_2_positionX_cbox.Text + " " + robot_2_positionY_cbox.Text + " " + robot_2_orientation_cbox.Text;
            string R2_newPosition = robot_2.calculatePlannedPosition(robot2_FirstMove_textbox.Text);

            //  Display user input
            Output_initPage_textbox.AppendText("******* Robot 2 *******" + Environment.NewLine +
                "Initial Position: " + R2_currentPosition + Environment.NewLine +
                "First move: " + robot2_FirstMove_textbox.Text + Environment.NewLine +
                "New Position: " + R2_newPosition + Environment.NewLine + Environment.NewLine);

            Output_initPage_textbox.AppendText("Press Go button to go to the Arena!" + Environment.NewLine);

            Go_btn.Enabled = true;
        }