public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List <IActorComponent> results = new List <IActorComponent>();
            Vector2 pointA = _actorA == null ? _nodeA.position : _actorA.collisionFilterConnectionPosition;
            Vector2 pointB = _actorB == null ? _nodeB.position : _actorB.collisionFilterConnectionPosition;

            // Hit test points
            if (_level.controller.hitTestPoint(testPoint, pointA))
            {
                if (_actorA == null)
                {
                    results.Add(_nodeA);
                    return(callback(results));
                }
            }
            else if (_level.controller.hitTestPoint(testPoint, pointB))
            {
                if (_actorB == null)
                {
                    results.Add(_nodeB);
                    return(callback(results));
                }
            }

            if (_level.controller.hitTestLine(testPoint, pointA, pointB))
            {
                results.Add(_nodeA);
                results.Add(_nodeB);
                return(callback(results));
            }

            return(false);
        }
Beispiel #2
0
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List <IActorComponent> results = new List <IActorComponent>();

            // Hit test points
            if (_level.controller.hitTestPoint(testPoint, _nodeA.position))
            {
                results.Add(_nodeA);
                return(callback(results));
            }
            else if (_level.controller.hitTestPoint(testPoint, _nodeB.position))
            {
                results.Add(_nodeB);
                return(callback(results));
            }

            // Hit test line
            if (_level.controller.hitTestLine(testPoint, _nodeA.position, _nodeB.position))
            {
                results.Add(this);
                return(callback(results));
            }

            return(false);
        }
Beispiel #3
0
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List <IActorComponent> results = new List <IActorComponent>();

            // Hit test gate controls
            foreach (GateControl control in _gateControls)
            {
                if (_level.controller.hitTestPoint(testPoint, control.position))
                {
                    results.Add(control);
                    return(callback(results));
                }
            }

            // Hit test icon
            if (_level.controller.hitTestPoint(testPoint, _position, 12f))
            {
                results.Add(this);
                return(callback(results));
            }

            // Hit test connection
            foreach (CircuitConnection connection in _connections)
            {
                if (_level.controller.hitTestLine(testPoint, _position, connection.actor.circuitConnectionPosition))
                {
                    results.Add(connection);
                    return(callback(results));
                }
            }

            return(false);
        }
Beispiel #4
0
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List <IActorComponent> results = new List <IActorComponent>();

            // Hit test controls
            if (_level.controller.hitTestPoint(testPoint, _controlA.position))
            {
                results.Add(_controlA);
                return(callback(results));
            }
            if (_level.controller.hitTestPoint(testPoint, _controlB.position))
            {
                results.Add(_controlB);
                return(callback(results));
            }

            // Hit test icon
            if (_level.controller.hitTestPoint(testPoint, _position, 12f))
            {
                results.Add(this);
                return(callback(results));
            }

            return(false);
        }
Beispiel #5
0
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List <IActorComponent> results = new List <IActorComponent>();

            if (_level.controller.hitTestBox(testPoint, _position, _halfWidth, _halfHeight, _angle))
            {
                results.Add(this);
            }

            return(callback(results));
        }
Beispiel #6
0
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List <IActorComponent> results = new List <IActorComponent>();

            if (_level.controller.hitTestCircle(testPoint, _position, _radius))
            {
                results.Add(this);
                return(callback(results));
            }

            return(false);
        }
Beispiel #7
0
        /// <summary>
        /// Creates a <strong><see cref="UIController"/></strong> instance with the specified parameters.
        /// </summary>
        /// <param name="touchTarget">A touch target to use for collecting touches.</param>
        /// <param name="hitTestCallback">A delegate that is used to do hit testing.</param>
        public UIController(TouchTarget touchTarget, HitTestCallback hitTestCallback)
        {
            if (touchTarget == null)
                throw SurfaceCoreFrameworkExceptions.ArgumentNullException("touchTarget");

            if (hitTestCallback == null)
                throw SurfaceCoreFrameworkExceptions.ArgumentNullException("hitTestCallback");

            this.touchTarget = touchTarget;
            this.hitTestCallback = hitTestCallback;

            this.touchTarget.TouchDown += new EventHandler<TouchEventArgs>(OnTouchAdded);
            this.touchTarget.TouchMove += new EventHandler<TouchEventArgs>(OnTouchMoved);
            this.touchTarget.TouchUp += new EventHandler<TouchEventArgs>(OnTouchRemoved);
        }
Beispiel #8
0
        /// <summary>
        /// Creates a <strong><see cref="UIController"/></strong> instance with the specified parameters.
        /// </summary>
        /// <param name="contactTarget">A contact target to use for collecting contacts.</param>
        /// <param name="hitTestCallback">A delegate that is used to do hit testing.</param>
        public UIController(ContactTarget contactTarget, HitTestCallback hitTestCallback)
        {
            if (contactTarget == null)
                throw SurfaceCoreFrameworkExceptions.ArgumentNullException("contactTarget");

            if (hitTestCallback == null)
                throw SurfaceCoreFrameworkExceptions.ArgumentNullException("hitTestCallback");

            this.contactTarget = contactTarget;
            this.hitTestCallback = hitTestCallback;

            this.contactTarget.ContactAdded += new EventHandler<ContactEventArgs>(OnContactAdded);
            this.contactTarget.ContactChanged += new EventHandler<ContactEventArgs>(OnContactChanged);
            this.contactTarget.ContactRemoved += new EventHandler<ContactEventArgs>(OnContactRemoved);
        }
