Beispiel #1
0
        private double Distance(Point point, Blockrelation relation)
        {
            if (relation.Block2 == null)
            {
                return(double.MaxValue);
            }

            double relationX = (relation.Block1.X + relation.Block2.X + 1) / 2.0;
            double relationY = (relation.Block1.Y + relation.Block2.Y + 1) / 2.0;

            return(Math.Sqrt(Math.Pow(relationX - point.X, 2) + Math.Pow(relationY - point.Y, 2)));
        }
Beispiel #2
0
        private double Distance(double x, double y, Blockrelation relation)
        {
            if (relation.Block2 == null)
            {
                return(double.MaxValue);
            }

            double relationX = (relation.Block1.X + relation.Block2.X) / 2.0;
            double relationY = (relation.Block1.Y + relation.Block2.Y) / 2.0;

            return(Math.Sqrt(Math.Pow(relationX - x, 2) + Math.Pow(relationY - y, 2)));
        }
Beispiel #3
0
        public void LabyrinthControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Point position = e.GetPosition(this);

            double widthFactor  = ActualWidth / BlocksWidth;
            double heightFactor = ActualHeight / BlocksHeight;

            position = new Point(position.X / widthFactor - 0.5, position.Y / heightFactor - 0.5);

            Blockrelation relation = Robot.ActualLabyrinth[position.X, position.Y];

            if (relation.Relation == RelationType.Close)
            {
                relation.Open();
            }
            else if (relation.Relation == RelationType.Open)
            {
                relation.Close();
            }

            InvalidateVisual();
            Robot = new Robot(Robot.ActualLabyrinth);
        }