using UnityEngine;
using System.Collections;

public class EnemyMovement : MonoBehaviour
{
	public Vector3 start;

	public Vector3 end;

	public float speed = 5f;		// The speed in which the enemy moves.

	private float startTime;

	void Start()
	{
		startTime = Time.time;
	}

	void Update()
	{
		if ((Time.time - startTime) > 20f)
		{
			speed = 4f;
		}

		if ((Time.time - startTime) > 50f)
		{
			speed = 3f;
		}

		if ((Time.time - startTime) > 100f)
		{
			speed = 2f;
		}

		if ((Time.time - startTime) > 150f)
		{
			speed = 1f;
		}

		gameObject.transform.position = Vector3.Lerp(start, end, Mathf.SmoothStep(0f,1f,Mathf.PingPong((Time.time - startTime) / speed, 1f)) );

	}
}