[Refactor] Reworked how OrbitalBehaviour behaves under the hood
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EnemyController : OrbitalPositionBehaviour
|
||||
public class EnemyController : OrbitalBehaviour
|
||||
{
|
||||
private static readonly List<EnemyController> Instances = new();
|
||||
|
||||
@@ -16,23 +16,31 @@ public class EnemyController : OrbitalPositionBehaviour
|
||||
Instances.Clear();
|
||||
}
|
||||
|
||||
protected override void OnStart()
|
||||
private void Start()
|
||||
{
|
||||
Instances.Add(this);
|
||||
|
||||
transform.position = new Vector3(0, 0, -200f);
|
||||
RegisterObject(new OrbitalInitializer
|
||||
{
|
||||
DistanceAlongCircumference = Random.Range(0f, Mathf.PI * 2f),
|
||||
ObjectRadius = 0.1f,
|
||||
SpinSpeed = 0.7f
|
||||
});
|
||||
|
||||
m_OrbitalPosition.m_DistanceAlongRadius = Random.Range(0f, Mathf.PI * 2f);
|
||||
m_OrbitalPosition.m_ObjectRadius = 0.1f;
|
||||
m_OrbitalPosition.m_SpinSpeed = 0.7f;
|
||||
transform.position = new Vector3(0, 0, -200f);
|
||||
}
|
||||
|
||||
public override void OnReachCentre()
|
||||
protected override void OnReachCentre()
|
||||
{
|
||||
if (GlobalOrbitalPositionManager.s_IsSimulationRunning)
|
||||
if (BehaviourManager.IsSimulationRunning)
|
||||
PlayerController.s_PlayerScore++;
|
||||
|
||||
Instances.Remove(this);
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
BehaviourManager.UnregisterOrbitalInstance(this);
|
||||
Instances.Remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user