|
|
@ -49,7 +49,10 @@ public class playerController : MonoBehaviour { |
|
|
|
private bool stopDash = false; |
|
|
|
public float deathTimer = 3.0f; |
|
|
|
bool droppedCandy = false; |
|
|
|
|
|
|
|
public bool heartBlack = false; |
|
|
|
public bool heartColor = true; |
|
|
|
public bool dead = false; |
|
|
|
public float heartTimer = 0.0f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -152,6 +155,12 @@ public class playerController : MonoBehaviour { |
|
|
|
|
|
|
|
heartCanister.transform.position = heartPos; |
|
|
|
hearts.Add(heartCanister); //adds heart to list
|
|
|
|
|
|
|
|
if (heartBlack == true && heartColor == false){ |
|
|
|
heartCanister.guiTexture.color = Color.black; |
|
|
|
|
|
|
|
//else (heartCanister.guiTexture.color = Color.red);
|
|
|
|
} |
|
|
|
}//end for
|
|
|
|
|
|
|
|
displayedHealth = health; |
|
|
@ -164,32 +173,48 @@ public class playerController : MonoBehaviour { |
|
|
|
|
|
|
|
private void death() |
|
|
|
{ |
|
|
|
if (health <= 0) |
|
|
|
if (deathTimer > 0) |
|
|
|
{ |
|
|
|
deathTimer -=Time.deltaTime; |
|
|
|
if (!droppedCandy){ |
|
|
|
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation); |
|
|
|
droppedCandy = true; |
|
|
|
if (health <= 0|| dead ==true) { |
|
|
|
dead = true; |
|
|
|
if (dead == true){ |
|
|
|
heartColor = false; |
|
|
|
heartBlack = true; |
|
|
|
heartTimer += Time.deltaTime; |
|
|
|
if (heartTimer >=1.5f){ |
|
|
|
health = 1; |
|
|
|
} |
|
|
|
if (heartTimer >=2.5f){ |
|
|
|
health = 2; |
|
|
|
} |
|
|
|
} |
|
|
|
transform.position = new Vector3 (0,-50,0); |
|
|
|
//gameObject.active = false;
|
|
|
|
|
|
|
|
if(deathTimer <=0) |
|
|
|
{ |
|
|
|
//gameObject.active = true;
|
|
|
|
|
|
|
|
|
|
|
|
Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0); //picks random position
|
|
|
|
health = 3; //resets life
|
|
|
|
transform.position = spawnPos; //changes position
|
|
|
|
rigidbody2D.velocity = Vector2.zero; |
|
|
|
deathTimer = deathTimer + 3.02f; |
|
|
|
droppedCandy = false; |
|
|
|
|
|
|
|
} |
|
|
|
}//end if
|
|
|
|
}//end death
|
|
|
|
if (deathTimer > 0) { |
|
|
|
deathTimer -= Time.deltaTime; |
|
|
|
if (!droppedCandy) { |
|
|
|
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation); |
|
|
|
droppedCandy = true; |
|
|
|
} |
|
|
|
transform.position = new Vector3 (0, -50, 0); |
|
|
|
if (deathTimer <= 0) { |
|
|
|
Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0); //picks random position
|
|
|
|
health = 3; //resets life
|
|
|
|
|
|
|
|
transform.position = spawnPos; //changes position
|
|
|
|
rigidbody2D.velocity = Vector2.zero; |
|
|
|
deathTimer = deathTimer + 3.02f; |
|
|
|
heartTimer = heartTimer - 3.00f; |
|
|
|
droppedCandy = false; |
|
|
|
heartBlack = false; |
|
|
|
dead = false; |
|
|
|
heartColor = true; |
|
|
|
} |
|
|
|
}//end if
|
|
|
|
|
|
|
|
|
|
|
|
/*else if (hearts <= 0) { |
|
|
|
dead = true; |
|
|
|
}*/ |
|
|
|
|
|
|
|
}//end death
|
|
|
|
} |
|
|
|
|
|
|
|
private void applyPlayerDirection(float moveHorizontal) |
|
|
|
{ |
|
|
|