- using UnityEngine;
- using System.Collections;
-
- public class stickController : MonoBehaviour {
-
- public GameObject newConfetti;
-
- public bool isAttacking;
- public bool isSpinning;
-
-
- // Use this for initialization
- void Start () {
-
- }
-
- // Update is called once per frame
- void Update () {
- if (isAttacking) {
- gameObject.GetComponent<TrailRenderer> ().enabled = true;
- gameObject.GetComponent<BoxCollider2D> ().enabled = true;
- } else {
- gameObject.GetComponent<TrailRenderer> ().enabled = false;
- gameObject.GetComponent<BoxCollider2D> ().enabled = false;
- }
- }
-
- private void Confettishoot(Vector3 target,int size){ //creates confetti
- Debug.Log ("Creating Confetti");
-
- target.y += 1.5f;
- for (int i = 0; i <size; i++) {
- Instantiate (newConfetti, target, transform.rotation);
- }
- }
-
- void OnCollisionEnter2D(Collision2D col){
- if (col.collider.tag == "Player") {
- if(transform.position.y>col.transform.position.y){
- if (isAttacking){
- col.gameObject.GetComponent<playerController>().health --;
- col.gameObject.GetComponent<playerController>().isHit = true;
- Confettishoot(col.gameObject.transform.position,col.gameObject.GetComponent<playerController>().confettiOnHit);
-
- Vector2 velocity = col.rigidbody.velocity;
- velocity.y = 20;
- col.rigidbody.velocity = velocity;
- }
- }
-
- }
- }
-
-
-
-
- }
|