コード例 #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
ファイル: ColliderObject.cs プロジェクト: cnscj/THSTG
        //添加形状
        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
ファイル: CircleCollider.cs プロジェクト: cnscj/THSTG
        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);