using UnityEngine;
public class RandomArea : MonoBehaviour
{
public enum _AreaType { Square, Circle }
public _AreaType type;
public Color Color = Color.red;
public Quaternion GetRotation()
{
return Quaternion.Euler(0, transform.rotation.eulerAngles.y, 0);
}
public Vector3 GetPosition()
{
if (type == _AreaType.Square)
{
float x = Random.Range(-transform.localScale.x, transform.localScale.x);
float z = Random.Range(-transform.localScale.z, transform.localScale.z);
Vector3 v = transform.position + transform.rotation * new Vector3(x, 0, z);
return v;
}
else if (type == _AreaType.Circle)
{
Vector3 dir = new Vector3(Random.Range(-1f, 1f), 0, Random.Range(-1f, 1f)).normalized;
return transform.position + transform.rotation * dir * Random.Range(0, GetMaximumScale());
}
return transform.positio