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

public class Bullet : MonoBehaviour {
    public float bulletSpeed;
    public float deathTimer;
    public int damage;
    public GameObject explosion;
    public bool rampSpeed;
    private Rigidbody rb;
    private float rampAmt = 0;
	// Use this for initialization
	void Start ()
    {
        rb = this.GetComponent<Rigidbody>();
        rb.velocity = new Vector3(bulletSpeed,0,0);
        Destroy(this.gameObject, deathTimer);	
	}
	
	// Update is called once per frame
	void Update ()
    {
	    if(rampSpeed==true)
        {
            rampAmt += 0.01f;
            rb.velocity += new Vector3(rampAmt, 0,0);
        }
	}

    public void OnTriggerEnter(Collider other)
    {
        if(other.tag == "Enemy")
        {
            other.gameObject.SendMessage("TakeDamage",damage);
            GameObject end = Instantiate(explosion,new Vector3(this.transform.position.x,this.transform.position.y,-1),this.transform.rotation);
            Destroy(end, 0.5f);
            //Instantiate some sort of explosion and destroy this bullet
            Destroy(this.gameObject);
        }
    }
}
