Added player mod (powerups)

This commit is contained in:
Pasha Bibko
2025-11-27 11:21:14 +00:00
parent 0dbbf02789
commit 055e688df5
12 changed files with 306 additions and 6 deletions

View File

@@ -19,5 +19,8 @@ public class GlobalOrbitalSettings : MonoBehaviour
[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;
}

View File

@@ -57,6 +57,8 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
private float m_LocalDeltaTimeScale = 1f;
private float LocalDeltaTime => Time.deltaTime * m_LocalDeltaTimeScale;
private bool m_CurrentRingAllowsSpawning;
private Vector3[] m_PrecalculatedPositions;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] private static void OnApplicationStart()
@@ -129,6 +131,10 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
m_LastGeneratedRing = ring.m_ID;
m_TimeOfLastRingSpawn = Time.time;
m_CurrentRingAllowsSpawning = Random.Range(0, 25) != 0;
if (!m_CurrentRingAllowsSpawning && AllowPlayerInput)
Instantiate(GlobalOrbitalSettings.ModifierPrefab);
}
List<Ring> toRemove = new();
@@ -209,7 +215,7 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
}
}
if (Random.Range(0, 20) == 0 && AllowPlayerInput)
if (Random.Range(0, 20) == 0 && AllowPlayerInput && m_CurrentRingAllowsSpawning)
Instantiate(GlobalOrbitalSettings.EnemyPrefab);
}

View File

@@ -54,11 +54,25 @@ public class PlayerController : OrbitalPositionBehaviour
{
if (!m_OrbitalPosition.m_IsAttachedToRings)
return;
if (other.CompareTag("Enemy"))
{
GlobalOrbitalPositionManager.RestartSimulation();
m_SuicidePoint = transform.position;
m_KillingItself = true;
m_DeathLerp = 0f;
}
GlobalOrbitalPositionManager.RestartSimulation();
m_SuicidePoint = transform.position;
m_KillingItself = true;
m_DeathLerp = 0f;
else if (other.CompareTag("PlayerMod"))
{
other.OnCollision(this);
Debug.Log("Collided with player mod");
}
else
{
Debug.Log("Unknown collision occured");
}
}
public override void OnSimulationRestart()

View File

@@ -0,0 +1,20 @@
using UnityEngine;
public class PlayerModifier : OrbitalPositionBehaviour
{
protected override void OnStart()
{
transform.position = new Vector3(0, 0, -100f);
m_OrbitalPosition.m_DistanceAlongRadius = Random.Range(0f, Mathf.PI * 2f);
m_OrbitalPosition.m_ObjectRadius = 0.3f;
m_OrbitalPosition.m_SpinSpeed = 1.6f;
}
public override void OnReachCentre() => Destroy(gameObject);
public override void OnCollision(OrbitalPositionBehaviour other)
{
Destroy(gameObject);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 29014004c04338246b2673078c5d8a52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: