Made player launch when hit
Needs fixing
This commit is contained in:
@@ -8,6 +8,7 @@ using UnityEngine;
|
||||
public float m_DistanceFromCentre;
|
||||
public float m_DistanceAlongRadius;
|
||||
public float m_ObjectRadius = 0.1f;
|
||||
public bool m_IsAttachedToRings = true;
|
||||
|
||||
public OrbitalPositionBehaviour m_Behaviour;
|
||||
public readonly Transform m_Owner;
|
||||
@@ -84,8 +85,12 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
yield return new WaitForFixedUpdate();
|
||||
s_Instance.m_PlayerOrbitalPosition.m_AttachedRing = s_Instance.m_LastGeneratedRing;
|
||||
|
||||
if (PlayerController.IsPlayerAttached)
|
||||
s_Instance.m_PlayerOrbitalPosition.m_AttachedRing = s_Instance.m_LastGeneratedRing;
|
||||
}
|
||||
|
||||
PlayerController.AttachPlayer();
|
||||
|
||||
yield return new WaitForSeconds(1.3f);
|
||||
AllowPlayerInput = true;
|
||||
@@ -149,6 +154,9 @@ public class GlobalOrbitalPositionManager : MonoBehaviour
|
||||
|
||||
foreach (OrbitalPosition orbitalPosition in m_ObjectInstances)
|
||||
{
|
||||
if (!orbitalPosition.m_IsAttachedToRings)
|
||||
continue;
|
||||
|
||||
if (!m_Distances.ContainsKey(orbitalPosition.m_AttachedRing))
|
||||
{
|
||||
orbitalPosition.m_AttachedRing = m_LastGeneratedRing;
|
||||
|
||||
@@ -2,14 +2,22 @@ using UnityEngine;
|
||||
|
||||
public class PlayerController : OrbitalPositionBehaviour
|
||||
{
|
||||
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; }
|
||||
|
||||
public Rigidbody2D m_Body;
|
||||
|
||||
protected override void OnStart()
|
||||
{
|
||||
s_Instance = this;
|
||||
|
||||
GlobalOrbitalPositionManager.SetPlayer(m_OrbitalPosition);
|
||||
|
||||
m_OrbitalPosition.m_ObjectRadius = 0.4f;
|
||||
m_OrbitalPosition.m_SpinSpeed = 0.1f;
|
||||
}
|
||||
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space) && GlobalOrbitalPositionManager.AllowPlayerInput)
|
||||
@@ -20,7 +28,10 @@ public class PlayerController : OrbitalPositionBehaviour
|
||||
|
||||
public override void OnCollision(OrbitalPositionBehaviour other)
|
||||
{
|
||||
Debug.Log("HIT OBSTACLE IG");
|
||||
GlobalOrbitalPositionManager.RestartSimulation();
|
||||
|
||||
m_OrbitalPosition.m_IsAttachedToRings = false;
|
||||
m_Body.AddForce(Vector2.up * 6, ForceMode2D.Impulse);
|
||||
}
|
||||
|
||||
public override void OnReachCentre()
|
||||
|
||||
Reference in New Issue
Block a user