From 232e5d4ef29bcbe906cb4a41fb6a45ecc49d963b Mon Sep 17 00:00:00 2001 From: rowan Date: Sat, 2 Aug 2025 14:34:29 -0400 Subject: [PATCH] closes #21; closes #17 --- .../Rendering/Shaders/DitherLit.shadergraph | 10 +++--- Assets/SOAP/UI/Modal.asset | 2 ++ Assets/Scripts/Entity/Damage.cs | 35 +++++++++++++++++++ Assets/Scripts/Entity/Damage.cs.meta | 2 ++ Assets/Scripts/Entity/Health.cs | 29 +++++++++++++++ Assets/Scripts/Entity/Health.cs.meta | 2 ++ 6 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 Assets/Scripts/Entity/Damage.cs create mode 100644 Assets/Scripts/Entity/Damage.cs.meta create mode 100644 Assets/Scripts/Entity/Health.cs create mode 100644 Assets/Scripts/Entity/Health.cs.meta diff --git a/Assets/Rendering/Shaders/DitherLit.shadergraph b/Assets/Rendering/Shaders/DitherLit.shadergraph index f2ca059..078c74d 100644 --- a/Assets/Rendering/Shaders/DitherLit.shadergraph +++ b/Assets/Rendering/Shaders/DitherLit.shadergraph @@ -544,19 +544,19 @@ "m_Id": "47997da48bb54307bd066561ed772527" }, { - "m_Id": "756712fba89b49808c6efdb2ddb6ec7a" + "m_Id": "267a20c0dea74203b5b23029fb2e17d1" }, { - "m_Id": "267a20c0dea74203b5b23029fb2e17d1" + "m_Id": "756712fba89b49808c6efdb2ddb6ec7a" }, { "m_Id": "dc227ad12736457ba893aa6ad1ce41c2" }, { - "m_Id": "1cd72896bd914789b0cc4cc80af0850a" + "m_Id": "00311e469f6f45aba1d2c5b2198478a0" }, { - "m_Id": "00311e469f6f45aba1d2c5b2198478a0" + "m_Id": "1cd72896bd914789b0cc4cc80af0850a" }, { "m_Id": "fa82e18ce46142d894bf50fc0df8a612" @@ -3055,7 +3055,7 @@ }, "m_Name": "Parallax Mapping", "m_DrawState": { - "m_Expanded": true, + "m_Expanded": false, "m_Position": { "serializedVersion": "2", "x": -1269.0001220703125, diff --git a/Assets/SOAP/UI/Modal.asset b/Assets/SOAP/UI/Modal.asset index 67464f8..a187d12 100644 --- a/Assets/SOAP/UI/Modal.asset +++ b/Assets/SOAP/UI/Modal.asset @@ -18,5 +18,7 @@ MonoBehaviour: effect: {fileID: 11400000, guid: 0902dc21238be2bb3ae758e1d5218922, type: 2} - uiEvent: 1 effect: {fileID: 11400000, guid: fd3397ffea6cbccc5992ef2e70a2ed44, type: 2} + headerId: header titleId: title + bodyId: body contentId: content diff --git a/Assets/Scripts/Entity/Damage.cs b/Assets/Scripts/Entity/Damage.cs new file mode 100644 index 0000000..ea5de55 --- /dev/null +++ b/Assets/Scripts/Entity/Damage.cs @@ -0,0 +1,35 @@ +using KitsuneCafe.System; +using UnityEngine; + +namespace KitsuneCafe.Entity +{ + public interface IDamaging : IGameObject + { + void ApplyDamage(int amount, IDamageable target); + } + + public interface IDamageable : IGameObject + { + void ReceiveDamage(IDamaging source, int amount); + } + + + public class DamageSource : MonoBehaviour, IDamaging + { + [SerializeField] + private int damage; + + public void ApplyDamage(int amount, IDamageable target) + { + target.ReceiveDamage(this, amount); + } + + public void ApplyDamage(int amount, GameObject target) + { + if (target.TryGetComponent(out IDamageable damageable)) + { + ApplyDamage(amount, damageable); + } + } + } +} diff --git a/Assets/Scripts/Entity/Damage.cs.meta b/Assets/Scripts/Entity/Damage.cs.meta new file mode 100644 index 0000000..aff14b6 --- /dev/null +++ b/Assets/Scripts/Entity/Damage.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 5ac53e30c2f9ed3d48e3ed86a8aed11b \ No newline at end of file diff --git a/Assets/Scripts/Entity/Health.cs b/Assets/Scripts/Entity/Health.cs new file mode 100644 index 0000000..b281189 --- /dev/null +++ b/Assets/Scripts/Entity/Health.cs @@ -0,0 +1,29 @@ +using System; +using R3; +using UnityEngine; + +namespace KitsuneCafe.Entity +{ + public class Health : MonoBehaviour, IDamageable + { + [SerializeField] + private SerializableReactiveProperty max; + + public int Max => max.CurrentValue; + + [SerializeField] + private SerializableReactiveProperty current; + + public int Current => current.CurrentValue; + + public void Recover(int amount) + { + this.current.Value = Math.Clamp(this.Current + amount, 0, this.Max); + } + + public void ReceiveDamage(IDamaging source, int amount) + { + this.current.Value = Math.Clamp(this.Current - amount, 0, this.Max); + } + } +} diff --git a/Assets/Scripts/Entity/Health.cs.meta b/Assets/Scripts/Entity/Health.cs.meta new file mode 100644 index 0000000..4e5874e --- /dev/null +++ b/Assets/Scripts/Entity/Health.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 6bf44a57a6a836c249eac8ba9521ce64 \ No newline at end of file