[Refactor] GlobalOrbitalSettings
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -69,6 +69,9 @@ sysinfo.txt
|
|||||||
/Win64-Build
|
/Win64-Build
|
||||||
/Build
|
/Build
|
||||||
|
|
||||||
|
# Rider IDE project files
|
||||||
|
.idea/
|
||||||
|
|
||||||
# Crashlytics generated file
|
# Crashlytics generated file
|
||||||
crashlytics-build.properties
|
crashlytics-build.properties
|
||||||
|
|
||||||
|
|||||||
@@ -680,12 +680,12 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 1b1a209741ad95946a6f0138e93431c4, type: 3}
|
m_Script: {fileID: 11500000, guid: 1b1a209741ad95946a6f0138e93431c4, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_RadiusSpeed: 0.5
|
<RadiusSpeed>k__BackingField: 0.5
|
||||||
m_DistanceSpeed: 0.6
|
<DistanceSpeed>k__BackingField: 0.6
|
||||||
m_GapDistance: 1
|
<GapDistance>k__BackingField: 1
|
||||||
m_RingPrefab: {fileID: 8276642441649562681, guid: 2b69b065f2beade4d91167a23508e29e, type: 3}
|
<RingPrefab>k__BackingField: {fileID: 8276642441649562681, guid: 2b69b065f2beade4d91167a23508e29e, type: 3}
|
||||||
m_EnemyPrefab: {fileID: 345795220292517504, guid: ec4a924a38b208240b281bd7983b07b7, type: 3}
|
<EnemyPrefab>k__BackingField: {fileID: 345795220292517504, guid: ec4a924a38b208240b281bd7983b07b7, type: 3}
|
||||||
m_ModifierPrefab: {fileID: 7367671708397998036, guid: 780bf151465173e4a82da2763da54b2b, type: 3}
|
<ModifierPrefab>k__BackingField: {fileID: 7367671708397998036, guid: 780bf151465173e4a82da2763da54b2b, type: 3}
|
||||||
--- !u!4 &1827131557
|
--- !u!4 &1827131557
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -1,26 +1,16 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class GlobalOrbitalSettings : MonoBehaviour
|
public class Settings : MonoBehaviour
|
||||||
{
|
{
|
||||||
private static GlobalOrbitalSettings Instance = null;
|
public static Settings Instance;
|
||||||
|
|
||||||
[SerializeField, Range(0f, Mathf.PI * 2)] float m_RadiusSpeed = 2f;
|
[field: SerializeField, Range(0f, Mathf.PI * 2)] public float RadiusSpeed { get; private set; } = 2f;
|
||||||
public static float RadiusSpeed => Instance.m_RadiusSpeed;
|
[field: SerializeField, Range(0f, 2f)] public float DistanceSpeed { get; private set; } = 0.6f;
|
||||||
|
[field: SerializeField, Range(0f, 1f)] public float GapDistance { get; private set; } = 0.3f;
|
||||||
|
|
||||||
[SerializeField, Range(0f, 2f)] float m_DistanceSpeed = 0.6f;
|
[field: SerializeField] public GameObject RingPrefab { get; private set; }
|
||||||
public static float DistanceSpeed => Instance.m_DistanceSpeed;
|
[field: SerializeField] public GameObject EnemyPrefab { get; private set; }
|
||||||
|
[field: SerializeField] public GameObject ModifierPrefab { get; private set; }
|
||||||
[SerializeField, Range(0f, 1f)] float m_GapDistance = 0.3f;
|
|
||||||
public static float GapDistance => Instance.m_GapDistance;
|
|
||||||
|
|
||||||
[SerializeField] GameObject m_RingPrefab;
|
|
||||||
public static GameObject RingPrefab => Instance.m_RingPrefab;
|
|
||||||
|
|
||||||
[SerializeField] GameObject m_EnemyPrefab;
|
|
||||||
public static GameObject EnemyPrefab => Instance.m_EnemyPrefab;
|
|
||||||
|
|
||||||
[SerializeField] GameObject m_ModifierPrefab;
|
|
||||||
public static GameObject ModifierPrefab => Instance.m_ModifierPrefab;
|
|
||||||
|
|
||||||
private void Start() => Instance = this;
|
private void Start() => Instance = this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,9 +129,9 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
|||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
if (Time.time - m_TimeOfLastRingSpawn > (GlobalOrbitalSettings.GapDistance / m_LocalDeltaTimeScale))
|
if (Time.time - m_TimeOfLastRingSpawn > (Settings.Instance.GapDistance / m_LocalDeltaTimeScale))
|
||||||
{
|
{
|
||||||
GameObject newRing = Instantiate(GlobalOrbitalSettings.RingPrefab);
|
GameObject newRing = Instantiate(Settings.Instance.RingPrefab);
|
||||||
newRing.transform.localScale = new Vector3(12f, 12f, 1);
|
newRing.transform.localScale = new Vector3(12f, 12f, 1);
|
||||||
|
|
||||||
Ring ring = newRing.AddComponent<Ring>();
|
Ring ring = newRing.AddComponent<Ring>();
|
||||||
@@ -150,7 +150,7 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
|||||||
|
|
||||||
m_CurrentRingAllowsSpawning = Random.Range(0, 25) != 0;
|
m_CurrentRingAllowsSpawning = Random.Range(0, 25) != 0;
|
||||||
if (!m_CurrentRingAllowsSpawning && AllowPlayerInput)
|
if (!m_CurrentRingAllowsSpawning && AllowPlayerInput)
|
||||||
Instantiate(GlobalOrbitalSettings.ModifierPrefab);
|
Instantiate(Settings.Instance.ModifierPrefab);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Ring> toRemove = new();
|
List<Ring> toRemove = new();
|
||||||
@@ -158,7 +158,7 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
|||||||
|
|
||||||
foreach (Ring ring in m_Rings)
|
foreach (Ring ring in m_Rings)
|
||||||
{
|
{
|
||||||
float diff = LocalDeltaTime * GlobalOrbitalSettings.DistanceSpeed;
|
float diff = LocalDeltaTime * Settings.Instance.DistanceSpeed;
|
||||||
ring.transform.localScale -= new Vector3(diff, diff, 0f);
|
ring.transform.localScale -= new Vector3(diff, diff, 0f);
|
||||||
|
|
||||||
LineRenderer lineRenderer = ring.GetComponentInChildren<LineRenderer>();
|
LineRenderer lineRenderer = ring.GetComponentInChildren<LineRenderer>();
|
||||||
@@ -207,7 +207,7 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
|||||||
|
|
||||||
float distance = m_Distances[orbitalPosition.m_AttachedRing];
|
float distance = m_Distances[orbitalPosition.m_AttachedRing];
|
||||||
orbitalPosition.m_DistanceFromCentre = distance;
|
orbitalPosition.m_DistanceFromCentre = distance;
|
||||||
orbitalPosition.m_DistanceAlongRadius = (orbitalPosition.m_DistanceAlongRadius + LocalDeltaTime * GlobalOrbitalSettings.RadiusSpeed * orbitalPosition.m_SpinSpeed) % (Mathf.PI * 2);
|
orbitalPosition.m_DistanceAlongRadius = (orbitalPosition.m_DistanceAlongRadius + LocalDeltaTime * Settings.Instance.RadiusSpeed * orbitalPosition.m_SpinSpeed) % (Mathf.PI * 2);
|
||||||
|
|
||||||
orbitalPosition.m_Owner.position = orbitalPosition.TranslateToVec3();
|
orbitalPosition.m_Owner.position = orbitalPosition.TranslateToVec3();
|
||||||
}
|
}
|
||||||
@@ -232,7 +232,7 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Random.Range(0, 20) == 0 && AllowPlayerInput && m_CurrentRingAllowsSpawning)
|
if (Random.Range(0, 20) == 0 && AllowPlayerInput && m_CurrentRingAllowsSpawning)
|
||||||
Instantiate(GlobalOrbitalSettings.EnemyPrefab);
|
Instantiate(Settings.Instance.EnemyPrefab);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RegisterOrbitalPositionInstance(OrbitalPosition newInstance) =>
|
public static void RegisterOrbitalPositionInstance(OrbitalPosition newInstance) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user