diff --git a/Assets/Scripts/Game/HatRespawn.cs b/Assets/Scripts/Game/HatRespawn.cs index 453a366..396e036 100644 --- a/Assets/Scripts/Game/HatRespawn.cs +++ b/Assets/Scripts/Game/HatRespawn.cs @@ -16,6 +16,7 @@ public class HatRespawn : MonoBehaviour { if (isDropped && Time.time - lastInteractionTime > respawnTime) { + Debug.Log("Hat has been inactive for too long. Respawning..."); RespawnHat(); } } @@ -24,6 +25,7 @@ public class HatRespawn : MonoBehaviour { if (collision.gameObject.CompareTag("Platformer Hazard")) { + Debug.Log("Hat collided with Platformer Hazard. Respawning..."); RespawnHat(); } } @@ -32,12 +34,14 @@ public class HatRespawn : MonoBehaviour { lastInteractionTime = Time.time; isDropped = false; + Debug.Log("Hat interacted with. Resetting timer."); } public void OnHatDropped() // Resets the timer when the hat is dropped { lastInteractionTime = Time.time; isDropped = true; + Debug.Log("Hat dropped. Starting respawn timer."); } private void RespawnHat() // Respawns the hat at the designated spawn position @@ -47,5 +51,6 @@ public class HatRespawn : MonoBehaviour transform.rotation = Quaternion.identity; lastInteractionTime = Time.time; // Reset the timer after respawning isDropped = false; + Debug.Log("Hat respawned at designated position."); } } diff --git a/Assets/Scripts/Player/Damageable.cs b/Assets/Scripts/Player/Damageable.cs index 4e5afcd..fc69fb0 100644 --- a/Assets/Scripts/Player/Damageable.cs +++ b/Assets/Scripts/Player/Damageable.cs @@ -40,14 +40,14 @@ public class Damageable : MonoBehaviour private void Damage(GameObject damageSource) // Damages player { - if (dying) return; + if (dying || damageSource.CompareTag("Hat")) return; // Exclude hat from taking damage float actualForce = damageSource.GetComponent().force; Block blockComponent = GetComponent(); GetComponentInChildren().DropItem(); // Drops hat if held - if (blockComponent != null && blockComponent.blocking) + if (blockComponent != null && blockComponent.blocking) { if (blockComponent.IsParrying()) // Player receives damage if punching a parrying player { @@ -106,7 +106,6 @@ public class Damageable : MonoBehaviour } } - public void HandleDeath() // Removes player from dying state after respawn { GameManager.Instance.PlayerDied(this); diff --git a/Assets/Scripts/Player/UseItem.cs b/Assets/Scripts/Player/UseItem.cs index b15f71f..45d859d 100644 --- a/Assets/Scripts/Player/UseItem.cs +++ b/Assets/Scripts/Player/UseItem.cs @@ -61,6 +61,7 @@ public class UseItem : MonoBehaviour heldItem.GetComponent().enabled = true; heldItem.GetComponent().bodyType = RigidbodyType2D.Dynamic; heldItem.transform.position += Vector3.up * 3f; + heldItem.GetComponent().OnHatDropped(); heldItem = null; isHoldingItem = false; if (GameManager.playerHoldTimes.ContainsKey(gameObject)) @@ -69,4 +70,5 @@ public class UseItem : MonoBehaviour } } } + }