|
@ -18,8 +18,9 @@ public class playerController : MonoBehaviour { |
|
|
public GameObject scoreDisplay; |
|
|
public GameObject scoreDisplay; |
|
|
public GUIText gameOverDisplay; |
|
|
public GUIText gameOverDisplay; |
|
|
public GameObject dashDisplay; |
|
|
public GameObject dashDisplay; |
|
|
public GameObject playerFrac; |
|
|
|
|
|
|
|
|
//public GameObject playerFrac;
|
|
|
public GameObject[] hearts; |
|
|
public GameObject[] hearts; |
|
|
|
|
|
public Color playerColor; |
|
|
//public GameObject heart2;
|
|
|
//public GameObject heart2;
|
|
|
//public GameObject heart3;
|
|
|
//public GameObject heart3;
|
|
|
|
|
|
|
|
@ -65,6 +66,7 @@ public class playerController : MonoBehaviour { |
|
|
private float volume = 1.0f; |
|
|
private float volume = 1.0f; |
|
|
|
|
|
|
|
|
private bool exploded = false; |
|
|
private bool exploded = false; |
|
|
|
|
|
private bool failCheck = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -93,6 +95,10 @@ public class playerController : MonoBehaviour { |
|
|
gameOverDisplay.enabled = true; |
|
|
gameOverDisplay.enabled = true; |
|
|
gameOverDisplay.text = ""+ gameObject.name + " Wins"; |
|
|
gameOverDisplay.text = ""+ gameObject.name + " Wins"; |
|
|
Time.timeScale = 0; |
|
|
Time.timeScale = 0; |
|
|
|
|
|
if (Input.anyKeyDown){ |
|
|
|
|
|
Time.timeScale = 1.0f; |
|
|
|
|
|
Application.LoadLevel("Menu_Scene"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -165,7 +171,7 @@ public class playerController : MonoBehaviour { |
|
|
hearts[i].GetComponent<Image>().color = Color.black; |
|
|
hearts[i].GetComponent<Image>().color = Color.black; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
else hearts[i].GetComponent<Image>().color = Color.red; |
|
|
|
|
|
|
|
|
else hearts[i].GetComponent<Image>().color = playerColor; |
|
|
}//end for
|
|
|
}//end for
|
|
|
|
|
|
|
|
|
displayedHealth = health; |
|
|
displayedHealth = health; |
|
@ -190,20 +196,28 @@ public class playerController : MonoBehaviour { |
|
|
if (heartTimer >=2.5f){ |
|
|
if (heartTimer >=2.5f){ |
|
|
health = 2; |
|
|
health = 2; |
|
|
} |
|
|
} |
|
|
if (!exploded){ |
|
|
|
|
|
|
|
|
/*if (!exploded){ |
|
|
|
|
|
|
|
|
exploded = true; |
|
|
exploded = true; |
|
|
Vector3 fracRotation = transform.rotation.eulerAngles; |
|
|
Vector3 fracRotation = transform.rotation.eulerAngles; |
|
|
fracRotation.y +=90; |
|
|
fracRotation.y +=90; |
|
|
GameObject explosion = Instantiate (playerFrac, transform.position+(Vector3.up*-3), Quaternion.Euler(fracRotation)) as GameObject; |
|
|
GameObject explosion = Instantiate (playerFrac, transform.position+(Vector3.up*-3), Quaternion.Euler(fracRotation)) as GameObject; |
|
|
} |
|
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
if (deathTimer > 0) { |
|
|
if (deathTimer > 0) { |
|
|
deathTimer -= Time.deltaTime; |
|
|
deathTimer -= Time.deltaTime; |
|
|
if (!droppedCandy) { |
|
|
if (!droppedCandy) { |
|
|
|
|
|
if (!failCheck){ |
|
|
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation); |
|
|
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation); |
|
|
Debug.Log ("Exploded position: " + transform.position); |
|
|
Debug.Log ("Exploded position: " + transform.position); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
Vector3 randCandyPos = new Vector3 (Random.Range (-20.0f, 20.0f),Random.Range (-11.0f, 14.0f),0); |
|
|
|
|
|
Instantiate (newCandy, randCandyPos, transform.rotation); |
|
|
|
|
|
failCheck = false; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
droppedCandy = true; |
|
|
droppedCandy = true; |
|
|
} |
|
|
} |
|
@ -339,8 +353,13 @@ public class playerController : MonoBehaviour { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
if (col.collider.tag == "failBox") { |
|
|
if (col.collider.tag == "failBox") { |
|
|
|
|
|
failCheck = true; |
|
|
health = 0; |
|
|
health = 0; |
|
|
|
|
|
if (score > 0) |
|
|
|
|
|
|
|
|
|
|
|
scoreDisplay.GetComponent<Text>().text = "score: " + score.ToString (); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|