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)); } }
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); } }
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); }
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); } }