using UnityEngine;
using System.Collections;

using System;

public class Bullet : MonoBehaviour
{
	public Rigidbody2D m_body;
	public float m_speed, m_timeLeft = 7, m_power = 10;
	public Vector2 m_direction;
	public GameObject m_owner;

	public Bullet ()
	{
	}

	public void Awake() {
		m_body = GetComponent<Rigidbody2D> ();
	}

	public void FixedUpdate() {
		m_body.velocity = m_direction.normalized * m_speed;
		m_timeLeft -= Time.deltaTime;
		if (m_timeLeft < 0) {
			GameObject.Destroy(gameObject);
		}
	}

	public void OnBecameInvisible() {
		GameObject.Destroy (gameObject);
	}
	void OnTriggerEnter2D(Collider2D other) {
		if (other.tag.Equals("ground")) {
			GameObject.Destroy(gameObject);
		}

	}

}

