From 6f2125d2cd1607b8fb70db652607adc84fd9346c Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Fri, 22 Dec 2023 19:40:59 +0000
Subject: [PATCH] Added drilling function to player

---
 Assets/Scripts/Damageable.cs |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/Assets/Scripts/Damageable.cs b/Assets/Scripts/Damageable.cs
index b738468..6fd7016 100644
--- a/Assets/Scripts/Damageable.cs
+++ b/Assets/Scripts/Damageable.cs
@@ -1,3 +1,4 @@
+using Assets.Scripts.Enums;
 using System;
 using System.Collections;
 using System.Collections.Generic;
@@ -5,9 +6,11 @@
 
 public class Damageable : MonoBehaviour
 {
+#if (UNITY_EDITOR)
     // ONLY FOR DEBUG USE
     [SerializeField]
     private bool selfDamage = false;
+#endif
     Animator animator;
 
     [SerializeField]
@@ -20,6 +23,10 @@
     private bool isInvincible = false;
     private float timeSinceHit = 0f;
     public float invincibilityTime = 0.25f;
+
+    public SoundName hitSound;
+    public SoundName healSound;
+    public SoundName deathSound;
 
     public int MaxHealth
     {
@@ -42,6 +49,11 @@
             if (value <= 0)
             {
                 IsAlive = false;
+                // Not needed here as it's played from the Animator
+                //if (deathSound != null)
+                //{
+                SoundManager.instance.PlaySoundAtPoint(gameObject, deathSound);
+                //}
             }
         }
     }
@@ -74,10 +86,12 @@
                 timeSinceHit += Time.deltaTime;
             }
         }
+#if (UNITY_EDITOR)
         if (selfDamage)
         {
             Hit(10);
         }
+#endif
     }
 
     public void Hit(int damage)
@@ -89,6 +103,7 @@
             isInvincible = true;
 
             CharacterEvents.characterDamaged.Invoke(gameObject, actualDamageAmount);
+            SoundManager.instance.PlaySoundAtPoint(gameObject, hitSound);
         }
     }
 
@@ -103,6 +118,7 @@
             CharacterEvents.characterHealed.Invoke(gameObject, actualHealAmount);
 
             result = true;
+            SoundManager.instance.PlaySoundAtPoint(gameObject, healSound);
 
         }
         return result;

--
Gitblit v1.9.3