using UnityEngine;
using System.Collections;

public class ShootKnife : MonoBehaviour
{
    public float TimeToShoot = 0f;
    public GameObject OriginalKnife;
    public GameObject ShootFrom;
	// Use this for initialization
	void Start () 
    {
        TimeToShoot = Time.timeSinceLevelLoad + Random.Range(1f,3f);
	
	}
	
	// Update is called once per frame
	void Update () 
    {
        if (Time.timeSinceLevelLoad > TimeToShoot)
        {
            GameObject.FindGameObjectWithTag("ThrowSFX").GetComponent<AudioSource>().Play();
            TimeToShoot = Time.timeSinceLevelLoad + Random.Range(1f,3f);
            GameObject NewKnife = Instantiate(OriginalKnife, ShootFrom.transform.position, ShootFrom.transform.rotation) as GameObject;
            NewKnife.GetComponent<Rigidbody>().AddForce((Vector3.up * Random.Range(300f,1400f)) + (Vector3.right * 2000f));
            Destroy(NewKnife,3f);
        }
	}
}
