예제 #1
0
    private ViewCastInfo ViewCast(float angle)
    {
        Vector3      dir = MathUtility.AngleToVector3((angle));
        RaycastHit2D hit = Physics2D.Raycast(transform.position, dir, viewRadius, obstacleMask);

        if (hit.collider != null)
        {
            return(new ViewCastInfo(true, hit.point, hit.distance, angle));
        }
        else
        {
            return(new ViewCastInfo(false, transform.position + dir * viewRadius, viewRadius, angle));
        }
    }
예제 #2
0
        private void ToSpecificLayout(Transform centerObject, Button[] buttonUI, float angle, float radius, float space)
        {
            int componentLength = buttonUI.Length;

            float totalSpace = (componentLength - 1) * space;

            float startAngle = angle - (totalSpace / 2);

            for (int i = 0; i < componentLength; i++)
            {
                Transform child = buttonUI[i].transform;

                Vector3 rotatePos = MathUtility.AngleToVector3(startAngle + (space * i));
                child.position = centerObject.position + (rotatePos * radius);
            }
        }
예제 #3
0
    private void OnSceneGUI()
    {
        FieldOfView fow = (FieldOfView) target;
        Handles.color = Color.white;
        Handles.DrawWireArc(fow.transform.position, Vector3.forward, Vector3.up, 360, fow.viewRadius);

        Vector3 viewAngleA = MathUtility.AngleToVector3( fow.GetLocalAngle(-fow.viewAngle / 2) );
        Vector3 viewAngleB = MathUtility.AngleToVector3(fow.GetLocalAngle(fow.viewAngle / 2));

        Handles.DrawLine(fow.transform.position, fow.transform.position + viewAngleA * fow.viewRadius);
        Handles.DrawLine(fow.transform.position, fow.transform.position + viewAngleB * fow.viewRadius);

        int visibleCount = fow.visibleTargets.Count;
        Handles.color = Color.red;
        for (int k = 0; k < visibleCount; k++)
            Handles.DrawLine(fow.transform.position, fow.visibleTargets[k].position);
    }
예제 #4
0
        private void ToEqualSpaceLayout(Transform centerObject, Button[] buttonUI, float radius)
        {
            int   componentLength = buttonUI.Length;
            float space           = 360f / componentLength;

            for (int i = 0; i < componentLength; i++)
            {
                Transform child = buttonUI[i].transform;

                float angle = space * i;

                if (componentLength % 2 == 0)
                {
                    angle += space / 2;
                }

                Vector3 rotatePos = MathUtility.AngleToVector3(angle);
                child.position = centerObject.position + (rotatePos * radius);
            }
        }