Beispiel #9
0
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List <IActorComponent> results = new List <IActorComponent>();

            // Hit test box
            Vector2 relative = new Vector2(_internodeHalfLength / 2f, 0);
            Matrix  offset   = Matrix.CreateTranslation(new Vector3(relative, 0)) * Matrix.CreateRotationZ(_angle);

            if (_level.controller.hitTestBox(testPoint, _position + Vector2.Transform(relative, offset), _internodeHalfLength, _maxBaseHalfWidth, _angle))
            {
                results.Add(this);
                return(callback(results));
            }

            return(false);
        }
Beispiel #10
0
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List <IActorComponent> results = new List <IActorComponent>();

            // Test points
            PointListNode current = _headPoint;

            while (current != null)
            {
                if (_level.controller.hitTestPoint(testPoint, current.position))
                {
                    results.Add(current);
                    callback(results);
                    return(true);
                }
                current = current.next;
            }

            // Test line segments
            current = _headPoint;
            while (current != null && current.next != null)
            {
                PointListNode next = current.next;
                if (_level.controller.hitTestLine(testPoint, current.position, next.position))
                {
                    results.Add(current);
                    results.Add(next);
                    return(callback(results));
                }

                current = current.next;
            }

            /*
             * // Test polygon
             * if (_level.controller.hitTestPolygon(testPoint, _headPoint.points))
             * {
             *  results.Add(this);
             *  return callback(results);
             * }*/

            return(false);
        }
Beispiel #11
0
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List<IActorComponent> results = new List<IActorComponent>();

            if (_level.controller.hitTestPoint(testPoint, _position, 12f))
            {
                results.Add(this);
                return callback(results);
            }

            return false;
        }
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List<IActorComponent> results = new List<IActorComponent>();
            Vector2 pointA = _actorA == null ? _nodeA.position : _actorA.collisionFilterConnectionPosition;
            Vector2 pointB = _actorB == null ? _nodeB.position : _actorB.collisionFilterConnectionPosition;

            // Hit test points
            if (_level.controller.hitTestPoint(testPoint, pointA))
            {
                if (_actorA == null)
                {
                    results.Add(_nodeA);
                    return callback(results);
                }
            }
            else if (_level.controller.hitTestPoint(testPoint, pointB))
            {
                if (_actorB == null)
                {
                    results.Add(_nodeB);
                    return callback(results);
                }
            }

            if (_level.controller.hitTestLine(testPoint, pointA, pointB))
            {
                results.Add(_nodeA);
                results.Add(_nodeB);
                return callback(results);
            }

            return false;
        }
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List<IActorComponent> results = new List<IActorComponent>();

            // Test points
            PointListNode current = _headPoint;
            while (current != null)
            {
                if (_level.controller.hitTestPoint(testPoint, current.position))
                {
                    results.Add(current);
                    callback(results);
                    return true;
                }
                current = current.next;
            }

            // Test line segments
            current = _headPoint;
            while (current != null && current.next != null)
            {
                PointListNode next = current.next;
                if (_level.controller.hitTestLine(testPoint, current.position, next.position))
                {
                    results.Add(current);
                    results.Add(next);
                    return callback(results);
                }

                current = current.next;
            }

            /*
            // Test polygon
            if (_level.controller.hitTestPolygon(testPoint, _headPoint.points))
            {
                results.Add(this);
                return callback(results);
            }*/

            return false;
        }
Beispiel #14
0
 abstract public bool hitTest(Vector2 testPoint, HitTestCallback callback);
Beispiel #15
0
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List<IActorComponent> results = new List<IActorComponent>();

            // Hit test points
            if (_level.controller.hitTestPoint(testPoint, _nodeA.position))
            {
                results.Add(_nodeA);
                return callback(results);
            }
            else if (_level.controller.hitTestPoint(testPoint, _nodeB.position))
            {
                results.Add(_nodeB);
                return callback(results);
            }

            // Hit test line
            if (_level.controller.hitTestLine(testPoint, _nodeA.position, _nodeB.position))
            {
                results.Add(this);
                return callback(results);
            }

            return false;
        }
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List<IActorComponent> results = new List<IActorComponent>();
            if (_level.controller.hitTestBox(testPoint, _position, _halfWidth, _halfHeight, _angle))
                results.Add(this);

            return callback(results);
        }
        public override bool hitTest(Vector2 testPoint, HitTestCallback callback)
        {
            List<IActorComponent> results = new List<IActorComponent>();

            // Hit test icon
            if (_level.controller.hitTestPoint(testPoint, _position))
            {
                results.Add(this);
                return callback(results);
            }

            // Hit test connection control
            if (_level.controller.hitTestPoint(testPoint, _connectionA.position))
            {
                results.Add(_connectionA);
                return callback(results);
            }
            else if (_level.controller.hitTestPoint(testPoint, _connectionB.position))
            {
                results.Add(_connectionB);
                return callback(results);
            }

            return false;
        }