public GameObject[] GetNearbyCells(Vector2 position, float radius) { List <GameObject> nearbyHives = new List <GameObject>(); foreach (GameObject hive in Beehives) { Hive.Hive hiveComponent = hive.GetComponent <Hive.Hive>(); foreach (GameObject hiveCell in hiveComponent.Cells) { Vector2 distance = hiveCell.transform.position - (Vector3)position; if (distance.sqrMagnitude < radius * radius) { nearbyHives.Add(hiveCell); } } } return(nearbyHives.ToArray()); }
void Start() { rm = FindObjectOfType<ResourceManager>(); hive = gameObject.GetComponent<Hive>(); Debug.Assert(hive != null, "Hive is null for this HiveWarehouse!"); refineTimer = RefineInterval; }