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

public class Wave : MonoBehaviour {

	public float speed;
	public float randMinDamage;
	public float randMaxDamage;

	public Vector3 dealDamagePoint;
	public PlayerShip playerShip;
	public Transform player;

	public bool dealtDamage = false;

	void OnEnable()
	{
		//reset the thing
		dealtDamage = false;
	}

	// Update is called once per frame
	void Update () {
		transform.position = new Vector3(transform.position.x - (speed * Time.deltaTime), transform.position.y, transform.position.z);

		if (Vector2.Distance (this.transform.position, player.transform.position) > 30f && !dealtDamage) {
			Debug.Log ("DEALT DAMAGE");
			playerShip.TakeDamage (CombatSceneManager.damageType.Hull, Random.Range (randMinDamage, randMaxDamage));
			dealtDamage = true;
		}
	}
}
