Added score counter
This commit is contained in:
@@ -13,6 +13,9 @@ public class EnemyController : OrbitalPositionBehaviour
|
||||
|
||||
public override void OnReachCentre()
|
||||
{
|
||||
if (GlobalOrbitalPositionManager.IsSimulationRunning)
|
||||
PlayerController.PlayerScore++;
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
||||
private readonly List<Ring> m_Rings = new();
|
||||
private readonly Dictionary<int, float> m_Distances = new();
|
||||
|
||||
public static bool IsSimulationRunning = true;
|
||||
|
||||
private OrbitalPosition m_PlayerOrbitalPosition;
|
||||
public static void SetPlayer(OrbitalPosition player) => s_Instance.m_PlayerOrbitalPosition = player;
|
||||
|
||||
@@ -80,6 +82,8 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
||||
|
||||
private static IEnumerator RestartSimulationInternal()
|
||||
{
|
||||
IsSimulationRunning = false;
|
||||
|
||||
s_Instance.m_LocalDeltaTimeScale = 7f;
|
||||
AllowPlayerInput = false;
|
||||
for (int i = 0; i < 100; i++)
|
||||
@@ -99,6 +103,8 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
||||
yield return new WaitForSeconds(1.3f);
|
||||
AllowPlayerInput = true;
|
||||
s_Instance.m_LocalDeltaTimeScale = 1f;
|
||||
|
||||
IsSimulationRunning = true;
|
||||
}
|
||||
|
||||
public static void RestartSimulation() => s_Instance.StartCoroutine(RestartSimulationInternal());
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class PlayerController : OrbitalPositionBehaviour
|
||||
{
|
||||
public static int PlayerScore = 0;
|
||||
|
||||
private static PlayerController s_Instance;
|
||||
public static bool IsPlayerAttached => s_Instance.m_OrbitalPosition.m_IsAttachedToRings;
|
||||
public static void AttachPlayer() { s_Instance.m_OrbitalPosition.m_IsAttachedToRings = true; }
|
||||
@@ -11,6 +14,7 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
private float m_DeathLerp;
|
||||
|
||||
public MeshRenderer m_Renderer;
|
||||
public Text m_ScoreText;
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
@@ -18,12 +22,14 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
|
||||
GlobalOrbitalPositionManager.SetPlayer(m_OrbitalPosition);
|
||||
|
||||
m_OrbitalPosition.m_ObjectRadius = 0.4f;
|
||||
m_OrbitalPosition.m_ObjectRadius = 0.2f;
|
||||
m_OrbitalPosition.m_SpinSpeed = 0.2f;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
m_ScoreText.text = PlayerScore.ToString();
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space) && GlobalOrbitalPositionManager.AllowPlayerInput)
|
||||
{
|
||||
m_OrbitalPosition.m_AttachedRing += 1;
|
||||
@@ -53,6 +59,8 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
m_Renderer.enabled = true;
|
||||
|
||||
m_Renderer.material.color = Color.green;
|
||||
|
||||
PlayerScore = 0;
|
||||
}
|
||||
|
||||
public override void OnReachCentre()
|
||||
|
||||
Reference in New Issue
Block a user