47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class EnemyController : OrbitalBehaviour
|
|
{
|
|
private static readonly List<EnemyController> Instances = new();
|
|
|
|
public static void KillAllEnemies()
|
|
{
|
|
foreach (EnemyController controller in Instances)
|
|
{
|
|
Destroy(controller.gameObject);
|
|
PlayerController.s_PlayerScore++;
|
|
}
|
|
|
|
Instances.Clear();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
Instances.Add(this);
|
|
|
|
RegisterObject(new OrbitalInitializer
|
|
{
|
|
DistanceAlongCircumference = Random.Range(0f, Mathf.PI * 2f),
|
|
ObjectRadius = 0.1f,
|
|
SpinSpeed = 0.7f
|
|
});
|
|
|
|
transform.position = new Vector3(0, 0, -200f);
|
|
}
|
|
|
|
protected override void OnReachCentre()
|
|
{
|
|
if (BehaviourManager.IsSimulationRunning)
|
|
PlayerController.s_PlayerScore++;
|
|
|
|
Destroy(gameObject);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
BehaviourManager.UnregisterOrbitalInstance(this);
|
|
Instances.Remove(this);
|
|
}
|
|
}
|