diff --git a/Assets/Images/crosshairs64.png.meta b/Assets/Images/crosshairs64.png.meta index 382eb00..2bacd05 100644 --- a/Assets/Images/crosshairs64.png.meta +++ b/Assets/Images/crosshairs64.png.meta @@ -224,7 +224,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: serializedVersion: 2 - filterMode: -1 + filterMode: 2 aniso: 2 mipBias: -100 wrapU: 1 @@ -257,7 +257,7 @@ TextureImporter: platformSettings: - serializedVersion: 3 buildTarget: DefaultTexturePlatform - maxTextureSize: 8192 + maxTextureSize: 16384 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 0 @@ -269,7 +269,7 @@ TextureImporter: forceMaximumCompressionQuality_BC6H_BC7: 0 - serializedVersion: 3 buildTarget: Standalone - maxTextureSize: 8192 + maxTextureSize: 16384 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 0 @@ -281,7 +281,7 @@ TextureImporter: forceMaximumCompressionQuality_BC6H_BC7: 0 - serializedVersion: 3 buildTarget: iPhone - maxTextureSize: 8192 + maxTextureSize: 16384 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 0 @@ -293,7 +293,7 @@ TextureImporter: forceMaximumCompressionQuality_BC6H_BC7: 0 - serializedVersion: 3 buildTarget: Android - maxTextureSize: 8192 + maxTextureSize: 16384 resizeAlgorithm: 0 textureFormat: -1 textureCompression: 0 diff --git a/Assets/Prefabs/Enemy.prefab b/Assets/Prefabs/Enemy.prefab new file mode 100644 index 0000000..c3b64b4 --- /dev/null +++ b/Assets/Prefabs/Enemy.prefab @@ -0,0 +1,139 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1738226812227614583 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1738226812227614580} + - component: {fileID: 1738226812227614581} + - component: {fileID: 1738226812227614582} + - component: {fileID: 233269787904781725} + - component: {fileID: 2766037370157449026} + - component: {fileID: 2122656558574222561} + - component: {fileID: 5433566675603670693} + m_Layer: 7 + m_Name: Enemy + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1738226812227614580 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1738226812227614583} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &1738226812227614581 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1738226812227614583} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1738226812227614582 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1738226812227614583} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + 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: a3da566b980834f66bb68c9aca77ef1d, 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!65 &233269787904781725 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1738226812227614583} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &2766037370157449026 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1738226812227614583} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d77551efeb20a4bdabb517c8351695ff, type: 3} + m_Name: + m_EditorClassIdentifier: + maxHealth: 1 +--- !u!114 &2122656558574222561 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1738226812227614583} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5b2c8b098025f4e2f997759b5c00fef7, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &5433566675603670693 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1738226812227614583} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 331122d8907f44ed9b0f8f2337d176b9, type: 3} + m_Name: + m_EditorClassIdentifier: + delayMin: 3.4 + delayMax: 3.6 diff --git a/Assets/Prefabs/Enemy.prefab.meta b/Assets/Prefabs/Enemy.prefab.meta new file mode 100644 index 0000000..8df22df --- /dev/null +++ b/Assets/Prefabs/Enemy.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8572ff9ecd10143e4926228305d8d285 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Target.prefab b/Assets/Prefabs/Target.prefab new file mode 100644 index 0000000..ba0c249 --- /dev/null +++ b/Assets/Prefabs/Target.prefab @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &3861463719128725639 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2976458840329059775} + - component: {fileID: 1878681423243367625} + - component: {fileID: 2563762367352688130} + m_Layer: 5 + m_Name: Target + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2976458840329059775 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3861463719128725639} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 960, y: 540} + m_SizeDelta: {x: 70, y: 70} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &1878681423243367625 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3861463719128725639} + m_CullTransparentMesh: 1 +--- !u!114 &2563762367352688130 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3861463719128725639} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, 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_Sprite: {fileID: 5270710134310834739, guid: 8fd3c31c95b6f42ddbe7f923aa74992e, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 diff --git a/Assets/Prefabs/Target.prefab.meta b/Assets/Prefabs/Target.prefab.meta new file mode 100644 index 0000000..4def867 --- /dev/null +++ b/Assets/Prefabs/Target.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 9129a265c1cf84274b8703ba593b266c +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/Chief's Sandbox.unity b/Assets/Scenes/Chief's Sandbox.unity index 836a05b..1f51d37 100644 --- a/Assets/Scenes/Chief's Sandbox.unity +++ b/Assets/Scenes/Chief's Sandbox.unity @@ -123,6 +123,72 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &186457103 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 186457104} + - component: {fileID: 186457106} + - component: {fileID: 186457105} + m_Layer: 0 + m_Name: EnemySpawner + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &186457104 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 186457103} + m_LocalRotation: {x: 0, y: 1, z: 0, w: 0} + m_LocalPosition: {x: 0, y: -2, z: 30} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} +--- !u!114 &186457105 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 186457103} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1226902ebd2674aefa463e6dc0e75ad7, type: 3} + m_Name: + m_EditorClassIdentifier: + bulletPool: {fileID: 1215971663} + weapon: {fileID: 11400000, guid: f2b89add65cb94ed89eaaf9af4ae8071, type: 2} + bulletPos: {fileID: 186457104} + input: {fileID: 186457106} + OnFire: + m_PersistentCalls: + m_Calls: [] + OnBulletCollide: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &186457106 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 186457103} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1e7507b4cab524d08a774a399662b3ad, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &660289115 GameObject: m_ObjectHideFlags: 0 @@ -159,7 +225,7 @@ RectTransform: m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} m_AnchoredPosition: {x: 960, y: 540} - m_SizeDelta: {x: 100, y: 100} + m_SizeDelta: {x: 150, y: 150} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &660289117 MonoBehaviour: @@ -218,6 +284,72 @@ MonoBehaviour: m_Top: 200 m_Bottom: 200 canvas: {fileID: 1942400137} +--- !u!1 &710724060 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 710724061} + - component: {fileID: 710724062} + - component: {fileID: 710724063} + m_Layer: 5 + m_Name: TargetLockPool + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &710724061 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 710724060} + 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_Children: [] + m_Father: {fileID: 1942400137} + m_RootOrder: 2 + 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: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &710724062 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 710724060} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9463c7c973b354f1c882567f52337aed, type: 3} + m_Name: + m_EditorClassIdentifier: + numObjects: 256 + prefab: {fileID: 2976458840329059775, guid: 9129a265c1cf84274b8703ba593b266c, type: 3} + numToSpawnPerFrame: 10 +--- !u!114 &710724063 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 710724060} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bffdbe5c9628347fc84123c966e47c8e, type: 3} + m_Name: + m_EditorClassIdentifier: + pool: {fileID: 710724062} + cam: {fileID: 1421772844} --- !u!1 &763784687 GameObject: m_ObjectHideFlags: 0 @@ -440,8 +572,9 @@ GameObject: - component: {fileID: 1173812005} - component: {fileID: 1173812009} - component: {fileID: 1173812010} - - component: {fileID: 1173812011} - component: {fileID: 1173812012} + - component: {fileID: 1173812013} + - component: {fileID: 1173812011} m_Layer: 6 m_Name: Player m_TagString: Untagged @@ -569,16 +702,19 @@ MonoBehaviour: m_GameObject: {fileID: 1173812004} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 1226902ebd2674aefa463e6dc0e75ad7, type: 3} + m_Script: {fileID: 11500000, guid: 916a2fb9e08e14be9bd626096bc2ac0b, type: 3} m_Name: m_EditorClassIdentifier: - bulletPool: {fileID: 1395215962} weapon: {fileID: 11400000, guid: 0b18e2c03a96a4ba3b3a76f5fddfcbdf, type: 2} + bulletPool: {fileID: 1395215962} bulletPos: {fileID: 1222495243} - input: {fileID: 1173812012} OnFire: m_PersistentCalls: m_Calls: [] + OnBulletCollide: + m_PersistentCalls: + m_Calls: [] + delayBetweenTargets: 0.05 --- !u!114 &1173812012 MonoBehaviour: m_ObjectHideFlags: 0 @@ -591,6 +727,115 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c48c9af9318404dc095b40b0731334c8, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &1173812013 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1173812004} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d3bf172892f141e5a18148a06f708cb, type: 3} + m_Name: + m_EditorClassIdentifier: + cam: {fileID: 1421772844} + cursor: {fileID: 660289116} + maxTargets: 100 + targetTime: 1 + targetSize: 1 + delay: 2 + collideWith: + serializedVersion: 2 + m_Bits: 128 + OnTargetFound: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 710724063} + m_TargetAssemblyTypeName: TargetLockIcon, Assembly-CSharp + m_MethodName: SpawnIcon + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + OnTargetLock: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 710724063} + m_TargetAssemblyTypeName: TargetLockIcon, Assembly-CSharp + m_MethodName: ClearIcons + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - m_Target: {fileID: 1173812011} + m_TargetAssemblyTypeName: FireAtTargets, Assembly-CSharp + m_MethodName: Fire + m_Mode: 0 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!1 &1215971662 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1215971664} + - component: {fileID: 1215971663} + m_Layer: 0 + m_Name: EnemyPool + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1215971663 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1215971662} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9463c7c973b354f1c882567f52337aed, type: 3} + m_Name: + m_EditorClassIdentifier: + numObjects: 3000 + prefab: {fileID: 1738226812227614580, guid: 8572ff9ecd10143e4926228305d8d285, type: 3} + numToSpawnPerFrame: 10 +--- !u!4 &1215971664 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1215971662} + 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_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1222495242 GameObject: m_ObjectHideFlags: 0 @@ -971,6 +1216,7 @@ RectTransform: m_Children: - {fileID: 660289116} - {fileID: 859797327} + - {fileID: 710724061} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/FireAtTargets.cs b/Assets/Scripts/FireAtTargets.cs new file mode 100644 index 0000000..fa94f1a --- /dev/null +++ b/Assets/Scripts/FireAtTargets.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; +using Utils; +using Weapons.Scripts; + +public class FireAtTargets : MonoBehaviour +{ + [SerializeField] private Weapon weapon; + [SerializeField] private ObjectPool bulletPool; + [SerializeField] private Transform bulletPos; + + [SerializeField] private UnityEvent OnFire; + [SerializeField] private Vector3Event OnBulletCollide; + + [SerializeField] private float delayBetweenTargets; + + private void Awake() + { + weapon = Instantiate(weapon); + weapon.Init(); + UpdateManager.OnUpdate += weapon.Update; + UpdateManager.OnFixedUpdate += weapon.FixedUpdate; + UpdateManager.OnLateUpdate += weapon.LateUpdate; + weapon.BulletCollision += BulletCollide; + } + + private void OnDestroy() + { + UpdateManager.OnUpdate -= weapon.Update; + UpdateManager.OnFixedUpdate -= weapon.FixedUpdate; + UpdateManager.OnLateUpdate -= weapon.LateUpdate; + weapon.BulletCollision -= BulletCollide; + } + + private void BulletCollide(Vector3 pos) + { + OnBulletCollide?.Invoke(pos); + } + + public void Fire(List targets) + { + FireIE(targets).Run(); + } + + private IEnumerator FireIE(List targets) + { + var currentTargets = new List(targets); + foreach (var target in currentTargets) + { + bulletPos.LookAt(target); + if (weapon.Fire(bulletPool, bulletPos)) + OnFire?.Invoke(); + + yield return delayBetweenTargets; + } + } + + private void OnDrawGizmos() + { + weapon.DrawGizmos(bulletPos); + } +} diff --git a/Assets/Scripts/FireAtTargets.cs.meta b/Assets/Scripts/FireAtTargets.cs.meta new file mode 100644 index 0000000..1d9ae46 --- /dev/null +++ b/Assets/Scripts/FireAtTargets.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 916a2fb9e08e14be9bd626096bc2ac0b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/MoveAfterDelay.cs b/Assets/Scripts/MoveAfterDelay.cs new file mode 100644 index 0000000..be51fc8 --- /dev/null +++ b/Assets/Scripts/MoveAfterDelay.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using DG.Tweening; +using UnityEngine; +using Random = UnityEngine.Random; + +public class MoveAfterDelay : MonoBehaviour +{ + [SerializeField] private float delayMin; + [SerializeField] private float delayMax; + private void OnEnable() + { + transform.DOMoveZ(-15, 2.0f).SetEase(Ease.InQuint).SetDelay(Random.Range(delayMin, delayMax)); + } +} diff --git a/Assets/Scripts/MoveAfterDelay.cs.meta b/Assets/Scripts/MoveAfterDelay.cs.meta new file mode 100644 index 0000000..617a21a --- /dev/null +++ b/Assets/Scripts/MoveAfterDelay.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 331122d8907f44ed9b0f8f2337d176b9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpawnZone.cs b/Assets/Scripts/SpawnZone.cs index e86a666..cf69ed7 100644 --- a/Assets/Scripts/SpawnZone.cs +++ b/Assets/Scripts/SpawnZone.cs @@ -223,9 +223,9 @@ namespace Weapons.Spawning Gizmos.color = color; SpawnPoly(transform, (point, dir) => { - Gizmos.DrawSphere(new Vector3(point.x, 0, point.y), 0.25f); + Gizmos.DrawSphere(transform.position + new Vector3(point.x, 0, point.y), 0.25f); if (color.a > 0.5f) - Gizmos.DrawRay(new Vector3(point.x, 0, point.y), new Vector3(dir.x, 0, dir.y)); + Gizmos.DrawRay(transform.position + new Vector3(point.x, 0, point.y), new Vector3(dir.x, 0, dir.y)); }); } diff --git a/Assets/Scripts/TargetLockIcon.cs b/Assets/Scripts/TargetLockIcon.cs new file mode 100644 index 0000000..6900b18 --- /dev/null +++ b/Assets/Scripts/TargetLockIcon.cs @@ -0,0 +1,44 @@ +using System.Collections; +using System.Collections.Generic; +using DG.Tweening; +using UnityEngine.UI; +using UnityEngine; + +public class TargetLockIcon : MonoBehaviour +{ + [SerializeField] private TransformPool pool; + [SerializeField] private Camera cam; + + private Dictionary _poolObjects = new Dictionary(); + + public void SpawnIcon (Transform obj) + { + var (icon, idx) = pool.GetObject(); + + icon.gameObject.SetActive(true); + icon.eulerAngles = new Vector3(0, 0, 45); + icon.localScale = Vector3.zero; + icon.position = RectTransformUtility.WorldToScreenPoint(cam, obj.position); + icon.GetComponent().color = Color.white; + icon.DORotate(Vector3.zero, 0.33f).SetEase(Ease.OutBack); + icon.DOScale(Vector3.one, 0.33f).SetEase(Ease.OutBack); + + _poolObjects.Add(icon, idx); + } + + public void ClearIcons() + { + foreach (var kvp in _poolObjects) + { + var delay = Random.Range(0f, 0.2f); + kvp.Key.GetComponent().DOFade(0, 0.33f).SetEase(Ease.InQuint).SetDelay(delay); + kvp.Key.DOScale(Vector3.one * 1.5f, 0.33f).SetEase(Ease.InBack).SetDelay(delay).OnComplete(() => + { + kvp.Key.gameObject.SetActive(false); + pool.ReturnObject(kvp.Key, kvp.Value); + }); + } + + _poolObjects.Clear(); + } +} diff --git a/Assets/Scripts/TargetLockIcon.cs.meta b/Assets/Scripts/TargetLockIcon.cs.meta new file mode 100644 index 0000000..a213996 --- /dev/null +++ b/Assets/Scripts/TargetLockIcon.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bffdbe5c9628347fc84123c966e47c8e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/TargetLockOn.cs b/Assets/Scripts/TargetLockOn.cs new file mode 100644 index 0000000..20333eb --- /dev/null +++ b/Assets/Scripts/TargetLockOn.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TargetLockOn : MonoBehaviour +{ + [SerializeField] private Camera cam; + + [SerializeField] private RectTransform cursor; + + [SerializeField] private int maxTargets; + + [SerializeField] private float targetTime; + + [SerializeField] private float targetSize; + + [SerializeField] private float delay; + + [SerializeField] private LayerMask collideWith; + + [SerializeField] private TransformEvent OnTargetFound; + [SerializeField] private TransformListEvent OnTargetLock; + + private float _targetCountdown; + private List _targets; + + private bool _canTarget = true; + + private RaycastHit[] _colliders = new RaycastHit[128]; + + private void Awake() + { + _targets = new List(maxTargets); + } + + private void FixedUpdate() + { + if (!_canTarget) return; + + _targetCountdown -= Time.deltaTime; + + if (_targetCountdown <= 0) + { + _targetCountdown = targetTime; + OnTargetLock?.Invoke(_targets); + _targets.Clear(); + _canTarget = false; + WaitUtils.Wait(delay, true, () => _canTarget = true); + } + + var ray = cam.ScreenPointToRay(cursor.position + Vector3.forward); + var numHits = Physics.SphereCastNonAlloc(ray, targetSize, _colliders, 50, collideWith, QueryTriggerInteraction.Collide); + + if (numHits < 0) return; + + for (int i = 0; i < numHits; i++) + { + if (_targets.Contains(_colliders[i].transform)) continue; + _targets.Add(_colliders[i].transform); + OnTargetFound?.Invoke(_colliders[i].transform); + + if (_targets.Count >= maxTargets) + break; + } + } +} diff --git a/Assets/Scripts/TargetLockOn.cs.meta b/Assets/Scripts/TargetLockOn.cs.meta new file mode 100644 index 0000000..e64b76b --- /dev/null +++ b/Assets/Scripts/TargetLockOn.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3d3bf172892f141e5a18148a06f708cb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/TransformEvent.cs b/Assets/Scripts/TransformEvent.cs new file mode 100644 index 0000000..a062eb9 --- /dev/null +++ b/Assets/Scripts/TransformEvent.cs @@ -0,0 +1,7 @@ +using System; +using UnityEngine; +using UnityEngine.Events; + +[Serializable] +public class TransformEvent : UnityEvent +{} \ No newline at end of file diff --git a/Assets/Scripts/TransformEvent.cs.meta b/Assets/Scripts/TransformEvent.cs.meta new file mode 100644 index 0000000..5158c46 --- /dev/null +++ b/Assets/Scripts/TransformEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 98f84ad589d74fcf8f1102ac1e1e00d3 +timeCreated: 1609857718 \ No newline at end of file diff --git a/Assets/Scripts/TransformListEvent.cs b/Assets/Scripts/TransformListEvent.cs new file mode 100644 index 0000000..ee8b4e4 --- /dev/null +++ b/Assets/Scripts/TransformListEvent.cs @@ -0,0 +1,8 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; + +[Serializable] +public class TransformListEvent : UnityEvent> +{} \ No newline at end of file diff --git a/Assets/Scripts/TransformListEvent.cs.meta b/Assets/Scripts/TransformListEvent.cs.meta new file mode 100644 index 0000000..33a79a9 --- /dev/null +++ b/Assets/Scripts/TransformListEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: da9989b4a9884dbc9b4ea821d14f6b4b +timeCreated: 1609857519 \ No newline at end of file diff --git a/Assets/Scripts/Vector3Event.cs b/Assets/Scripts/Vector3Event.cs index 5212c50..36da5b9 100644 --- a/Assets/Scripts/Vector3Event.cs +++ b/Assets/Scripts/Vector3Event.cs @@ -1,8 +1,11 @@ +using System; using UnityEngine; using UnityEngine.Events; namespace Weapons.Scripts { + + [Serializable] public class Vector3Event : UnityEvent {} } \ No newline at end of file diff --git a/Assets/Scripts/Weapon.cs b/Assets/Scripts/Weapon.cs index d0ddc0b..919979b 100644 --- a/Assets/Scripts/Weapon.cs +++ b/Assets/Scripts/Weapon.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; +using DG.Tweening; using Unity.Burst; using Unity.Collections; using Unity.Jobs; @@ -50,7 +51,8 @@ public class Weapon : ScriptableObject [SerializeField] private LayerMask collidesWith; [SerializeField] private float accuracy; [SerializeField] private SpawnZone zone; - + [SerializeField] private bool manualFire; + private List _bullets; private List _bulletTransforms; private static Collider[] _results = new Collider[32]; @@ -71,6 +73,7 @@ public class Weapon : ScriptableObject _job = new BulletMoveJob(); _bullets = new List(); _bulletTransforms = new List(); + _currentCooldown = fireRate; } public void Update() @@ -157,10 +160,13 @@ public class Weapon : ScriptableObject { if (_pool == null) _pool = pool; - - if (_currentCooldown < fireRate) return false; - _currentCooldown = 0; - + + if (!manualFire) + { + if (_currentCooldown < fireRate) return false; + _currentCooldown = 0; + } + SpawnBullets(position); return true; } @@ -190,7 +196,8 @@ public class Weapon : ScriptableObject // point the bullet in the right direction bullet.forward = new Vector3(dir.x, dir.y); - bullet.transform.localScale = Vector3.one * bulletSize.EvaluateMinMaxCurve(); + bullet.transform.localScale = Vector3.zero; + bullet.transform.DOScale(Vector3.one * bulletSize.EvaluateMinMaxCurve(), 0.33f).SetEase(Ease.OutQuint); if (zone.SpawnDir != SpawnDir.Spherised) { diff --git a/Assets/Weapons/Enemy.asset b/Assets/Weapons/Enemy.asset new file mode 100644 index 0000000..08bbe69 --- /dev/null +++ b/Assets/Weapons/Enemy.asset @@ -0,0 +1,122 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2bc932693ed0a470d9cf39b1c3168afb, type: 3} + m_Name: Enemy + m_EditorClassIdentifier: + fireRate: 6 + bulletSpeed: + m_Mode: 0 + m_CurveMultiplier: 1 + m_CurveMin: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_CurveMax: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_ConstantMin: 0 + m_ConstantMax: 0 + bulletLifetime: + m_Mode: 3 + m_CurveMultiplier: 0 + m_CurveMin: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_CurveMax: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_ConstantMin: 15 + m_ConstantMax: 20 + bulletSize: + m_Mode: 0 + m_CurveMultiplier: 0 + m_CurveMin: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_CurveMax: + serializedVersion: 2 + m_Curve: [] + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_ConstantMin: 0 + m_ConstantMax: 1 + damage: 1 + collidesWith: + serializedVersion: 2 + m_Bits: 64 + accuracy: 0 + zone: + numToSpawn: 1 + offset: {x: 0, y: 0} + spawnType: 2 + spawnDir: 0 + width: 0 + height: 0 + surfaceOnly: 1 + evenDistribution: 1 + numSides: 5 + numPerSide: 80 + radius: 18 + arc: 360 + composite: [] + manualFire: 0 diff --git a/Assets/Weapons/Enemy.asset.meta b/Assets/Weapons/Enemy.asset.meta new file mode 100644 index 0000000..1d1aa7e --- /dev/null +++ b/Assets/Weapons/Enemy.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f2b89add65cb94ed89eaaf9af4ae8071 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Weapons/PlayerWeapon.asset b/Assets/Weapons/PlayerWeapon.asset index afcb94e..fe91327 100644 --- a/Assets/Weapons/PlayerWeapon.asset +++ b/Assets/Weapons/PlayerWeapon.asset @@ -14,7 +14,7 @@ MonoBehaviour: m_EditorClassIdentifier: fireRate: 0.05 bulletSpeed: - m_Mode: 3 + m_Mode: 0 m_CurveMultiplier: 1 m_CurveMin: serializedVersion: 2 @@ -64,8 +64,8 @@ MonoBehaviour: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 - m_ConstantMin: 29 - m_ConstantMax: 30 + m_ConstantMin: 60 + m_ConstantMax: 60 bulletLifetime: m_Mode: 3 m_CurveMultiplier: 0 @@ -104,7 +104,7 @@ MonoBehaviour: collidesWith: serializedVersion: 2 m_Bits: 128 - accuracy: 10 + accuracy: 0 zone: numToSpawn: 1 offset: {x: 0, y: 0} @@ -115,7 +115,8 @@ MonoBehaviour: surfaceOnly: 1 evenDistribution: 1 numSides: 3 - numPerSide: 15 - radius: 1.5 + numPerSide: 5 + radius: 1.25 arc: 360 composite: [] + manualFire: 1