This commit is contained in:
cemt1363
2026-06-06 19:48:17 +02:00
3 changed files with 18 additions and 5 deletions
+15 -4
View File
@@ -47,7 +47,7 @@ public class DamageHandler : MonoBehaviour
{
if (fallTime >= maxFallingTime)
{
Die();
Die("fallOut");
}
fallTime += Time.deltaTime;
} else if(currentVelocity >= 0)
@@ -93,13 +93,24 @@ public class DamageHandler : MonoBehaviour
if(this.health <= 0f)
{
Die();
Die("fallDamage");
}
}
public void Die()
public void Die(String reason)
{
SceneManager.LoadScene(3, LoadSceneMode.Single);
if(reason == "hole")
{
SceneManager.LoadScene(3, LoadSceneMode.Single);
Debug.Log("Died from hole");
} else if (reason == "fallDamage")
{
Debug.Log("Died from fall damage");
} else if (reason == "fallOut")
{
Debug.Log("Fell too much");
}
Destroy(gameObject);
}
}
+3 -1
View File
@@ -6,6 +6,7 @@ public class DropletMovement : MonoBehaviour
{
private Rigidbody2D rb;
private Collider2D characterCollider;
private DamageHandler damageHandler;
// helper variables
private bool isGrounded = false;
@@ -34,7 +35,8 @@ public class DropletMovement : MonoBehaviour
{
rb = GetComponent<Rigidbody2D>();
characterCollider = GetComponent<Collider2D>();
damageHandler = GetComponent<DamageHandler>();
TreeSpawner.treeCount = 0;
}
Binary file not shown.