summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Physics/PhysicsBox.cs
blob: f8b4fee40918d0f7b61f6deae7a56a171b749e60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// AABB碰撞盒
/// </summary>
public class PhysicsBox : PhysicsPrimitive
{
	public override PrimitiveType Type
	{
		get
		{
			return PrimitiveType.Box;
		}
	}

	[SerializeField]
	private Vector3 m_Size;
	public Vector3 Size
	{
		get
		{
			return m_Size;
		}
	}

	public float Long { get { return m_Size.x; } }
	public float Wide { get { return m_Size.z; } }
	public float Height { get { return m_Size.y; } }

	public bool m_DrawGizmo = true;

	public float Top
	{
		get
		{
			return Position.y + Height / 2f;
		}
	}

	public float Left
	{
		get 
		{
			return Position.x - Long / 2f;
		}
	}

	public float Right
	{
		get
		{
			return Position.x + Long / 2f;
		}
	}

	public float Bottom
	{
		get
		{
			return Position.y - Height / 2f;
		}
	}

    public void OnDrawGizmos()
    {
        if (!m_IsActive || !m_DrawGizmo)
            return;
        Vector3 pos = Position;
        Gizmos.color = m_HintColor;
        Gizmos.DrawCube(pos, m_Size);
		//Gizmos.color = Color.blue;
		//Gizmos.DrawSphere(pos, 0.1f);
	}

	private void Start()
    {
        base.OnInit();
    }

}