Hat remains on winner
This commit is contained in:
@@ -74,6 +74,8 @@ public class Damageable : MonoBehaviour
|
||||
|
||||
public void Damage(float damage) // Adds damage to player when hit
|
||||
{
|
||||
if (GameManager.Instance.gameOver) return; // Prevent damage after game is over
|
||||
|
||||
this.damage += damage;
|
||||
if (damage >= maxDamage)
|
||||
{
|
||||
@@ -94,7 +96,7 @@ public class Damageable : MonoBehaviour
|
||||
|
||||
private void Die() // Triggers death animation and sets player to dying state
|
||||
{
|
||||
if (GameManager.Instance != null)
|
||||
if (GameManager.Instance != null && !GameManager.Instance.gameOver) // Prevent death after game is over
|
||||
{
|
||||
UseItem useItem = GetComponent<UseItem>();
|
||||
if (useItem != null)
|
||||
|
||||
@@ -10,7 +10,7 @@ public class UseItem : MonoBehaviour
|
||||
public float holdTime;
|
||||
private Damageable damageable;
|
||||
|
||||
[SerializeField] private Transform head;
|
||||
[SerializeField] public Transform head;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -58,10 +58,13 @@ public class UseItem : MonoBehaviour
|
||||
{
|
||||
GameManager.playerHoldTimes[gameObject] = 0f;
|
||||
}
|
||||
GameManager.Instance.StopCoroutine("MoveHatToWinner");
|
||||
}
|
||||
|
||||
public void DropItem() // Player drops hat when hit
|
||||
{
|
||||
if (GameManager.Instance.gameOver) return; // Prevent dropping items if the game is over
|
||||
|
||||
if (isHoldingItem)
|
||||
{
|
||||
heldItem.GetComponent<Collider2D>().enabled = true;
|
||||
@@ -70,7 +73,6 @@ public class UseItem : MonoBehaviour
|
||||
heldItem.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;
|
||||
heldItem.GetComponent<Rigidbody2D>().AddForce(Vector2.up * Random.Range(10f, 30f) + Vector2.right * Random.Range(-10, 10), ForceMode2D.Impulse);
|
||||
heldItem.GetComponent<Rigidbody2D>().AddTorque(Random.Range(-5, 5), ForceMode2D.Impulse);
|
||||
//heldItem.transform.position += Vector3.up * 3f;
|
||||
heldItem.GetComponent<HatRespawn>().OnHatDropped();
|
||||
heldItem.transform.parent = GameManager.Instance.transform;
|
||||
heldItem = null;
|
||||
@@ -87,4 +89,9 @@ public class UseItem : MonoBehaviour
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
HatRespawn.canBePickedUp = true;
|
||||
}
|
||||
|
||||
public bool IsHoldingItem()
|
||||
{
|
||||
return isHoldingItem;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user