Esempio n. 1
0
        public bool Hit(ICollider other)
        {
            bool bRetVal = false;

            _hitPoint.Clear();
            if (other != null)
            {
                switch (other.Type)
                {
                case Collider2DType.Box:
                    //HitBox((BoxCollider)other);
                    break;

                case Collider2DType.Circle:
                {
                    bRetVal = HitCircle((CircleCollider)other);
                    if (bRetVal)
                    {
                        CalcCircleHits((CircleCollider)other);
                    }
                }
                break;

                case Collider2DType.PlaneX:
                case Collider2DType.PlaneY:
                    bRetVal = HitPlane((PlaneCollider)other);
                    break;
                }
            }
            if (bRetVal)
            {
                CollisionEventArgs ce = new CollisionEventArgs
                {
                    Who      = other.Owner,
                    Source   = this.Owner,
                    Points   = _hitPoint,
                    Location = _hitLocation,
                    Distance = _circleDistance
                };
                CallCollisionEvent(other.Owner, ce);
                other.CallCollisionEvent(this.Owner, ce);
            }

            return(bRetVal);
        }