You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.3 KiB

  1. using UnityEngine;
  2. using System.Collections;
  3. public class stickController : MonoBehaviour {
  4. public GameObject newConfetti;
  5. public bool isAttacking;
  6. public bool isSpinning;
  7. // Use this for initialization
  8. void Start () {
  9. }
  10. // Update is called once per frame
  11. void Update () {
  12. if (isAttacking) {
  13. gameObject.GetComponent<TrailRenderer> ().enabled = true;
  14. gameObject.GetComponent<BoxCollider2D> ().enabled = true;
  15. } else {
  16. gameObject.GetComponent<TrailRenderer> ().enabled = false;
  17. gameObject.GetComponent<BoxCollider2D> ().enabled = false;
  18. }
  19. }
  20. private void Confettishoot(Vector3 target,int size){ //creates confetti
  21. Debug.Log ("Creating Confetti");
  22. target.y += 1.5f;
  23. for (int i = 0; i <size; i++) {
  24. Instantiate (newConfetti, target, transform.rotation);
  25. }
  26. }
  27. void OnCollisionEnter2D(Collision2D col){
  28. if (col.collider.tag == "Player") {
  29. if(transform.position.y>col.transform.position.y){
  30. if (isAttacking){
  31. col.gameObject.GetComponent<playerController>().health --;
  32. col.gameObject.GetComponent<playerController>().isHit = true;
  33. Confettishoot(col.gameObject.transform.position,col.gameObject.GetComponent<playerController>().confettiOnHit);
  34. Vector2 velocity = col.rigidbody.velocity;
  35. velocity.y = 20;
  36. col.rigidbody.velocity = velocity;
  37. }
  38. }
  39. }
  40. }
  41. }