|
|
@ -43,13 +43,18 @@ public class playerController : MonoBehaviour { |
|
|
|
private bool canDash = true; |
|
|
|
private float lastDash; |
|
|
|
private bool stopDash = false; |
|
|
|
public float deathTimer = 3.0f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Start(){ |
|
|
|
if (transform.rotation.y == 180) |
|
|
|
curDirection = -1; |
|
|
|
else |
|
|
|
curDirection = 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -70,6 +75,8 @@ public class playerController : MonoBehaviour { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void FixedUpdate() { |
|
|
@ -148,15 +155,28 @@ public class playerController : MonoBehaviour { |
|
|
|
}//end displayHealth
|
|
|
|
|
|
|
|
//respawns player if they die
|
|
|
|
private void death(){ |
|
|
|
if (health <= 0) { |
|
|
|
|
|
|
|
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation); |
|
|
|
private void death() |
|
|
|
{ |
|
|
|
if (health <= 0) |
|
|
|
if (deathTimer > 0) |
|
|
|
{ |
|
|
|
deathTimer -=Time.deltaTime; |
|
|
|
//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; |
|
|
|
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation); |
|
|
|
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; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}//end if
|
|
|
|
}//end death
|
|
|
|
|
|
|
@ -181,6 +201,7 @@ public class playerController : MonoBehaviour { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
//spin
|
|
|
|
IEnumerator spinAttack(Vector3 byAngles, float inTime) { |
|
|
|
isSpinning = true; |
|
|
|
canSpin = false; |
|
|
@ -200,7 +221,7 @@ public class playerController : MonoBehaviour { |
|
|
|
isSpinning = false; |
|
|
|
stick.isAttacking = false; |
|
|
|
} |
|
|
|
|
|
|
|
//dash
|
|
|
|
IEnumerator dashAttack (float dashDistance,float dashTime) { |
|
|
|
float endPosition; |
|
|
|
int dashDirection; |
|
|
|