40 lines
958 B
C#
40 lines
958 B
C#
using UnityEngine;
|
|
|
|
public class FlockSystem : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private GameObject flockTemplate;
|
|
|
|
[SerializeField]
|
|
private int flockAmount = 20;
|
|
|
|
[SerializeField]
|
|
private float radiusCreate = 10f;
|
|
|
|
[SerializeField]
|
|
private int amountOfFlocks;
|
|
|
|
private void SpawnFlocks()
|
|
{
|
|
for (int i = 0; i < flockAmount; i++)
|
|
{
|
|
Vector3 position = Random.insideUnitSphere * radiusCreate + base.transform.position;
|
|
Object.Instantiate(flockTemplate, position, Quaternion.identity, flockTemplate.transform.parent);
|
|
}
|
|
amountOfFlocks = Object.FindObjectsOfType<LocalAvoidance>().Length;
|
|
}
|
|
|
|
private void ReloadScene()
|
|
{
|
|
flockTemplate.transform.position = base.transform.position;
|
|
LocalAvoidance[] array = Object.FindObjectsOfType<LocalAvoidance>();
|
|
foreach (LocalAvoidance localAvoidance in array)
|
|
{
|
|
if (flockTemplate.gameObject != localAvoidance.gameObject)
|
|
{
|
|
Object.Destroy(localAvoidance.gameObject);
|
|
}
|
|
}
|
|
}
|
|
}
|