diff --git a/playable/Assets/Confetti.prefab b/playable/Assets/Confetti.prefab new file mode 100644 index 0000000..e08a543 Binary files /dev/null and b/playable/Assets/Confetti.prefab differ diff --git a/playable/Assets/Confetti.prefab.meta b/playable/Assets/Confetti.prefab.meta new file mode 100644 index 0000000..86963bf --- /dev/null +++ b/playable/Assets/Confetti.prefab.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 2b7103b046272c1498dac632285c2739 +NativeFormatImporter: + userData: diff --git a/playable/Assets/Lachlan_jump_work.unity b/playable/Assets/Lachlan_jump_work.unity index e033436..612cfb3 100644 Binary files a/playable/Assets/Lachlan_jump_work.unity and b/playable/Assets/Lachlan_jump_work.unity differ diff --git a/playable/Assets/Scripts/PlayerControler.cs b/playable/Assets/Scripts/PlayerControler.cs index be7907b..e15c298 100644 --- a/playable/Assets/Scripts/PlayerControler.cs +++ b/playable/Assets/Scripts/PlayerControler.cs @@ -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 col.transform.position.y){ col.gameObject.GetComponent().health --; + Confettishoot(col.gameObject.transform.position,200.0f); //health --; rigidbody2D.velocity = jumpVector; canJump = false; diff --git a/playable/Assets/Scripts/confettiController.cs b/playable/Assets/Scripts/confettiController.cs new file mode 100644 index 0000000..df1bd4a --- /dev/null +++ b/playable/Assets/Scripts/confettiController.cs @@ -0,0 +1,59 @@ +using UnityEngine; +using System.Collections; + +public class confettiController : MonoBehaviour { + + public float lifeTime = 0.5f; + public float speed = 5; + + private float startTime; + private float startScale; + + // Use this for initialization + void Start () { + float rand = Random.Range (0, 7); + int randColour = Mathf.FloorToInt (rand); + startTime = Time.time; + startScale = transform.localScale.x; + rigidbody.velocity = Random.onUnitSphere * speed; + + switch (randColour) { + case 0: + renderer.material.color = Color.cyan; + break; + case 1: + renderer.material.color = Color.red; + break; + case 2: + renderer.material.color = Color.blue; + break; + case 3: + renderer.material.color = Color.green; + break; + case 4: + renderer.material.color = Color.yellow; + break; + case 5: + renderer.material.color = Color.magenta; + break; + default: + renderer.material.color = Color.black; + break; + } + + + + } + + // Update is called once per frame + void Update () { + float newScale = Mathf.Lerp(0, startScale, Time.deltaTime / lifeTime); + transform.localScale = new Vector3(startScale-newScale, startScale-newScale, startScale-newScale); + + if (Time.time - startTime > lifeTime) { + Destroy (gameObject, 0.0f); + } + + + } +} diff --git a/playable/Assets/Scripts/confettiController.cs.meta b/playable/Assets/Scripts/confettiController.cs.meta new file mode 100644 index 0000000..a72de43 --- /dev/null +++ b/playable/Assets/Scripts/confettiController.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cf3e4ef8e9821b74d8758c2572c02c3f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/playable/Assets/Scripts/player2_controls.cs b/playable/Assets/Scripts/player2_controls.cs index a0b5ce6..7efdbf0 100644 --- a/playable/Assets/Scripts/player2_controls.cs +++ b/playable/Assets/Scripts/player2_controls.cs @@ -18,6 +18,7 @@ public class player2_controls : MonoBehaviour { public GameObject heart; bool canJump = true; + public GameObject newConfetti; @@ -34,6 +35,9 @@ public class player2_controls : MonoBehaviour { } if (updateHealth) displayHealth (health); + + if (health == 0) + death(); if (Input.GetKey (KeyCode.W)){ if (canJump == true){ @@ -73,12 +77,30 @@ public class player2_controls : MonoBehaviour { } } + private void Confettishoot(Vector3 target,float size){ + Debug.Log ("Creating Confetti"); + + target.y += 1.5f; + for (int i = 0; i col.transform.position.y){ col.gameObject.GetComponent().health --; + Confettishoot(col.gameObject.transform.position,200.0f); + //health --; rigidbody2D.velocity = jumpVector; canJump = false;