|
|
@ -18,6 +18,7 @@ public class playerController : MonoBehaviour { |
|
|
|
public GUIText scoreDisplay; |
|
|
|
public GUIText gameOverDisplay; |
|
|
|
public GameObject dashDisplay; |
|
|
|
public GameObject playerFrac; |
|
|
|
|
|
|
|
public float runSpeed; //run speed
|
|
|
|
public float jumpHeight; //jump height
|
|
|
@ -30,7 +31,11 @@ public class playerController : MonoBehaviour { |
|
|
|
public float dashDistance; |
|
|
|
public float dashTime; |
|
|
|
public float dashWait; |
|
|
|
public float minY; |
|
|
|
public float minY;public bool heartBlack = false; |
|
|
|
public bool heartColor = true; |
|
|
|
public bool dead = false; |
|
|
|
public float heartTimer = 0.0f; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private float displayedHealth = 3; //currently displayed health
|
|
|
@ -49,10 +54,8 @@ 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; |
|
|
|
private bool exploded = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -185,14 +188,24 @@ public class playerController : MonoBehaviour { |
|
|
|
if (heartTimer >=2.5f){ |
|
|
|
health = 2; |
|
|
|
} |
|
|
|
if (!exploded){ |
|
|
|
|
|
|
|
exploded = true; |
|
|
|
Vector3 fracRotation = transform.rotation.eulerAngles; |
|
|
|
fracRotation.y +=90; |
|
|
|
GameObject explosion = Instantiate (playerFrac, transform.position+(Vector3.up*-3), Quaternion.Euler(fracRotation)) as GameObject; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (deathTimer > 0) { |
|
|
|
deathTimer -= Time.deltaTime; |
|
|
|
if (!droppedCandy) { |
|
|
|
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation); |
|
|
|
Debug.Log ("Exploded position: " + transform.position); |
|
|
|
|
|
|
|
droppedCandy = true; |
|
|
|
} |
|
|
|
transform.position = new Vector3 (0, -50, 0); |
|
|
|
transform.position = new Vector3 (10, -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
|
|
|
@ -205,6 +218,7 @@ public class playerController : MonoBehaviour { |
|
|
|
heartBlack = false; |
|
|
|
dead = false; |
|
|
|
heartColor = true; |
|
|
|
exploded = false; |
|
|
|
} |
|
|
|
}//end if
|
|
|
|
|
|
|
@ -333,7 +347,7 @@ public class playerController : MonoBehaviour { |
|
|
|
Debug.Log (trig.gameObject.tag); |
|
|
|
if (trig.gameObject.tag == "candy") |
|
|
|
{ |
|
|
|
trig.gameObject.SetActive (false); |
|
|
|
Destroy (trig.gameObject, 0.0f); |
|
|
|
score++; |
|
|
|
scoreDisplay.text = "score: " + score.ToString (); |
|
|
|
} |
|
|
|