diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 0c63483..db83445 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -162,7 +162,7 @@ MonoBehaviour: m_Behaviour: {fileID: 0} m_SpinSpeed: 0 m_Renderer: {fileID: 104400500} - m_Transform: {fileID: 104400498} + m_ScoreText: {fileID: 1501855168} --- !u!4 &104400498 Transform: m_ObjectHideFlags: 0 @@ -399,6 +399,255 @@ MonoBehaviour: m_BeforeTransparentBundles: [] m_BeforeStackBundles: [] m_AfterStackBundles: [] +--- !u!1 &1158970869 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1158970873} + - component: {fileID: 1158970872} + - component: {fileID: 1158970871} + - component: {fileID: 1158970870} + m_Layer: 5 + m_Name: IGUI + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1158970870 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1158970869} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &1158970871 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1158970869} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 + m_PresetInfoIsWorld: 0 +--- !u!223 &1158970872 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1158970869} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 1 + m_Camera: {fileID: 519420031} + m_PlaneDistance: 5 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_VertexColorAlwaysGammaSpace: 1 + m_AdditionalShaderChannelsFlag: 0 + m_UpdateRectTransformForStandalone: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &1158970873 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1158970869} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1501855167} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!1 &1501855166 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1501855167} + - component: {fileID: 1501855169} + - component: {fileID: 1501855168} + m_Layer: 5 + m_Name: ScoreDisplay + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1501855167 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1501855166} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1158970873} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 5, y: 5} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1501855168 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1501855166} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 35 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 3 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 1 + m_LineSpacing: 1 + m_Text: 65536 +--- !u!222 &1501855169 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1501855166} + m_CullTransparentMesh: 1 +--- !u!1 &1692737941 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1692737944} + - component: {fileID: 1692737943} + - component: {fileID: 1692737942} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1692737942 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1692737941} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} + m_Name: + m_EditorClassIdentifier: + m_SendPointerHoverToParent: 1 + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &1692737943 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1692737941} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &1692737944 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1692737941} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1827131555 GameObject: m_ObjectHideFlags: 0 @@ -455,3 +704,5 @@ SceneRoots: - {fileID: 1827131557} - {fileID: 104400498} - {fileID: 519420032} + - {fileID: 1158970873} + - {fileID: 1692737944} diff --git a/Assets/Scripts/EnemyController.cs b/Assets/Scripts/EnemyController.cs index a0cb0cf..d5d31ef 100644 --- a/Assets/Scripts/EnemyController.cs +++ b/Assets/Scripts/EnemyController.cs @@ -13,6 +13,9 @@ public class EnemyController : OrbitalPositionBehaviour public override void OnReachCentre() { + if (GlobalOrbitalPositionManager.IsSimulationRunning) + PlayerController.PlayerScore++; + Destroy(gameObject); } } diff --git a/Assets/Scripts/OrbitalPosition.cs b/Assets/Scripts/OrbitalPosition.cs index 86b30fc..25b7475 100644 --- a/Assets/Scripts/OrbitalPosition.cs +++ b/Assets/Scripts/OrbitalPosition.cs @@ -40,6 +40,8 @@ public class GlobalOrbitalPositionManager : MonoBehaviour private readonly List m_Rings = new(); private readonly Dictionary 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()); diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 0fed058..982798c 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -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()