예제 #1
0
        protected override void OnMouseUp(MouseButtonEventArgs e)
        {
            base.OnMouseUp(e);

            _mouseDown = false;

            if (_line != null)
            {
                // you are dragging a line

                if (_line is AttackLine)
                {
                    if (_mouseOver != null)
                    {
                        // you are currently over a planet

                        if (_mouseOver != _attackFrom)
                        {
                            // you are on a different planet

                            LinkObjects(_attackFrom, _mouseOver);
                        }
                    }
                }
                else
                {
                    // do cutting here

                    foreach (ObjectLink link in scene.Objects.Where(o => o is ObjectLink))
                    {
                        var isIntersect
                            = LinesIntersect(_line.Position, _line.To,
                                             link.Parent.Position, link.Child.Position);

                        if (isIntersect)
                        {
                            Console.WriteLine("Intersect");
                        }
                    }
                }

                scene.Remove(_line);
                _line       = null;
                _attackFrom = null;
            }
        }
예제 #2
0
        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            base.OnMouseDown(e);

            _mouseDown = true;

            if (_mouseOver != null)
            {
                _line       = new AttackLine(_mouseOver.Position, _mouseOver.Position);
                _attackFrom = _mouseOver;
            }
            else
            {
                _line = new CutLine(_mouseWorldLocation, _mouseWorldLocation);
            }
            scene.Add(_line);
        }