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

public class DeathWave : MonoBehaviour {

	public GameObject player;

	public float START_SPEED;

	public float SPEED_INCREASE_PER_LEVEL = 1.05f;

	// Use this for initialization
	void Start() {
		START_SPEED = player.GetComponent<PlayerController>().MAX_SPEED * 0.8f;
	}

	// Update is called once per frame
	void Update() {
		transform.position = Vector3.MoveTowards(transform.position, player.transform.position, START_SPEED * Time.deltaTime);
	}

	public void increaseSpeed() {
		START_SPEED *= SPEED_INCREASE_PER_LEVEL;
	}

	void OnCollisionEnter(Collision col) {
		if (col.gameObject.tag == "Player") {
			SceneManager.LoadScene("GameOver");
		}
		else {
			Debug.Log(col.gameObject);
			Destroy(col.gameObject);
		}
	}
}
