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

namespace Destructible2D
{
	public class bulletController : MonoBehaviour {
		private float movementSpeed = 1;
		public GameObject ExplosionPrefab;
		public GameObject FakeExplosionPrefab;
		public int FractureCount = 1;
		// Use this for initialization
		void Start () {

		}

		// Update is called once per frame
		void Update () {
			//GetComponent<Rigidbody2D>().MovePosition(GetComponent<Rigidbody2D>().position+Vector2.forward * movementSpeed * Time.deltaTime);
			//GetComponent<Rigidbody2D>().AddForce(transform.up*movementSpeed*Time.deltaTime);


		}

		void OnCollisionEnter2D(Collision2D coll)
		{
			
				var screenPoint = GetComponent<Transform> ().position;
				var screenRotation = GetComponent<Transform> ().rotation;
				var destructible = coll.gameObject.GetComponent<D2dDestructible> ();


				Destroy (this.gameObject);
				Destroy (coll.gameObject);
				if (ExplosionPrefab != null) {
					Instantiate (ExplosionPrefab, screenPoint, screenRotation);
				}


		}


	}
}
