using UnityEngine;
using System.Collections;

public class lightningtarget : MonoBehaviour {
    public GameObject bassRef;
    public GameObject bassPlayer;
    public GameObject targetShock;
    public bool shock = false;
    public float kill = 0;
    // Use this for initialization
    void Start () {
        bassPlayer = GameObject.FindGameObjectWithTag("BassPlayer");
        targetShock = GameObject.FindGameObjectWithTag("TargetShock");
        bassRef = GameObject.FindGameObjectWithTag("BassShock");
    }

    public void BassMakeBeat() {
        shock = true;
        kill = 5;
        //Invoke("killShock", 1f);
    }

    void killShock() {
        shock = false;
    }
    // Update is called once per frame
    void Update () {
        exist();
        if(kill > 0) {
            kill--;
        } else {
            killShock();
        }
	}

    void exist() {
        if (shock) {
            transform.localScale = new Vector3(0.04f, 0.04f, 0.04f);
            bassRef = GameObject.FindGameObjectWithTag("BassShock");
            targetShock.transform.position = new Vector3(bassRef.transform.position.x, bassRef.transform.position.y, bassRef.transform.position.z);

            //if (GameObject.FindGameObjectWithTag("BassShock"))
            //{
            //    bassRef = GameObject.FindGameObjectWithTag("BassShock");
            //    transform.localPosition = new Vector3(bassRef.transform.localPosition.x, bassRef.transform.localPosition.y, bassRef.transform.localPosition.z);
            //}
            //else
            //{
            //    transform.localPosition = new Vector3(bassPlayer.transform.position.x, bassPlayer.transform.position.y, bassPlayer.transform.position.z);
            //}


        } else {
            transform.localScale = new Vector3(0, 0, 0);
        }
    }
    

}
