diff options
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts/Tests/TestSpirits.cs')
-rw-r--r-- | WorldlineKeepers/Assets/Scripts/Tests/TestSpirits.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Tests/TestSpirits.cs b/WorldlineKeepers/Assets/Scripts/Tests/TestSpirits.cs new file mode 100644 index 0000000..8e46d3d --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Tests/TestSpirits.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UIElements; + +public class TestSpirits : MonoBehaviour +{ + public SpiritScript prefab; + + public static List<SpiritScript> spirits = new List<SpiritScript>(); + + private const int kMaxCount = 500; + + void Start() + { + int count = kMaxCount - spirits.Count; + for (int i = 0; i < count; ++i) + { + float x = UnityEngine.Random.Range(-20, 10); + float y = UnityEngine.Random.Range(-20, 10); + SpiritScript go = Instantiate(prefab) as SpiritScript; + go.transform.position = new Vector3(x, y, 0); + go.transform.parent = this.transform; + go.gameObject.SetActive(true); + } + StartCoroutine(CoSpawn(5)); + } + + IEnumerator CoSpawn(float interval) + { + while (true) + { + int count = kMaxCount - spirits.Count; + for (int i = 0; i < count; ++i) + { + float x = UnityEngine.Random.Range(-20, 10); + float y = UnityEngine.Random.Range(-20, 10); + SpiritScript go = Instantiate(prefab) as SpiritScript; + go.transform.position = new Vector3(x, y, 0); + go.transform.parent = this.transform; + go.gameObject.SetActive(true); + } + + yield return new WaitForSeconds(interval); + } + } + + private void FixedUpdate() + { + for(int i = 0; i < spirits.Count; ++i) + { + spirits[i].Tick(); + } + } + +} |