diff --git a/Survival Shooter/Assets/Prefabs/Bullet.prefab b/Survival Shooter/Assets/Prefabs/Bullet.prefab index a6a42da7611e40217169d0636bb333dbcde50b0d..5f3894babddeda62e76ba2a2b1915d5ef079fcda 100644 --- a/Survival Shooter/Assets/Prefabs/Bullet.prefab +++ b/Survival Shooter/Assets/Prefabs/Bullet.prefab @@ -12,6 +12,7 @@ GameObject: - component: {fileID: 8194723548071903807} - component: {fileID: 4583758620994889822} - component: {fileID: 2690502127738053299} + - component: {fileID: -2974020695207734174} m_Layer: 0 m_Name: Bullet m_TagString: Untagged @@ -49,6 +50,7 @@ MonoBehaviour: speed: 10 damage: 20 life: 1.1 + bulletCritChance: 0 --- !u!114 &4583758620994889822 MonoBehaviour: m_ObjectHideFlags: 0 @@ -135,6 +137,102 @@ Light: m_UseViewFrustumForShadowCasterCull: 1 m_ShadowRadius: 0 m_ShadowAngle: 0 +--- !u!82 &-2974020695207734174 +AudioSource: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8946891882775703378} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 8300000, guid: f4726624026e4dc44a180953882a028d, type: 3} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + 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!1001 &1069897862498936157 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Survival Shooter/Assets/Scripts/Bullet/Bullet.cs b/Survival Shooter/Assets/Scripts/Bullet/Bullet.cs index bab5ea77c599b610c4ff185fee64235f9859320f..f33c47aa8d5e968a8495aba4357b5e2452daae19 100644 --- a/Survival Shooter/Assets/Scripts/Bullet/Bullet.cs +++ b/Survival Shooter/Assets/Scripts/Bullet/Bullet.cs @@ -23,6 +23,8 @@ public class Bullet : MonoBehaviour AudioSource critAudio; public int bulletCritChance = 0; + + bool isCrit = false; // Start is called before the first frame update void Start() { @@ -32,7 +34,7 @@ public class Bullet : MonoBehaviour newPos = transform.position; oldPos = newPos; gunAudioArr = GetComponents<AudioSource>(); - critAudio = gunAudioArr[1]; + critAudio = gunAudioArr[0]; bulletCritChance = PlayerShooting.critChance; } @@ -93,7 +95,7 @@ public class Bullet : MonoBehaviour if (enemyHealth != null) { // ... the enemy should take damage. int rand = Random.Range(0, 100); - if (rand < critChance) + if (rand < bulletCritChance) { critAudio.Play(); isCrit = true; @@ -101,12 +103,11 @@ public class Bullet : MonoBehaviour if (isCrit) { Debug.Log("Crit"); - enemyHealth.TakeDamage(damagePerShot * 2, hit.point); - + enemyHealth.TakeDamage(damage * 2, hit.point); } else { - enemyHealth.TakeDamage(damagePerShot, hit.point); + enemyHealth.TakeDamage(damage, hit.point); } } diff --git a/Survival Shooter/Assets/Scripts/Player/PlayerShooting.cs b/Survival Shooter/Assets/Scripts/Player/PlayerShooting.cs index 1ab11ab6b659c4e3dc25f4af9a0fc6da3b0103d9..9f07e7b454997a4566855a9fe0746c4f0520123f 100644 --- a/Survival Shooter/Assets/Scripts/Player/PlayerShooting.cs +++ b/Survival Shooter/Assets/Scripts/Player/PlayerShooting.cs @@ -56,7 +56,6 @@ public class PlayerShooting : MonoBehaviour void Shoot() { - bool isCrit = false; timer = 0f;