Hat update

This commit is contained in:
RochesterX
2025-03-17 18:20:03 -04:00
parent 153104636d
commit c9519de7f0
9 changed files with 577 additions and 490 deletions

View File

@@ -17,6 +17,8 @@ public class Damageable : MonoBehaviour
public bool dying = false;
public event System.Action<GameObject> OnPlayerPunched;
private void Start()
{
animator = GetComponent<Animator>();
@@ -46,6 +48,9 @@ public class Damageable : MonoBehaviour
float actualForce = damageSource.GetComponent<Damageable>().force;
Block blockComponent = GetComponent<Block>();
GetComponentInChildren<UseItem>().DropItem();
if (blockComponent != null && blockComponent.blocking)
{
if (blockComponent.IsParrying())
@@ -92,9 +97,10 @@ public class Damageable : MonoBehaviour
}
private void Die()
{;
{
if (GameManager.Instance != null)
{
GetComponent<UseItem>().DropItem();
animator.SetBool("die", true);
dying = true;
}

View File

@@ -6,7 +6,6 @@ using UnityEngine.InputSystem;
public class Punch : MonoBehaviour
{
public bool cancelable = true;
public static event System.Action<GameObject> OnPlayerPunched;
[SerializeField] private BoxCollider2D hurtbox;
@@ -31,7 +30,7 @@ public class Punch : MonoBehaviour
GetComponent<AnimationPlayer>().Punch();
DisableCancellation();
GetComponent<PlayerMovement>().maxSpeedOverride = 1f;
OnPlayerPunched?.Invoke(gameObject);
//OnPlayerPunched?.Invoke(gameObject);
}
public void EnableHurtbox()

View File

@@ -2,6 +2,7 @@ using UnityEngine;
public class UseItem : MonoBehaviour
{
[SerializeField] private string itemTag;
private GameObject heldItem;
private bool isHoldingItem = false;
@@ -9,13 +10,13 @@ public class UseItem : MonoBehaviour
{
if (isHoldingItem)
{
heldItem.transform.position = transform.position;
heldItem.transform.position = transform.position + Vector3.up;
}
}
private void OnTriggerEnter2D(Collider2D collision)
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.CompareTag("Item") && !isHoldingItem)
if (collision.gameObject.CompareTag("Hat") && !isHoldingItem)
{
PickUpItem(collision.gameObject);
}
@@ -26,6 +27,8 @@ public class UseItem : MonoBehaviour
heldItem = item;
isHoldingItem = true;
item.GetComponent<Collider2D>().enabled = false;
item.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Static;
item.transform.rotation = Quaternion.identity;
}
public void DropItem()
@@ -33,6 +36,7 @@ public class UseItem : MonoBehaviour
if (isHoldingItem)
{
heldItem.GetComponent<Collider2D>().enabled = true;
heldItem.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
heldItem = null;
isHoldingItem = false;
}
@@ -40,19 +44,19 @@ public class UseItem : MonoBehaviour
private void OnEnable()
{
Punch.OnPlayerPunched += HandlePlayerPunched;
//Punch.OnPlayerPunched += HandlePlayerPunched;
}
private void OnDisable()
{
Punch.OnPlayerPunched -= HandlePlayerPunched;
//Punch.OnPlayerPunched -= HandlePlayerPunched;
}
/*
private void HandlePlayerPunched(GameObject punchedPlayer)
{
if (punchedPlayer == gameObject)
{
DropItem();
}
}
}*/
}