diff --git a/Assets/Prefabs/Police.prefab b/Assets/Prefabs/Cop.prefab similarity index 96% rename from Assets/Prefabs/Police.prefab rename to Assets/Prefabs/Cop.prefab index f421215..74ca10e 100644 --- a/Assets/Prefabs/Police.prefab +++ b/Assets/Prefabs/Cop.prefab @@ -159,8 +159,11 @@ GameObject: - component: {fileID: 2029869656} - component: {fileID: 2029869655} - component: {fileID: 2029869662} + - component: {fileID: 8706587534195932413} + - component: {fileID: 2029869664} + - component: {fileID: 2029869665} m_Layer: 0 - m_Name: Police + m_Name: Cop m_TagString: Player m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -247,8 +250,46 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0a9885324a079f84c9062afea342983d, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &8706587534195932413 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8619338778009079851} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bf4133c59ea42bb41a06278bd0040cc4, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &2029869664 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8619338778009079851} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: eadfcd4e5aaab4f4186be237ae6f4367, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &2029869665 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8619338778009079851} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d06b65ffac4aeee44b540afdee5f4e98, type: 3} + m_Name: + m_EditorClassIdentifier: bullet: {fileID: 5689450973616959451, guid: a5b944ff0c1dd9b40a3a1c4365dd2ce1, type: 3} bulletTransform: {fileID: 8900475362468441194} + bulletSpeed: 10 + isShootingOn: 0 --- !u!1 &8619338778009079855 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Police.prefab.meta b/Assets/Prefabs/Cop.prefab.meta similarity index 100% rename from Assets/Prefabs/Police.prefab.meta rename to Assets/Prefabs/Cop.prefab.meta diff --git a/Assets/Prefabs/Enemy Spawner.prefab b/Assets/Prefabs/Enemy Spawner.prefab new file mode 100644 index 0000000..7793b79 --- /dev/null +++ b/Assets/Prefabs/Enemy Spawner.prefab @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6246371829720322739 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6246371829720322748} + - component: {fileID: 6246371829720322749} + - component: {fileID: 6246371829720322750} + - component: {fileID: 6246371829720322751} + m_Layer: 0 + m_Name: Enemy Spawner + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6246371829720322748 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6246371829720322739} + m_LocalRotation: {x: -0, y: 1, z: -0, w: -0.00000016292068} + m_LocalPosition: {x: 0.24, y: 0, z: 39.440132} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &6246371829720322749 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6246371829720322739} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c35afa73613ff3946be7fed53b4fa881, type: 3} + m_Name: + m_EditorClassIdentifier: + zombiePrefab: {fileID: 856601670117699726, guid: b14953694d54eea4eb66f453e525024c, type: 3} + zombieList: [] + enemysNumber: 5 + isZombieAttack: 0 +--- !u!65 &6246371829720322750 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6246371829720322739} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 6.1, y: 0.5, z: 7.8093915} + m_Center: {x: 0, y: 0, z: 0.40469575} +--- !u!114 &6246371829720322751 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6246371829720322739} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e251059c5953f8249897732bc62da839, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Prefabs/Enemy Spawner.prefab.meta b/Assets/Prefabs/Enemy Spawner.prefab.meta new file mode 100644 index 0000000..7dfb38c --- /dev/null +++ b/Assets/Prefabs/Enemy Spawner.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: f4da4732880517b4f8c1a91f4e46cc9b +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Zombie.prefab b/Assets/Prefabs/Zombie.prefab index 488d038..becac62 100644 --- a/Assets/Prefabs/Zombie.prefab +++ b/Assets/Prefabs/Zombie.prefab @@ -76,6 +76,7 @@ GameObject: - component: {fileID: 1552702606} - component: {fileID: 1552702605} - component: {fileID: 6136956654677822583} + - component: {fileID: -9185599043494665271} m_Layer: 0 m_Name: Zombie m_TagString: Untagged @@ -164,6 +165,19 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: player: {fileID: 0} + spawner: {fileID: 0} +--- !u!114 &-9185599043494665271 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 856601670117699726} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 068545d5f77a54647927a2a14a186013, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &856601670117699840 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/GameScene.unity b/Assets/Scenes/GameScene.unity index 95bc620..02a785c 100644 --- a/Assets/Scenes/GameScene.unity +++ b/Assets/Scenes/GameScene.unity @@ -219,6 +219,8 @@ GameObject: m_Component: - component: {fileID: 275367938} - component: {fileID: 275367939} + - component: {fileID: 275367940} + - component: {fileID: 275367941} m_Layer: 0 m_Name: AudioSource m_TagString: Untagged @@ -337,67 +339,125 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 ---- !u!1 &286861847 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 286861848} - - component: {fileID: 286861849} - - component: {fileID: 286861850} - m_Layer: 0 - m_Name: Zombie Spawner - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &286861848 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 286861847} - m_LocalRotation: {x: -0, y: 1, z: -0, w: -0.00000016292068} - m_LocalPosition: {x: 0.24, y: 0, z: 39.440132} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 968253941} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &286861849 +--- !u!114 &275367940 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 286861847} + m_GameObject: {fileID: 275367937} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c35afa73613ff3946be7fed53b4fa881, type: 3} + m_Script: {fileID: 11500000, guid: 3150a1b32e967d141ae9aac5c4ddbfca, type: 3} m_Name: m_EditorClassIdentifier: - zombiePrefab: {fileID: 856601670117699726, guid: b14953694d54eea4eb66f453e525024c, type: 3} - zombieList: [] - isZombieAttack: 0 ---- !u!65 &286861850 -BoxCollider: + audioSource: {fileID: 275367939} + backgroundAudio: {fileID: 275367941} + gateClip: {fileID: 8300000, guid: bc73c26acd33db94d9b0364cf657da1f, type: 3} + congratesClip: {fileID: 8300000, guid: d796b71420eabd14c90c84f26eb34f32, type: 3} + failClip: {fileID: 8300000, guid: 2524766b1871cd14abe8f46f4906557e, type: 3} + shootClip: {fileID: 8300000, guid: b3cc748c8e56877468096028fe00047b, type: 3} +--- !u!82 &275367941 +AudioSource: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 286861847} - m_Material: {fileID: 0} - m_IsTrigger: 1 + m_GameObject: {fileID: 275367937} m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 6.1, y: 0.5, z: 7.8093915} - m_Center: {x: 0, y: 0, z: 0.40469575} + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 8300000, guid: ca907e894957c5f48b7f2f77f784dd18, type: 3} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 1 + Mute: 0 + Spatialize: 0 + SpatializePostEffects: 0 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 +--- !u!4 &286861848 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + m_PrefabInstance: {fileID: 6246371829433612452} + m_PrefabAsset: {fileID: 0} --- !u!1 &335817951 GameObject: m_ObjectHideFlags: 0 @@ -425,7 +485,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 335817951} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: -1.2878588e-15, z: 58} + m_LocalPosition: {x: 0, y: -1.3100632e-15, z: 59} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -850,7 +910,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 611561436} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: -1.5099034e-15, z: 68} + m_LocalPosition: {x: 0, y: -1.5321078e-15, z: 69} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1161,6 +1221,9 @@ GameObject: - component: {fileID: 742329080} - component: {fileID: 742329082} - component: {fileID: 742329083} + - component: {fileID: 742329084} + - component: {fileID: 742329085} + - component: {fileID: 742329086} m_Layer: 0 m_Name: Player Spawner m_TagString: PlayerSpawner @@ -1209,15 +1272,47 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 871b9b2f18b18bb4bb1442bb1e27fe81, type: 3} m_Name: m_EditorClassIdentifier: - playerPrefab: {fileID: 2029869654} - playerList: - - {fileID: 2029869654} +--- !u!114 &742329084 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 742329079} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 285df824d2011f6418a6a61acaee06c8, type: 3} + m_Name: + m_EditorClassIdentifier: playerSpeed: 5 - audioSource: {fileID: 275367939} - gateClip: {fileID: 8300000, guid: bc73c26acd33db94d9b0364cf657da1f, type: 3} - congratesClip: {fileID: 8300000, guid: d796b71420eabd14c90c84f26eb34f32, type: 3} - failClip: {fileID: 8300000, guid: 2524766b1871cd14abe8f46f4906557e, type: 3} - shootClip: {fileID: 8300000, guid: b3cc748c8e56877468096028fe00047b, type: 3} + isPlayerRunning: 0 +--- !u!114 &742329085 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 742329079} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fa3e94bee9b685b4091c92c50058825c, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &742329086 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 742329079} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f5848ccac48702f4da7cd082ce29ff8b, type: 3} + m_Name: + m_EditorClassIdentifier: + copPrefab: {fileID: 2029869654} + copList: + - {fileID: 2029869654} --- !u!1 &881636661 GameObject: m_ObjectHideFlags: 0 @@ -1363,7 +1458,6 @@ GameObject: - component: {fileID: 963194227} - component: {fileID: 963194226} - component: {fileID: 963194229} - - component: {fileID: 963194230} m_Layer: 0 m_Name: Main Camera m_TagString: MainCamera @@ -1451,102 +1545,6 @@ MonoBehaviour: m_EditorClassIdentifier: player: {fileID: 742329080} offset: {x: 5.69, y: 11.23, z: -10.93} ---- !u!82 &963194230 -AudioSource: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 963194225} - m_Enabled: 1 - serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 0} - m_audioClip: {fileID: 8300000, guid: ca907e894957c5f48b7f2f77f784dd18, type: 3} - m_PlayOnAwake: 1 - m_Volume: 1 - m_Pitch: 1 - Loop: 1 - Mute: 0 - Spatialize: 0 - SpatializePostEffects: 0 - Priority: 128 - DopplerLevel: 1 - MinDistance: 1 - MaxDistance: 500 - Pan2D: 0 - rolloffMode: 0 - BypassEffects: 0 - BypassListenerEffects: 0 - BypassReverbZones: 0 - rolloffCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - - serializedVersion: 3 - time: 1 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - panLevelCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - spreadCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 0 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 - reverbZoneMixCustomCurve: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: 0 - value: 1 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0.33333334 - outWeight: 0.33333334 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 --- !u!1 &963637484 GameObject: m_ObjectHideFlags: 0 @@ -1714,9 +1712,76 @@ Transform: m_Children: - {fileID: 742329080} - {fileID: 286861848} + - {fileID: 1034361561} m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &1034361560 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 968253941} + m_Modifications: + - target: {fileID: 6246371829720322739, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_Name + value: Enemy Spawner (1) + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalPosition.x + value: 0.2 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalPosition.z + value: 55.7 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalRotation.w + value: -0.00000016292068 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalRotation.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322749, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: enemysNumber + value: 8 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} +--- !u!4 &1034361561 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + m_PrefabInstance: {fileID: 1034361560} + m_PrefabAsset: {fileID: 0} --- !u!1 &1086009404 GameObject: m_ObjectHideFlags: 0 @@ -2205,7 +2270,7 @@ PrefabInstance: m_Modifications: - target: {fileID: 8619338778009079851, guid: 47a3741b253f088469eedd6d403dd89a, type: 3} propertyPath: m_Name - value: Player + value: Cop objectReference: {fileID: 0} - target: {fileID: 8619338778009177163, guid: 47a3741b253f088469eedd6d403dd89a, type: 3} propertyPath: m_RootOrder @@ -3009,6 +3074,63 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2142333987} m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1001 &6246371829433612452 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 968253941} + m_Modifications: + - target: {fileID: 6246371829720322739, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_Name + value: Enemy Spawner + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalPosition.x + value: 0.24 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalPosition.z + value: 39.440132 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalRotation.w + value: -0.00000016292068 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalRotation.x + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalRotation.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalRotation.z + value: -0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 6246371829720322748, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: f4da4732880517b4f8c1a91f4e46cc9b, type: 3} --- !u!1001 &7322868460640539742 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Cop.meta b/Assets/Scripts/Cop.meta new file mode 100644 index 0000000..df2ff1e --- /dev/null +++ b/Assets/Scripts/Cop.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 132bf23462bf64f45b3cbb1bd87a7ed9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Cop/CopAnimation.cs b/Assets/Scripts/Cop/CopAnimation.cs new file mode 100644 index 0000000..330e966 --- /dev/null +++ b/Assets/Scripts/Cop/CopAnimation.cs @@ -0,0 +1,25 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CopAnimation : MonoBehaviour +{ + private Animator animator; + // Start is called before the first frame update + void Start() + { + animator = GetComponent(); + } + + public void StartRunningAnim() + { + animator.SetBool("isShooting", false); + animator.SetBool("isRunning", true); + } + + public void StartShootingAnim() + { + animator.SetBool("isRunning", false); + animator.SetBool("isShooting", true); + } +} diff --git a/Assets/Scripts/Player/SpawnPlayer.cs.meta b/Assets/Scripts/Cop/CopAnimation.cs.meta similarity index 83% rename from Assets/Scripts/Player/SpawnPlayer.cs.meta rename to Assets/Scripts/Cop/CopAnimation.cs.meta index 2e32a4f..c21955d 100644 --- a/Assets/Scripts/Player/SpawnPlayer.cs.meta +++ b/Assets/Scripts/Cop/CopAnimation.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 871b9b2f18b18bb4bb1442bb1e27fe81 +guid: eadfcd4e5aaab4f4186be237ae6f4367 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Cop/CopBullets.cs b/Assets/Scripts/Cop/CopBullets.cs new file mode 100644 index 0000000..1e50943 --- /dev/null +++ b/Assets/Scripts/Cop/CopBullets.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CopBullets : MonoBehaviour +{ + public GameObject bullet; + public Transform bulletTransform; + public int bulletSpeed = 10; + public bool isShootingOn = false; + + public IEnumerator Shooting() + { + while (isShootingOn) + { + Shoot(); + yield return new WaitForSeconds(1f); + } + } + private void Shoot() + { + GameObject bulletInstance = Instantiate(bullet, bulletTransform.position, Quaternion.identity); + Rigidbody rigidbody = bulletInstance.GetComponent(); + rigidbody.velocity = transform.forward * bulletSpeed; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Cop/CopBullets.cs.meta b/Assets/Scripts/Cop/CopBullets.cs.meta new file mode 100644 index 0000000..e74dbf8 --- /dev/null +++ b/Assets/Scripts/Cop/CopBullets.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d06b65ffac4aeee44b540afdee5f4e98 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Cop/CopCenterized.cs b/Assets/Scripts/Cop/CopCenterized.cs new file mode 100644 index 0000000..0e4dd3d --- /dev/null +++ b/Assets/Scripts/Cop/CopCenterized.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CopCenterized : MonoBehaviour +{ + private Transform playerSpawnerCenter; + private float goToCenter = 5f; + // Start is called before the first frame update + void Start() + { + playerSpawnerCenter = transform.parent.gameObject.transform; + } + + private void FixedUpdate() + { + transform.position = Vector3.MoveTowards(transform.position, playerSpawnerCenter.position, Time.fixedDeltaTime * goToCenter); + } +} diff --git a/Assets/Scripts/Cop/CopCenterized.cs.meta b/Assets/Scripts/Cop/CopCenterized.cs.meta new file mode 100644 index 0000000..42ad9d9 --- /dev/null +++ b/Assets/Scripts/Cop/CopCenterized.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bf4133c59ea42bb41a06278bd0040cc4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Cop/CopController.cs b/Assets/Scripts/Cop/CopController.cs new file mode 100644 index 0000000..435e0be --- /dev/null +++ b/Assets/Scripts/Cop/CopController.cs @@ -0,0 +1,28 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CopController : MonoBehaviour +{ + + private CopAnimation copAnimation; + private CopBullets copBullets; + + private void Awake() + { + copAnimation = GetComponent(); + copBullets = GetComponent(); + } + + public void StartShooting() + { + copBullets.isShootingOn = true; + StartCoroutine(copBullets.Shooting()); + copAnimation.StartShootingAnim(); + } + public void StartRunning() + { + copBullets.isShootingOn = false; + copAnimation.StartRunningAnim(); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Cop/CopController.cs.meta b/Assets/Scripts/Cop/CopController.cs.meta new file mode 100644 index 0000000..0950cc3 --- /dev/null +++ b/Assets/Scripts/Cop/CopController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0a9885324a079f84c9062afea342983d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 3afa141..eabb345 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -40,8 +40,8 @@ void Awake() public void StartGame() { menuPanel.SetActive(false); - SpawnPlayer spawnPlayer = GameObject.Find("Player Spawner").GetComponent(); - spawnPlayer.MovePlayer(); + PlayerMovement playerMovement = GameObject.Find("Player Spawner").GetComponent(); + playerMovement.MovePlayer(); } // Method to restart the game diff --git a/Assets/Scripts/Gate/GateController.cs b/Assets/Scripts/Gate/GateController.cs index bd3a3c1..6e5bbe6 100644 --- a/Assets/Scripts/Gate/GateController.cs +++ b/Assets/Scripts/Gate/GateController.cs @@ -8,16 +8,15 @@ public enum GateType { MULTIPLY, ADDITION }; public class GateController : MonoBehaviour { bool isPlayerTouchGate = true; - SpawnPlayer spawnPlayer; + PlayerSpawning playerSpawning; GateHolderController gateController; - int gateValue; + public int gateValue = 2; public GateType gateType; public TextMeshProUGUI text; // Start is called before the first frame update void Start() { - gateValue = 5; - spawnPlayer = GameObject.FindGameObjectWithTag("PlayerSpawner").GetComponent(); + playerSpawning = GameObject.Find("Player Spawner").GetComponent(); gateController = transform.parent.gameObject.GetComponent(); UpdateText(); } @@ -26,11 +25,8 @@ private void OnTriggerEnter(Collider other) if ( other.tag == "Player" && isPlayerTouchGate) { isPlayerTouchGate = false; - Debug.Log("Close The Gate"); gateController.CloseGate(); - Debug.Log("Spawn Players"); - spawnPlayer.Spawn(gateValue, gateType); - Debug.Log("Destroy"); + playerSpawning.Spawn(gateValue, gateType); Destroy(this.gameObject); } } diff --git a/Assets/Scripts/Player/PlayerController.cs b/Assets/Scripts/Player/PlayerController.cs index ce2c89f..c69fe3c 100644 --- a/Assets/Scripts/Player/PlayerController.cs +++ b/Assets/Scripts/Player/PlayerController.cs @@ -1,62 +1,80 @@ using System.Collections; using System.Collections.Generic; +using Unity.VisualScripting; using UnityEngine; public class PlayerController : MonoBehaviour { - Animator animator; - public GameObject bullet; - public Transform bulletTransform; - private Transform playerSpawnerCenter; - int bulletSpeed = 10; - float goToCenter = 5f; - bool isShootingOn = false; - - private void Awake() - { - animator = GetComponent(); - playerSpawnerCenter = transform.parent.gameObject.transform; - } - private void FixedUpdate() + // Scripts + PlayerMovement playerMovement; + PlayerRotation playerRotation; + PlayerSpawning playerSpawning; + AudioController audioController; + + void Start() { - transform.position = Vector3.MoveTowards(transform.position, playerSpawnerCenter.position, Time.fixedDeltaTime * goToCenter) ; + playerMovement = GetComponent(); + playerRotation = GetComponent(); + playerSpawning = GetComponent(); + audioController = GameObject.Find("AudioSource").GetComponent(); } - public void StartShooting() + private void OnTriggerEnter(Collider other) { - isShootingOn = true; - StartCoroutine(Shooting()); - StartShootingAnim(); + if (other.tag == "Finish") + { + playerMovement.StopPlayer(); + GameManager.Instance.ShowWinPanel(); + audioController.PlayCongratesSound(); + } } - public void StartRunning() + + public void KillCop(GameObject cop) { - isShootingOn = false; - StartRunningAnim(); + playerSpawning.RemoveFromList(cop); + DetectCopCount(); } - IEnumerator Shooting() + + private void DetectCopCount() { - while (isShootingOn) + if (playerSpawning.CopsNumber() <= 0) { - Shoot(); - yield return new WaitForSeconds(1f); + playerMovement.StopPlayer(); + GameManager.Instance.ShowFailPanel(); + audioController.PlayFailSound(); } } - private void Shoot() + + public void EnemyDetected(GameObject enemy) + { + playerMovement.StopPlayer(); + playerRotation.LookAtEnemy(enemy); + StartShooting(); + } + + public void AllZomibesKilled() { - GameObject bulletInstance = Instantiate(bullet,bulletTransform.position,Quaternion.identity); - Rigidbody rigidbody = bulletInstance.GetComponent(); - rigidbody.velocity = transform.forward * bulletSpeed; + playerRotation.LookForward(); + playerMovement.MovePlayer(); + StartRunning(); } - - public void StartRunningAnim() + + private void StartShooting() { - animator.SetBool("isShooting", false); - animator.SetBool("isRunning", true); + for(int i = 0;i < playerSpawning.CopsNumber();i++) + { + CopController cop = playerSpawning.getCop(i).GetComponent(); + cop.StartShooting(); + audioController.PlayShootingSound(); + } } - public void StartShootingAnim() + private void StartRunning() { - animator.SetBool("isRunning", false); - animator.SetBool("isShooting", true); + for (int i = 0; i < playerSpawning.CopsNumber(); i++) + { + CopController cop = playerSpawning.getCop(i).GetComponent(); + cop.StartRunning(); + } } -} +} \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerController.cs.meta b/Assets/Scripts/Player/PlayerController.cs.meta index 0950cc3..2e32a4f 100644 --- a/Assets/Scripts/Player/PlayerController.cs.meta +++ b/Assets/Scripts/Player/PlayerController.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0a9885324a079f84c9062afea342983d +guid: 871b9b2f18b18bb4bb1442bb1e27fe81 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Assets/Scripts/Player/PlayerMovement.cs b/Assets/Scripts/Player/PlayerMovement.cs index 57b1378..3daf73a 100644 --- a/Assets/Scripts/Player/PlayerMovement.cs +++ b/Assets/Scripts/Player/PlayerMovement.cs @@ -1,7 +1,6 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -using static UnityEngine.GraphicsBuffer; public class PlayerMovement : MonoBehaviour { @@ -10,24 +9,18 @@ public class PlayerMovement : MonoBehaviour float xSpeed; // Specify the maximum position on the X-axis float maxPosition = 4.10f; + public bool isPlayerRunning; - bool isPlayerRunning; - // Start is called before the first frame update - void Start() - { - - } - // Update is called once per frame void Update() { - if (isPlayerRunning) + if (isPlayerRunning == false) { return; } - PlayerMovements(); + Movements(); } - void PlayerMovements() + void Movements() { // Variable to store the horizontal touch/mouse input float touchX = 0; @@ -57,26 +50,13 @@ void PlayerMovements() transform.position = playerMovement; } - private void OnTriggerEnter(Collider other) - { - if (other.tag == "Finish") - { - isPlayerRunning = true; - } - } - - public void EnemyDetected(GameObject enemy) + public void StopPlayer() { isPlayerRunning = false; } - private void LookAtEnemy(GameObject enemy) + public void MovePlayer() { - Vector3 direction = enemy.transform.position - transform.position ; - Quaternion lookAt = Quaternion.LookRotation(direction); - lookAt.x = 0; - lookAt.z = 0; - - transform.rotation = lookAt; + isPlayerRunning = true; } } diff --git a/Assets/Scripts/Player/PlayerRotation.cs b/Assets/Scripts/Player/PlayerRotation.cs new file mode 100644 index 0000000..88805a3 --- /dev/null +++ b/Assets/Scripts/Player/PlayerRotation.cs @@ -0,0 +1,20 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerRotation : MonoBehaviour +{ + public void LookAtEnemy(GameObject enemy) + { + Vector3 direction = enemy.transform.position - transform.position; + Quaternion lookAt = Quaternion.LookRotation(direction); + lookAt.x = 0; + lookAt.z = 0; + + transform.rotation = lookAt; + } + public void LookForward() + { + transform.rotation = Quaternion.identity; + } +} diff --git a/Assets/Scripts/Player/PlayerRotation.cs.meta b/Assets/Scripts/Player/PlayerRotation.cs.meta new file mode 100644 index 0000000..b1e5649 --- /dev/null +++ b/Assets/Scripts/Player/PlayerRotation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fa3e94bee9b685b4091c92c50058825c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Player/PlayerSpawning.cs b/Assets/Scripts/Player/PlayerSpawning.cs new file mode 100644 index 0000000..d4e0541 --- /dev/null +++ b/Assets/Scripts/Player/PlayerSpawning.cs @@ -0,0 +1,62 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlayerSpawning : MonoBehaviour +{ + [SerializeField] GameObject copPrefab; + public List copList; + AudioController audioController; + + private void Start() + { + audioController = GameObject.Find("AudioSource").GetComponent(); + } + + public void Spawn(int gateValue, GateType gateType) + { + audioController.PlayGateSound(); + if (gateType == GateType.ADDITION) + { + for (int i = 0; i < gateValue; i++) + { + // Instantiate the player prefab at the specified spawn position + GameObject playerInstance = Instantiate(copPrefab, GetPlayerPosition(), Quaternion.identity, transform); + copList.Add(playerInstance); + } + } + else if (gateType == GateType.MULTIPLY) + { + int playerCount = (copList.Count * gateValue) - copList.Count; + for (int i = 0; i < playerCount; i++) + { + // Instantiate the player prefab at the specified spawn position + GameObject playerInstance = Instantiate(copPrefab, GetPlayerPosition(), Quaternion.identity, transform); + copList.Add(playerInstance); + } + } + + } + private Vector3 GetPlayerPosition() + { + Vector3 position = Random.insideUnitSphere * 0.1f; + Vector3 newPosition = position + transform.position; + return newPosition; + } + + public void RemoveFromList(GameObject cop) + { + copList.Remove(cop); + Destroy(cop); + } + + public int CopsNumber() + { + return copList.Count; + } + + public GameObject getCop(int i) + { + return copList[i]; + } +} \ No newline at end of file diff --git a/Assets/Scripts/Player/PlayerSpawning.cs.meta b/Assets/Scripts/Player/PlayerSpawning.cs.meta new file mode 100644 index 0000000..dc56803 --- /dev/null +++ b/Assets/Scripts/Player/PlayerSpawning.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f5848ccac48702f4da7cd082ce29ff8b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Player/SpawnPlayer.cs b/Assets/Scripts/Player/SpawnPlayer.cs deleted file mode 100644 index 292935b..0000000 --- a/Assets/Scripts/Player/SpawnPlayer.cs +++ /dev/null @@ -1,191 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class SpawnPlayer : MonoBehaviour -{ - [SerializeField] GameObject playerPrefab; - [SerializeField] List playerList; - [SerializeField] float playerSpeed = 5f; - // Variable to control the speed of player movement - float xSpeed; - // Specify the maximum position on the X-axis - float maxPosition = 4.10f; - public AudioSource audioSource; - public AudioClip gateClip, congratesClip, failClip, shootClip; - bool isPlayerRunning; - // Start is called before the first frame update - void Start() - { - isPlayerRunning = true; - } - // Update is called once per frame - void Update() - { - if (isPlayerRunning) - { - return; - } - PlayerMovements(); - } - - void PlayerMovements() - { - // Variable to store the horizontal touch/mouse input - float touchX = 0; - // Variable to store the resulting horizontal movement - float movementOnX = 0; - if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) - { - // Set the horizontal movement speed - xSpeed = 250; - // Get the horizontal delta position of the touch input - touchX = Input.GetTouch(0).deltaPosition.x / Screen.width; - } - else if (Input.GetMouseButton(0)) - { - // Set the horizontal movement speed - xSpeed = 500; - // Get the horizontal input axis of the mouse - touchX = Input.GetAxis("Mouse X"); - } - // Calculate the resulting horizontal movement - movementOnX = transform.position.x + xSpeed * touchX * Time.deltaTime; - // Clamp the resulting movement within the maximum position range - movementOnX = Mathf.Clamp(movementOnX, -maxPosition, maxPosition); - // Calculate the player's movement along the X-axis based on touch input or mouse input - Vector3 playerMovement = new Vector3(movementOnX, transform.position.y, transform.position.z + Time.deltaTime * playerSpeed); - // Apply the calculated movement to the player's position - transform.position = playerMovement; - } - - private void OnTriggerEnter(Collider other) - { - if (other.tag == "Finish") - { - isPlayerRunning = true; - GameManager.Instance.ShowWinPanel(); - PlayAudio(congratesClip); - StopBackgroundMusic(); - } - } - - public void EnemyDetected(GameObject enemy) - { - isPlayerRunning = true; - LookAtEnemy(enemy); - StartShooting(); - } - - private void LookAtEnemy(GameObject enemy) - { - Vector3 direction = enemy.transform.position - transform.position; - Quaternion lookAt = Quaternion.LookRotation(direction); - lookAt.x = 0; - lookAt.z = 0; - - transform.rotation = lookAt; - } - - public void Spawn(int gateValue,GateType gateType) - { - PlayAudio(gateClip); - if (gateType == GateType.ADDITION) - { - for (int i = 0; i < gateValue; i++) - { - // Instantiate the player prefab at the specified spawn position - GameObject playerInstance = Instantiate(playerPrefab, GetPlayerPosition(), Quaternion.identity, transform); - playerList.Add(playerInstance); - } - } - else if(gateType == GateType.MULTIPLY) - { - int playerCount = (playerList.Count * gateValue) - playerList.Count; - for (int i = 0; i < playerCount; i++) - { - // Instantiate the player prefab at the specified spawn position - GameObject playerInstance = Instantiate(playerPrefab, GetPlayerPosition(), Quaternion.identity, transform); - playerList.Add(playerInstance); - } - } - - } - - public void KillCop(GameObject cop) - { - playerList.Remove(cop); - Destroy(cop); - DetectCopCount(); - } - - public void AllZomibesKilled() - { - LookForward(); - MovePlayer(); - } - - private void DetectCopCount() - { - if (playerList.Count <= 0) - { - StopPlayer(); - GameManager.Instance.ShowFailPanel(); - PlayAudio(failClip); - StopBackgroundMusic(); - } - } - - private void StopPlayer() - { - isPlayerRunning = true; - } - - public void MovePlayer() - { - isPlayerRunning = false; - StartRunning(); - } - - private void LookForward() - { - transform.rotation = Quaternion.identity; - } - - private void StartShooting() - { - for(int i = 0;i < playerList.Count;i++) - { - PlayerController cop = playerList[i].GetComponent(); - cop.StartShooting(); - PlayAudio(shootClip); - } - } - private void StartRunning() - { - for (int i = 0; i < playerList.Count; i++) - { - PlayerController cop = playerList[i].GetComponent(); - cop.StartRunning(); - } - } - - public Vector3 GetPlayerPosition() - { - Vector3 position = Random.insideUnitSphere * 0.1f; - Vector3 newPosition = position + transform.position; - return newPosition; - } - - public void PlayAudio(AudioClip clip) - { - if(audioSource != null) - { - audioSource.PlayOneShot(clip,0.5f); - } - } - private void StopBackgroundMusic() - { - Camera.main.GetComponent().Stop(); - } -} diff --git a/Assets/Scripts/Utils/AudioController.cs b/Assets/Scripts/Utils/AudioController.cs new file mode 100644 index 0000000..d3eba5c --- /dev/null +++ b/Assets/Scripts/Utils/AudioController.cs @@ -0,0 +1,43 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class AudioController : MonoBehaviour +{ + public AudioSource audioSource,backgroundAudio; + public AudioClip gateClip, congratesClip, failClip, shootClip; + + public void PlayCongratesSound() + { + PlayAudio(congratesClip); + StopBackgroundMusic(); + } + + public void PlayFailSound() + { + PlayAudio(failClip); + StopBackgroundMusic(); + } + + public void PlayGateSound() + { + PlayAudio(gateClip); + } + + public void PlayShootingSound() + { + PlayAudio(shootClip); + } + + public void PlayAudio(AudioClip clip) + { + if (audioSource != null) + { + audioSource.PlayOneShot(clip, 0.5f); + } + } + private void StopBackgroundMusic() + { + backgroundAudio.Stop(); + } +} diff --git a/Assets/Scripts/Utils/AudioController.cs.meta b/Assets/Scripts/Utils/AudioController.cs.meta new file mode 100644 index 0000000..24591ab --- /dev/null +++ b/Assets/Scripts/Utils/AudioController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3150a1b32e967d141ae9aac5c4ddbfca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Utils/ObstacleController.cs b/Assets/Scripts/Utils/ObstacleController.cs index 353a77c..683f9c5 100644 --- a/Assets/Scripts/Utils/ObstacleController.cs +++ b/Assets/Scripts/Utils/ObstacleController.cs @@ -4,18 +4,18 @@ public class ObstacleController : MonoBehaviour { - SpawnPlayer SpawnPlayer; + PlayerController playerController; // Start is called before the first frame update void Start() { - SpawnPlayer = GameObject.FindGameObjectWithTag("PlayerSpawner").GetComponent(); + playerController = GameObject.Find("Player Spawner").GetComponent(); } private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { - SpawnPlayer.KillCop(other.gameObject); + playerController.KillCop(other.gameObject); } } } diff --git a/Assets/Scripts/Zombie/EnemySpawnerController.cs b/Assets/Scripts/Zombie/EnemySpawnerController.cs new file mode 100644 index 0000000..29a7dab --- /dev/null +++ b/Assets/Scripts/Zombie/EnemySpawnerController.cs @@ -0,0 +1,59 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class EnemySpawnerController : MonoBehaviour +{ + ZombieSpawner zombieSpawner; + PlayerController playerController; + + private void Start() + { + zombieSpawner = GetComponent(); + playerController = GameObject.Find("Player Spawner").GetComponent(); + } + + private void OnTriggerEnter(Collider other) + { + if (other.tag == "Player") + { + zombieSpawner.isZombieAttack = true; + playerController.EnemyDetected(gameObject); + LookAtPlayer(other.gameObject); + GetComponent().enabled = false; + } + } + + private void LookAtPlayer(GameObject target) + { + // Calculate direction from this object's position to the player's position + Vector3 direction = target.transform.position - transform.position; + + // Calculate rotation to look at the direction + Quaternion lookAtRotation = Quaternion.LookRotation(direction); + + // Set rotation for this object + transform.rotation = lookAtRotation; + } + + public void ZombieAttackTheCops(GameObject cop, GameObject zombie) + { + zombieSpawner.RemoveFromList(zombie); + CheckZombieCount(); + playerController.KillCop(cop); + } + + public void ZombieGotShoot(GameObject zombie) + { + zombieSpawner.RemoveFromList(zombie); + CheckZombieCount(); + } + + private void CheckZombieCount() + { + if (zombieSpawner.ZombieNumber() <= 0) + { + playerController.AllZomibesKilled(); + } + } +} diff --git a/Assets/Scripts/Zombie/EnemySpawnerController.cs.meta b/Assets/Scripts/Zombie/EnemySpawnerController.cs.meta new file mode 100644 index 0000000..2837408 --- /dev/null +++ b/Assets/Scripts/Zombie/EnemySpawnerController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e251059c5953f8249897732bc62da839 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Zombie/ZombieController.cs b/Assets/Scripts/Zombie/ZombieController.cs index 50d7f14..da2860e 100644 --- a/Assets/Scripts/Zombie/ZombieController.cs +++ b/Assets/Scripts/Zombie/ZombieController.cs @@ -4,34 +4,27 @@ public class ZombieController : MonoBehaviour { - public SpawnPlayer player; - public ZombieSpawner spawner; + public EnemySpawnerController controller; bool isZombieAlive; // Start is called before the first frame update void Start() { isZombieAlive = true; } - private void FixedUpdate() - { - if (spawner.isZombieAttack) - { - transform.position = Vector3.MoveTowards(transform.position, player.transform.position, Time.fixedDeltaTime * 1.5f); - } - } + private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Player" && isZombieAlive == true) { isZombieAlive = false; - spawner.ZombieAttackTheCops(cop: collision.gameObject, zombie: gameObject); + controller.ZombieAttackTheCops(cop: collision.gameObject, zombie: gameObject); } } private void OnTriggerEnter(Collider other) { if (other.tag == "Bullet") { - spawner.ZombieGotShoot(gameObject); + controller.ZombieGotShoot(gameObject); Destroy(other.gameObject); } } diff --git a/Assets/Scripts/Zombie/ZombieMovement.cs b/Assets/Scripts/Zombie/ZombieMovement.cs new file mode 100644 index 0000000..3ff9e56 --- /dev/null +++ b/Assets/Scripts/Zombie/ZombieMovement.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ZombieMovement : MonoBehaviour +{ + public PlayerController player; + public ZombieSpawner spawner; + + private void FixedUpdate() + { + if (spawner.isZombieAttack) + { + transform.position = Vector3.MoveTowards(transform.position, player.transform.position, Time.fixedDeltaTime * 1.5f); + } + } +} diff --git a/Assets/Scripts/Zombie/ZombieMovement.cs.meta b/Assets/Scripts/Zombie/ZombieMovement.cs.meta new file mode 100644 index 0000000..fc886c0 --- /dev/null +++ b/Assets/Scripts/Zombie/ZombieMovement.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 068545d5f77a54647927a2a14a186013 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Zombie/ZombieSpawner.cs b/Assets/Scripts/Zombie/ZombieSpawner.cs index 6c0194c..21e7d9f 100644 --- a/Assets/Scripts/Zombie/ZombieSpawner.cs +++ b/Assets/Scripts/Zombie/ZombieSpawner.cs @@ -6,16 +6,19 @@ public class ZombieSpawner : MonoBehaviour { [SerializeField] GameObject zombiePrefab; [SerializeField] List zombieList; - SpawnPlayer spawnPlayer; + [SerializeField] int enemysNumber = 5; + PlayerController playerController; + EnemySpawnerController controller; public bool isZombieAttack; - // Start is called before the first frame update + private void Awake() { - spawnPlayer = GameObject.Find("Player Spawner").GetComponent(); + playerController = GameObject.Find("Player Spawner").GetComponent(); + controller = GetComponent(); } void Start() { - Spawn(3); + Spawn(enemysNumber); } public void Spawn(int zombies) { @@ -24,9 +27,11 @@ public void Spawn(int zombies) Quaternion zombieAngel = Quaternion.Euler(new Vector3(0, 180, 0)); // Instantiate the player prefab at the specified spawn position GameObject zomibeInstance = Instantiate(zombiePrefab, GetZombiePosition(), zombieAngel, transform); - ZombieController zombieController = zomibeInstance.GetComponent(); - zombieController.player = spawnPlayer; - zombieController.spawner = this; + ZombieMovement zombieMovement = zomibeInstance.GetComponent(); + ZombieController zombieController = zomibeInstance.GetComponent(); + zombieController.controller = controller; + zombieMovement.player = playerController; + zombieMovement.spawner = this; zombieList.Add(zomibeInstance); } } @@ -36,49 +41,18 @@ public Vector3 GetZombiePosition() Vector3 newPosition = position + transform.position; return newPosition; } - private void OnTriggerEnter(Collider other) - { - if(other.tag == "Player") - { - isZombieAttack = true; - spawnPlayer.EnemyDetected(gameObject); - LookAtPlayer(other.gameObject); - GetComponent().enabled = false; - } - } - private void LookAtPlayer(GameObject target) - { - // Calculate direction from this object's position to the player's position - Vector3 direction = target.transform.position - transform.position; - - // Calculate rotation to look at the direction - Quaternion lookAtRotation = Quaternion.LookRotation(direction); - - // Set rotation for this object - transform.rotation = lookAtRotation; - } - - public void ZombieAttackTheCops(GameObject cop, GameObject zombie) + public void RemoveFromList(GameObject zombie) { zombieList.Remove(zombie); Destroy(zombie); - CheckZombieCount(); - spawnPlayer.KillCop(cop); } - public void ZombieGotShoot(GameObject zombie) + public int ZombieNumber() { - zombieList.Remove(zombie); - Destroy(zombie); - CheckZombieCount(); + return zombieList.Count; } - private void CheckZombieCount() - { - if(zombieList.Count <= 0) - { - spawnPlayer.AllZomibesKilled(); - } - } + } + \ No newline at end of file