|
|
@ -17,6 +17,7 @@ public class PlayerControler : MonoBehaviour { |
|
|
|
public GameObject bullet; |
|
|
|
public GameObject heart; |
|
|
|
bool canJump = true; |
|
|
|
public GameObject newConfetti; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -34,6 +35,9 @@ public class PlayerControler : MonoBehaviour { |
|
|
|
if (updateHealth) |
|
|
|
displayHealth (health); |
|
|
|
|
|
|
|
if (health == 0) |
|
|
|
death(); |
|
|
|
|
|
|
|
|
|
|
|
if (Input.GetKey (KeyCode.UpArrow)){ |
|
|
|
if (canJump == true){ |
|
|
@ -73,6 +77,21 @@ public class PlayerControler : MonoBehaviour { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void Confettishoot(Vector3 target,float size){ |
|
|
|
Debug.Log ("Creating Confetti"); |
|
|
|
|
|
|
|
target.y += 1.5f; |
|
|
|
for (int i = 0; i <size; i++) { |
|
|
|
Instantiate (newConfetti, target, transform.rotation); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void death(){ |
|
|
|
Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0); |
|
|
|
health = 3; |
|
|
|
transform.position = spawnPos; |
|
|
|
} |
|
|
|
|
|
|
|
void OnCollisionEnter2D(Collision2D col){ |
|
|
|
if (col.collider.tag == "ground") |
|
|
|
canJump = true; |
|
|
@ -80,6 +99,7 @@ public class PlayerControler : MonoBehaviour { |
|
|
|
canJump = true; |
|
|
|
if(transform.position.y>col.transform.position.y){ |
|
|
|
col.gameObject.GetComponent<player2_controls>().health --; |
|
|
|
Confettishoot(col.gameObject.transform.position,200.0f); |
|
|
|
//health --;
|
|
|
|
rigidbody2D.velocity = jumpVector; |
|
|
|
canJump = false; |
|
|
|