diff --git a/Assets/Materials/WhiteMat.mat b/Assets/Materials/WhiteMat.mat new file mode 100644 index 0000000..1211099 --- /dev/null +++ b/Assets/Materials/WhiteMat.mat @@ -0,0 +1,91 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 8 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: WhiteMat + m_Shader: {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} + m_Parent: {fileID: 0} + m_ModifiedSerializedProperties: 0 + m_ValidKeywords: [] + m_InvalidKeywords: [] + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_LockedProperties: + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _AlphaTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Ints: [] + m_Floats: + - PixelSnap: 0 + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _EnableExternalAlpha: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + - _Flip: {r: 1, g: 1, b: 1, a: 1} + - _RendererColor: {r: 1, g: 1, b: 1, a: 1} + m_BuildTextureStacks: [] diff --git a/Assets/Materials/WhiteMat.mat.meta b/Assets/Materials/WhiteMat.mat.meta new file mode 100644 index 0000000..e02389d --- /dev/null +++ b/Assets/Materials/WhiteMat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8f49dabfaa53ce947958cc0ed2975b2c +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Enemy.prefab b/Assets/Prefabs/Enemy.prefab index 261ee99..18ca304 100644 --- a/Assets/Prefabs/Enemy.prefab +++ b/Assets/Prefabs/Enemy.prefab @@ -12,7 +12,7 @@ GameObject: - component: {fileID: 3813189644929098082} m_Layer: 0 m_Name: Enemy - m_TagString: Untagged + m_TagString: Enemy m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 diff --git a/Assets/Prefabs/PlayerMod.prefab b/Assets/Prefabs/PlayerMod.prefab new file mode 100644 index 0000000..09d3fca --- /dev/null +++ b/Assets/Prefabs/PlayerMod.prefab @@ -0,0 +1,138 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &3345171783113818284 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5264147178014863578} + - component: {fileID: 8309954331828580361} + - component: {fileID: 7594426098938812954} + m_Layer: 0 + m_Name: Model + m_TagString: PlayerMod + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5264147178014863578 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3345171783113818284} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 1} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 6262878747777363767} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &8309954331828580361 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3345171783113818284} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &7594426098938812954 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3345171783113818284} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 8f49dabfaa53ce947958cc0ed2975b2c, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!1 &7367671708397998036 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6262878747777363767} + - component: {fileID: 3305490538895218547} + m_Layer: 0 + m_Name: PlayerMod + m_TagString: PlayerMod + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6262878747777363767 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7367671708397998036} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} + m_ConstrainProportionsScale: 1 + m_Children: + - {fileID: 5264147178014863578} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &3305490538895218547 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7367671708397998036} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 29014004c04338246b2673078c5d8a52, type: 3} + m_Name: + m_EditorClassIdentifier: + m_OrbitalPosition: + m_AttachedRing: 0 + m_DistanceFromCentre: 0 + m_DistanceAlongRadius: 0 + m_ObjectRadius: 0 + m_IsAttachedToRings: 0 + m_Behaviour: {fileID: 0} + m_SpinSpeed: 0 diff --git a/Assets/Prefabs/PlayerMod.prefab.meta b/Assets/Prefabs/PlayerMod.prefab.meta new file mode 100644 index 0000000..ee70936 --- /dev/null +++ b/Assets/Prefabs/PlayerMod.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 780bf151465173e4a82da2763da54b2b +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 757a997..f3e7706 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -682,6 +682,7 @@ MonoBehaviour: m_GapDistance: 1 m_RingPrefab: {fileID: 8276642441649562681, guid: 2b69b065f2beade4d91167a23508e29e, type: 3} m_EnemyPrefab: {fileID: 345795220292517504, guid: ec4a924a38b208240b281bd7983b07b7, type: 3} + m_ModifierPrefab: {fileID: 7367671708397998036, guid: 780bf151465173e4a82da2763da54b2b, type: 3} --- !u!4 &1827131557 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/GlobalOrbitalSettings.cs b/Assets/Scripts/GlobalOrbitalSettings.cs index 893d1b8..e00c5ba 100644 --- a/Assets/Scripts/GlobalOrbitalSettings.cs +++ b/Assets/Scripts/GlobalOrbitalSettings.cs @@ -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; } diff --git a/Assets/Scripts/OrbitalPosition.cs b/Assets/Scripts/OrbitalPosition.cs index 96bf7c9..6b82229 100644 --- a/Assets/Scripts/OrbitalPosition.cs +++ b/Assets/Scripts/OrbitalPosition.cs @@ -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 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); } diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 2018369..7c902cd 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -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() diff --git a/Assets/Scripts/PlayerModifier.cs b/Assets/Scripts/PlayerModifier.cs new file mode 100644 index 0000000..ffa0791 --- /dev/null +++ b/Assets/Scripts/PlayerModifier.cs @@ -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); + } +} diff --git a/Assets/Scripts/PlayerModifier.cs.meta b/Assets/Scripts/PlayerModifier.cs.meta new file mode 100644 index 0000000..a9dce81 --- /dev/null +++ b/Assets/Scripts/PlayerModifier.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 29014004c04338246b2673078c5d8a52 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index a561668..2d219c9 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -5,6 +5,7 @@ TagManager: serializedVersion: 2 tags: - Enemy + - PlayerMod layers: - Default - TransparentFX