using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyBulletBehavior : MonoBehaviour {

    public float direction;
    public int damage = 1;
    private Rigidbody rb;

	// Use this for initialization
	void Start () {
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update () {
        //transform.position = transform.position + new Vector3(Mathf.Cos(Mathf.Deg2Rad * direction) * .2f, 0, Mathf.Sin(Mathf.Deg2Rad * direction) * .2f);
        rb.velocity = new Vector3(Mathf.Cos(Mathf.Deg2Rad * direction), 0, Mathf.Sin(Mathf.Deg2Rad * direction)) * 1000 * Time.deltaTime;
    }

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag != "Bullet" && collision.gameObject.tag != "Enemy" && collision.gameObject.tag != "EnemyBullet" && collision.gameObject.tag != "pickup")
        {
            Destroy(gameObject);
        }
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag != "Bullet" && other.gameObject.tag != "Enemy" && other.gameObject.tag != "pickup")
        {
            Destroy(gameObject);
        }
    }
}
