using UnityEngine;
using System.Collections;

public class DartMovement : MonoBehaviour {
	public bool isFacingLeft;
	public GameObject parent;
	float moveSpeed;
	
	// Use this for initialization
	void Start () {
		moveSpeed = 5.0f;
		if (isFacingLeft){
			moveSpeed *= -1;
			Vector2 temp = transform.localScale;
			transform.localScale = new Vector2(temp.x*-1, temp.y);
		}
	}
	
	// Update is called once per frame
	void Update () {
		rigidbody2D.velocity = new Vector2(moveSpeed, 0f);
	}
	
	void OnTriggerEnter2D(Collider2D body) {

		if(body.tag == "hurt stuff"){
			return;
		}

		if (body.gameObject.GetInstanceID() == parent.GetInstanceID()){
			return;
		}

		if (body.gameObject.layer == LayerMask.NameToLayer("Player")){
			DestroyObject(this.gameObject);
			// Kill player here!
		}else if (body.gameObject.layer == LayerMask.NameToLayer("Dark") ||
		body.gameObject.layer == LayerMask.NameToLayer("Light") ||
		body.gameObject.layer == LayerMask.NameToLayer("Ground")){
			// In case we want particles...
			DestroyObject(this.gameObject);
		}
		          
	}
}
