diff --git a/playable/Assets/Scripts/playerController.cs b/playable/Assets/Scripts/playerController.cs index 081c336..d643c2d 100644 --- a/playable/Assets/Scripts/playerController.cs +++ b/playable/Assets/Scripts/playerController.cs @@ -31,11 +31,6 @@ public class playerController : MonoBehaviour { public float dashTime; public float dashWait; public float minY; - public float deathTimer = 3.0f; - public Vector3 respawnArea; - public Vector2 randRes; - - private float displayedHealth = 3; //currently displayed health @@ -52,9 +47,12 @@ public class playerController : MonoBehaviour { private bool canDash = true; private float lastDash = 0.0f; private bool stopDash = false; - private bool droppedCandy = 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; @@ -157,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; @@ -169,35 +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 - Vector3 spawnPos = respawnArea; - spawnPos.x = Random.Range(randRes.x,randRes.y); - 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) {