Added player mod (powerups)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
20
Assets/Scripts/PlayerModifier.cs
Normal file
20
Assets/Scripts/PlayerModifier.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/PlayerModifier.cs.meta
Normal file
11
Assets/Scripts/PlayerModifier.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29014004c04338246b2673078c5d8a52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user