start scene fix
This commit is contained in:
@@ -24,10 +24,12 @@ public class DamageHandler : MonoBehaviour
|
|||||||
public AudioClip fallsound;
|
public AudioClip fallsound;
|
||||||
|
|
||||||
public AudioClip splashSound;
|
public AudioClip splashSound;
|
||||||
|
private bool isDead = false;
|
||||||
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
|
isDead = false;
|
||||||
rb = GetComponent<Rigidbody2D>();
|
rb = GetComponent<Rigidbody2D>();
|
||||||
animator = GetComponent<Animator>();
|
animator = GetComponent<Animator>();
|
||||||
}
|
}
|
||||||
@@ -39,6 +41,8 @@ public class DamageHandler : MonoBehaviour
|
|||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
{
|
{
|
||||||
|
if (isDead) return;
|
||||||
|
|
||||||
float currentVelocity = rb.linearVelocityY;
|
float currentVelocity = rb.linearVelocityY;
|
||||||
if (lastYVelocity >= 0 && currentVelocity < 0)
|
if (lastYVelocity >= 0 && currentVelocity < 0)
|
||||||
{
|
{
|
||||||
@@ -76,6 +80,8 @@ public class DamageHandler : MonoBehaviour
|
|||||||
|
|
||||||
private void OnCollisionEnter2D(Collision2D other)
|
private void OnCollisionEnter2D(Collision2D other)
|
||||||
{
|
{
|
||||||
|
if (isDead) return;
|
||||||
|
|
||||||
if(other.collider.CompareTag("Finish")){ //WIN THE GAME
|
if(other.collider.CompareTag("Finish")){ //WIN THE GAME
|
||||||
TreeSpawner.treeCount = 0;
|
TreeSpawner.treeCount = 0;
|
||||||
SceneManager.LoadScene(5, LoadSceneMode.Single);
|
SceneManager.LoadScene(5, LoadSceneMode.Single);
|
||||||
@@ -104,6 +110,8 @@ public class DamageHandler : MonoBehaviour
|
|||||||
|
|
||||||
private void OnTriggerEnter2D(Collider2D other)
|
private void OnTriggerEnter2D(Collider2D other)
|
||||||
{
|
{
|
||||||
|
if (isDead) return;
|
||||||
|
|
||||||
if (other.CompareTag("Minidrop"))
|
if (other.CompareTag("Minidrop"))
|
||||||
{
|
{
|
||||||
UpdateHealth(health + 0.2f);
|
UpdateHealth(health + 0.2f);
|
||||||
@@ -116,6 +124,8 @@ public class DamageHandler : MonoBehaviour
|
|||||||
|
|
||||||
public void UpdateHealth(float health)
|
public void UpdateHealth(float health)
|
||||||
{
|
{
|
||||||
|
if (isDead) return;
|
||||||
|
|
||||||
this.health = health;
|
this.health = health;
|
||||||
if (health > maxHealth) this.health = maxHealth;
|
if (health > maxHealth) this.health = maxHealth;
|
||||||
|
|
||||||
@@ -132,6 +142,9 @@ public class DamageHandler : MonoBehaviour
|
|||||||
|
|
||||||
public void Die(String reason)
|
public void Die(String reason)
|
||||||
{
|
{
|
||||||
|
if (isDead) return;
|
||||||
|
isDead = true;
|
||||||
|
|
||||||
TreeSpawner.treeCount = 0;
|
TreeSpawner.treeCount = 0;
|
||||||
if(reason == "hole")
|
if(reason == "hole")
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user