Esempio n. 1
0
        private void executeButton_Click(object sender, RoutedEventArgs e)
        {
            double distance;

            if (double.TryParse(distanceTextBox.Text, out distance) == false)
            {
                distanceTextBox.Focus();
                System.Media.SystemSounds.Beep.Play();
                return;
            }
            // ReSharper disable PossibleInvalidOperationException
            if (forwardRadioButton.IsChecked.Value)
            {
                car = car.Forward(distance);
            }
            else if (backwardRadioButton.IsChecked.Value)
            {
                car = car.Backward(distance);
            }
            else if (forwardLeftRadioButton.IsChecked.Value)
            {
                car = car.ForwardLeft(distance);
            }
            else if (forwardRightRadioButton.IsChecked.Value)
            {
                car = car.ForwardRight(distance);
            }
            else if (backwardLeftRadioButton.IsChecked.Value)
            {
                car = car.BackwardLeft(distance);
            }
            else if (backwardRightRadioButton.IsChecked.Value)
            {
                car = car.BackwardRight(distance);
            }

            // ReSharper restore PossibleInvalidOperationException
            painter.Draw(car);
            Debug.WriteLine("{0}, {1}, {2}", car.Center.X, car.Center.Y, car.Orientation);

            if (historyListBox.SelectedIndex > -1)
            {
                if (historyListBox.SelectedIndex < historyListBox.Items.Count - 1)
                {
                    historyListBox.SelectedIndex++;
                }
                else
                {
                    historyListBox.SelectedIndex = -1;
                }
            }
        }
Esempio n. 2
0
            public List <Node> GetConnectedPositions(double distance, double degree)
            {
                List <Node> list = new List <Node>(6);

                Car vc = Car.Forward(distance);

                list.Add(new Node(new Point3D(vc.Center.X, vc.Center.Y, vc.Orientation),
                                  new Action {
                    ActionDirection = ActionDirection.Forward, Parameter = distance
                }));

                vc = Car.ForwardLeft(degree);
                list.Add(new Node(new Point3D(vc.Center.X, vc.Center.Y, vc.Orientation),
                                  new Action {
                    ActionDirection = ActionDirection.ForwardLeft, Parameter = degree
                }));

                vc = Car.ForwardRight(degree);
                list.Add(new Node(new Point3D(vc.Center.X, vc.Center.Y, vc.Orientation),
                                  new Action {
                    ActionDirection = ActionDirection.ForwardRight, Parameter = degree
                }));

                vc = Car.Backward(distance);
                list.Add(new Node(new Point3D(vc.Center.X, vc.Center.Y, vc.Orientation),
                                  new Action {
                    ActionDirection = ActionDirection.Backward, Parameter = distance
                }));

                vc = Car.BackwardLeft(degree);
                list.Add(new Node(new Point3D(vc.Center.X, vc.Center.Y, vc.Orientation),
                                  new Action {
                    ActionDirection = ActionDirection.BackwardLeft, Parameter = degree
                }));

                vc = Car.BackwardRight(degree);
                //Debug.Assert(Math.Abs(Car.Orientation - vc.Orientation) > 1);
                list.Add(new Node(new Point3D(vc.Center.X, vc.Center.Y, vc.Orientation),
                                  new Action {
                    ActionDirection = ActionDirection.BackwardRight, Parameter = degree
                }));

                return(list);
            }