diff --git a/Space Shooter/Assets/Materials/Enemy_mat.mat b/Space Shooter/Assets/Materials/Enemy_mat.mat new file mode 100644 index 0000000..dbc058a --- /dev/null +++ b/Space Shooter/Assets/Materials/Enemy_mat.mat @@ -0,0 +1,83 @@ +%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: Enemy_mat + m_Shader: {fileID: 46, 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: + - _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: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 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: 0.8962264, g: 0.10568706, b: 0.10568706, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/Space Shooter/Assets/Materials/Enemy_mat.mat.meta b/Space Shooter/Assets/Materials/Enemy_mat.mat.meta new file mode 100644 index 0000000..2a89248 --- /dev/null +++ b/Space Shooter/Assets/Materials/Enemy_mat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6cdbf59a25f9f8c47a09e2d05fc0dcd8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Space Shooter/Assets/Materials/Laser_mat.mat b/Space Shooter/Assets/Materials/Laser_mat.mat new file mode 100644 index 0000000..edc372a --- /dev/null +++ b/Space Shooter/Assets/Materials/Laser_mat.mat @@ -0,0 +1,83 @@ +%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: Laser_mat + m_Shader: {fileID: 46, 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: + - _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: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 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: 0, g: 0.9256196, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} + m_BuildTextureStacks: [] diff --git a/Space Shooter/Assets/Materials/Laser_mat.mat.meta b/Space Shooter/Assets/Materials/Laser_mat.mat.meta new file mode 100644 index 0000000..9b81f4d --- /dev/null +++ b/Space Shooter/Assets/Materials/Laser_mat.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d8a01fe8797b7704eb231a4d76e40b61 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Space Shooter/Assets/Prefabs.meta b/Space Shooter/Assets/Prefabs.meta new file mode 100644 index 0000000..472ffad --- /dev/null +++ b/Space Shooter/Assets/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7de622937d1edcc4aabcc520288f2f91 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Space Shooter/Assets/Prefabs/Enemy.prefab b/Space Shooter/Assets/Prefabs/Enemy.prefab new file mode 100644 index 0000000..190ac75 --- /dev/null +++ b/Space Shooter/Assets/Prefabs/Enemy.prefab @@ -0,0 +1,121 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2435537520388073602 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6259941258914032746} + - component: {fileID: 6018918584238382557} + - component: {fileID: 2651467715335248648} + - component: {fileID: 6368405767543518119} + - component: {fileID: 1804272919641829641} + m_Layer: 0 + m_Name: Enemy + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6259941258914032746 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2435537520388073602} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.75, y: 0.75, z: 0.75} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &6018918584238382557 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2435537520388073602} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &2651467715335248648 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2435537520388073602} + 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: 6cdbf59a25f9f8c47a09e2d05fc0dcd8, 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 &6368405767543518119 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2435537520388073602} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 1 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &1804272919641829641 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2435537520388073602} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 00338d66c55d5a9429ada0b82e859cfb, type: 3} + m_Name: + m_EditorClassIdentifier: + speed: 4 diff --git a/Space Shooter/Assets/Prefabs/Enemy.prefab.meta b/Space Shooter/Assets/Prefabs/Enemy.prefab.meta new file mode 100644 index 0000000..ddcb091 --- /dev/null +++ b/Space Shooter/Assets/Prefabs/Enemy.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: acf5f99e370a70d429fa70f6e1d5446c +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Space Shooter/Assets/Prefabs/Laser.prefab b/Space Shooter/Assets/Prefabs/Laser.prefab new file mode 100644 index 0000000..bb50b7f --- /dev/null +++ b/Space Shooter/Assets/Prefabs/Laser.prefab @@ -0,0 +1,123 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2705647128521409060 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6667147684356053690} + - component: {fileID: 3441724675315214033} + - component: {fileID: 1972977895775938971} + - component: {fileID: 7348503523116231939} + - component: {fileID: 4222877361310449460} + m_Layer: 0 + m_Name: Laser + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6667147684356053690 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2705647128521409060} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.2, y: 0.2, z: 0.2} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &3441724675315214033 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2705647128521409060} + m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1972977895775938971 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2705647128521409060} + 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: d8a01fe8797b7704eb231a4d76e40b61, 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!136 &7348503523116231939 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2705647128521409060} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 1 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &4222877361310449460 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2705647128521409060} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f2768c56994b7484aabe727cd12cc691, type: 3} + m_Name: + m_EditorClassIdentifier: + speed: 8 diff --git a/Space Shooter/Assets/Prefabs/Laser.prefab.meta b/Space Shooter/Assets/Prefabs/Laser.prefab.meta new file mode 100644 index 0000000..23a0bb3 --- /dev/null +++ b/Space Shooter/Assets/Prefabs/Laser.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1a67b67b6874c634492ea61ed6c00de8 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Space Shooter/Assets/Scenes/Game.unity b/Space Shooter/Assets/Scenes/Game.unity index 6ff0d11..7a928ad 100644 --- a/Space Shooter/Assets/Scenes/Game.unity +++ b/Space Shooter/Assets/Scenes/Game.unity @@ -252,7 +252,7 @@ BoxCollider: serializedVersion: 2 m_Bits: 0 m_LayerOverridePriority: 0 - m_IsTrigger: 0 + m_IsTrigger: 1 m_ProvidesContacts: 0 m_Enabled: 1 serializedVersion: 3 @@ -336,6 +336,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: speed: 10 + laserPrefab: {fileID: 2705647128521409060, guid: 1a67b67b6874c634492ea61ed6c00de8, type: 3} + fireRate: 0.5 --- !u!1 &1873826075 GameObject: m_ObjectHideFlags: 0 @@ -428,3 +430,64 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &7451243589022023261 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 2435537520388073602, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_Name + value: Enemy + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_RootOrder + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6259941258914032746, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: [] + m_AddedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: acf5f99e370a70d429fa70f6e1d5446c, type: 3} diff --git a/Space Shooter/Assets/Scripts/Enemy.cs b/Space Shooter/Assets/Scripts/Enemy.cs new file mode 100644 index 0000000..f5873cd --- /dev/null +++ b/Space Shooter/Assets/Scripts/Enemy.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Enemy : MonoBehaviour +{ + [SerializeField] + private float speed = 4.0f; + + // Start is called before the first frame update + void Start() + { + + } + + // Update is called once per frame + void Update() + { + transform.Translate(Vector3.down * speed * Time.deltaTime); + + if(transform.position.y < -5f) + { + float randomX = Random.Range(-8f, 8f); + transform.position = new Vector3(randomX, 7, 0); + } + } +} diff --git a/Space Shooter/Assets/Scripts/Enemy.cs.meta b/Space Shooter/Assets/Scripts/Enemy.cs.meta new file mode 100644 index 0000000..04bcca3 --- /dev/null +++ b/Space Shooter/Assets/Scripts/Enemy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 00338d66c55d5a9429ada0b82e859cfb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Space Shooter/Assets/Scripts/Laser.cs b/Space Shooter/Assets/Scripts/Laser.cs new file mode 100644 index 0000000..9430563 --- /dev/null +++ b/Space Shooter/Assets/Scripts/Laser.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Laser : MonoBehaviour +{ + [SerializeField] + private float speed = 8.0f; + + void Update() + { + transform.Translate(Vector3.up * speed * Time.deltaTime); + + if(transform.position.y > 8.0f) + { + Destroy(gameObject); + } + } +} diff --git a/Space Shooter/Assets/Scripts/Laser.cs.meta b/Space Shooter/Assets/Scripts/Laser.cs.meta new file mode 100644 index 0000000..b55f5d5 --- /dev/null +++ b/Space Shooter/Assets/Scripts/Laser.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f2768c56994b7484aabe727cd12cc691 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Space Shooter/Assets/Scripts/Player.cs b/Space Shooter/Assets/Scripts/Player.cs index 148e070..e44fada 100644 --- a/Space Shooter/Assets/Scripts/Player.cs +++ b/Space Shooter/Assets/Scripts/Player.cs @@ -6,6 +6,11 @@ public class Player : MonoBehaviour { [SerializeField] private float speed = 1.0f; + [SerializeField] + private GameObject laserPrefab; + [SerializeField] + private float fireRate = 0.15f; + private float nextFire = -1f; void Start() { @@ -16,6 +21,20 @@ public class Player : MonoBehaviour void Update() { CalculateMovement(); + if (Input.GetButton("Fire1") && Time.time > nextFire) + { + ShootLaser(); + } + } + + private void ShootLaser() + { + //if (Input.GetKeyDown(KeyCode.Space)) + //{ + // Instantiate(laserPrefab, transform.position, Quaternion.identity); + //} + nextFire = Time.time + fireRate; + Instantiate(laserPrefab, transform.position + new Vector3(0, 0.8f, 0), Quaternion.identity); } private void CalculateMovement()