Пример #1
0
        protected override bool OnCheck(ColliderShape shape)
        {
            var other = shape as BoxCollider;
            var rt1   = this.m_rect;
            var rt2   = other.m_rect;


            if ((rt1.yMin > rt2.yMin && rt1.yMin < rt2.yMax) ||
                (rt1.yMax > rt2.yMin && rt1.yMax < rt2.yMax))
            {
                if ((rt1.xMin > rt2.xMin && rt1.xMin < rt2.xMax) ||
                    (rt1.xMax > rt2.xMin && rt1.xMax < rt2.xMax))
                {
                    return(true);
                }
            }
            if ((rt2.yMin > rt1.yMin && rt2.yMin < rt1.yMax) ||
                (rt2.yMax > rt1.yMin && rt2.yMax < rt1.yMax))
            {
                if ((rt2.xMin > rt1.xMin && rt2.xMin < rt1.xMax) ||
                    (rt2.xMax > rt1.xMin && rt2.xMax < rt1.xMax))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #2
0
        //添加形状
        public ColliderObject AddShape(ColliderShape shape)
        {
            m_shapes = m_shapes ?? new List <ColliderShape>();
            m_shapes.Add(shape);
            shape.parent = this;

            return(this);
        }
Пример #3
0
 public bool Check(ColliderShape other)
 {
     if (this.type == other.type)
     {
         return(OnCheck(other));
     }
     return(OnCheck(this, other));
 }
Пример #4
0
        protected override bool OnCheck(ColliderShape shape)
        {
            var other = shape as CircleCollider;
            var vec3  = other.GetPosition() - this.GetPosition();

            if (vec3.magnitude < other.radius + this.radius)
            {
                return(true);
            }
            return(false);
        }
Пример #5
0
        //公共的
        public bool OnCheck(ColliderShape a, ColliderShape b)
        {
            if (a.type == ShapeType.Box && b.type == ShapeType.Circle)
            {
                return(CheckBoxCircle(a as BoxCollider, b as CircleCollider));
            }
            else if (a.type == ShapeType.Circle && b.type == ShapeType.Box)
            {
                return(CheckBoxCircle(b as BoxCollider, a as CircleCollider));
            }


            return(false);
        }
Пример #6
0
 protected abstract bool OnCheck(ColliderShape shape);