|
@ -30,6 +30,7 @@ public class playerController : MonoBehaviour { |
|
|
public float dashDistance; |
|
|
public float dashDistance; |
|
|
public float dashTime; |
|
|
public float dashTime; |
|
|
public float dashWait; |
|
|
public float dashWait; |
|
|
|
|
|
public float minY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private float displayedHealth = 3; //currently displayed health
|
|
|
private float displayedHealth = 3; //currently displayed health
|
|
@ -47,7 +48,7 @@ public class playerController : MonoBehaviour { |
|
|
private float lastDash = 0.0f; |
|
|
private float lastDash = 0.0f; |
|
|
private bool stopDash = false; |
|
|
private bool stopDash = false; |
|
|
public float deathTimer = 3.0f; |
|
|
public float deathTimer = 3.0f; |
|
|
|
|
|
|
|
|
|
|
|
bool droppedCandy = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -68,8 +69,8 @@ public class playerController : MonoBehaviour { |
|
|
death (); |
|
|
death (); |
|
|
applyPlayerDirection (Input.GetAxisRaw (HorizontalBtn)); |
|
|
applyPlayerDirection (Input.GetAxisRaw (HorizontalBtn)); |
|
|
damage (); |
|
|
damage (); |
|
|
if (transform.position.y < -3) |
|
|
|
|
|
health = 0; |
|
|
|
|
|
|
|
|
//if (transform.position.y < minY)
|
|
|
|
|
|
// health = 0;
|
|
|
|
|
|
|
|
|
if (score >= 10) { |
|
|
if (score >= 10) { |
|
|
gameOverDisplay.enabled = true; |
|
|
gameOverDisplay.enabled = true; |
|
@ -167,19 +168,24 @@ public class playerController : MonoBehaviour { |
|
|
if (deathTimer > 0) |
|
|
if (deathTimer > 0) |
|
|
{ |
|
|
{ |
|
|
deathTimer -=Time.deltaTime; |
|
|
deathTimer -=Time.deltaTime; |
|
|
|
|
|
if (!droppedCandy){ |
|
|
|
|
|
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation); |
|
|
|
|
|
droppedCandy = true; |
|
|
|
|
|
} |
|
|
|
|
|
transform.position = new Vector3 (0,-50,0); |
|
|
//gameObject.active = false;
|
|
|
//gameObject.active = false;
|
|
|
|
|
|
|
|
|
if(deathTimer <=0) |
|
|
if(deathTimer <=0) |
|
|
{ |
|
|
{ |
|
|
//gameObject.active = true;
|
|
|
//gameObject.active = true;
|
|
|
transform.position = new Vector3 (0,30,0); |
|
|
|
|
|
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0); //picks random position
|
|
|
Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0); //picks random position
|
|
|
health = 3; //resets life
|
|
|
health = 3; //resets life
|
|
|
transform.position = spawnPos; //changes position
|
|
|
transform.position = spawnPos; //changes position
|
|
|
rigidbody2D.velocity = Vector2.zero; |
|
|
rigidbody2D.velocity = Vector2.zero; |
|
|
deathTimer = deathTimer + 3.02f; |
|
|
deathTimer = deathTimer + 3.02f; |
|
|
|
|
|
|
|
|
|
|
|
droppedCandy = false; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}//end if
|
|
|
}//end if
|
|
@ -291,6 +297,10 @@ public class playerController : MonoBehaviour { |
|
|
stopDash = true; |
|
|
stopDash = true; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
if (col.collider.tag == "failBox") { |
|
|
|
|
|
health = 0; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void OnTriggerEnter2D(Collider2D trig) |
|
|
void OnTriggerEnter2D(Collider2D trig) |
|
|