コード例 #1
0
        public void Remove(BaseShaper2D shape)
        {
            var idx = allColliders.IndexOf(shape);

            if (idx != -1)
            {
                Remove(idx);
            }
        }
コード例 #2
0
ファイル: AABB.cs プロジェクト: tuita520/LockstepPlatform
 public override bool TestWithShape(BaseShaper2D a)
 {
     return(a.TestWith(this));
 }
コード例 #3
0
 public virtual bool TestWithShape(BaseShaper2D a){return false;}
コード例 #4
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            owner = (ColliderProxy2D)target;
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Type:");
                if (int.TryParse(GUILayout.TextField(addTypeID.ToString()), out int idx))
                {
                    addTypeID = idx;
                    addTypeID = Mathf.Clamp(addTypeID, 0, 2);
                }

                GUILayout.Label("removeIdx:");
                if (int.TryParse(GUILayout.TextField(removeIdx.ToString()), out int _idx))
                {
                    removeIdx = Mathf.Clamp(_idx, 0, owner.allOffsets.Count - 1);
                }

                GUILayout.EndHorizontal();
            }
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("+"))
                {
                    BaseShaper2D shape = null;
                    var          type  = (EShape2D)addTypeID;
                    if (type == EShape2D.Circle)
                    {
                        owner.AddCircle(LVector2.zero, owner.transform.position.ToLVector3(), 1.ToLFloat());
                    }
                    else if (type == EShape2D.AABB)
                    {
                        owner.AddAABB(LVector2.zero, owner.transform.position.ToLVector3(), LVector2.one);
                    }
                    else if (type == EShape2D.OBB)
                    {
                        owner.AddOBB(LVector2.zero, owner.transform.position.ToLVector3(), LVector2.one, 01.ToLFloat());
                    }
                }

                if (GUILayout.Button("-"))
                {
                    if (removeIdx >= owner.allOffsets.Count)
                    {
                        return;
                    }
                    owner.Remove(removeIdx);
                }

                GUILayout.EndHorizontal();
            }
            //Draw Property
            {
                var count = owner.allOffsets.Count;
                for (int i = 0; i < count; i++)
                {
                    var shape  = owner.allColliders[i];
                    var circle = shape as Circle;
                    if (circle != null)
                    {
                        ShowCircle(circle, i);
                    }

                    var aabb = shape as AABB;
                    if (aabb != null)
                    {
                        ShowAABB(aabb, i);
                    }

                    var obb = shape as OBB;
                    if (obb != null)
                    {
                        ShowOBB(obb, i);
                    }
                }
            }
        }