From 2a4058a9aea8ca552151dc8a5431310afaf4d8b2 Mon Sep 17 00:00:00 2001 From: jreason Date: Sun, 30 Jan 2022 17:37:26 +1100 Subject: [PATCH] forgot to push this --- Assets/Scripts/MonsterHitbox.cs | 37 ++++++++++++++++++++++++++++ Assets/Scripts/MonsterHitbox.cs.meta | 11 +++++++++ 2 files changed, 48 insertions(+) create mode 100644 Assets/Scripts/MonsterHitbox.cs create mode 100644 Assets/Scripts/MonsterHitbox.cs.meta diff --git a/Assets/Scripts/MonsterHitbox.cs b/Assets/Scripts/MonsterHitbox.cs new file mode 100644 index 0000000..b5879db --- /dev/null +++ b/Assets/Scripts/MonsterHitbox.cs @@ -0,0 +1,37 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using Variables; + +public class MonsterHitbox : MonoBehaviour, IResettable +{ + [SerializeField] + Variable m_onPlayerDeath; + + public void OnLevelLoad() + { + + } + + public void OnResetEnd() + { + gameObject.layer = LayerMask.NameToLayer("Default"); + } + + public IEnumerator OnResetStart(float time) + { + yield break; + } + + + private void OnTriggerEnter2D(Collider2D collision) + { + Debug.Log($"Collision with {collision.gameObject.name}"); + if (collision.CompareTag("Player")) + { + gameObject.layer = LayerMask.NameToLayer("Always Visible"); + m_onPlayerDeath.Value = true; + } + } + +} diff --git a/Assets/Scripts/MonsterHitbox.cs.meta b/Assets/Scripts/MonsterHitbox.cs.meta new file mode 100644 index 0000000..5748ffe --- /dev/null +++ b/Assets/Scripts/MonsterHitbox.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 90b646f898d10024c8ba725c9a7892a6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: