|
|
@ -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
|
|
|
@ -31,6 +32,11 @@ public class playerController : MonoBehaviour { |
|
|
|
public float dashTime; |
|
|
|
public float dashWait; |
|
|
|
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
|
|
|
@ -48,13 +54,15 @@ public class playerController : MonoBehaviour { |
|
|
|
private float lastDash = 0.0f; |
|
|
|
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; |
|
|
|
public bool droppedCandy = false; |
|
|
|
|
|
|
|
private float volume = 1.0f; |
|
|
|
|
|
|
|
private bool exploded = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Start(){ |
|
|
@ -190,14 +198,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
|
|
|
@ -210,6 +228,7 @@ public class playerController : MonoBehaviour { |
|
|
|
heartBlack = false; |
|
|
|
dead = false; |
|
|
|
heartColor = true; |
|
|
|
exploded = false; |
|
|
|
} |
|
|
|
}//end if
|
|
|
|
|
|
|
@ -338,7 +357,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 (); |
|
|
|
} |
|
|
|