From ab5d734213130637e4e70b4aee646d60af673e7f Mon Sep 17 00:00:00 2001
From: Zenovore <agustinus.alexander17@gmail.com>
Date: Sat, 9 Apr 2022 18:24:58 +0700
Subject: [PATCH] fix/missing-audio

---
 Survival Shooter/Assets/Prefabs/Bullet.prefab | 98 +++++++++++++++++++
 .../Assets/Scripts/Bullet/Bullet.cs           | 11 ++-
 .../Assets/Scripts/Player/PlayerShooting.cs   |  1 -
 3 files changed, 104 insertions(+), 6 deletions(-)

diff --git a/Survival Shooter/Assets/Prefabs/Bullet.prefab b/Survival Shooter/Assets/Prefabs/Bullet.prefab
index a6a42da..5f3894b 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 bab5ea7..f33c47a 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 1ab11ab..9f07e7b 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;
 
 
-- 
GitLab