using UnityEngine;
using System.Collections;

public class Obstacle : MonoBehaviour {
	
	public static float shoreTranslation = -0.1f;
	public float startDelay = 5.0f;
	public float startTime = 0.0f;
	public Vector3 startPosition;
	// Use this for initialization
	void Start () {
		startPosition = gameObject.transform.position;
		gameObject.transform.position += new Vector3( Random.Range(-1, 1) * 2.5f, 0, 0);
		startTime = Time.time;
	}
	
	// Update is called once per frame
	void Update () {
		if (Time.time > startTime + startDelay){
			gameObject.transform.position += (new Vector3(0.0f, shoreTranslation, 0.0f));
			if (gameObject.transform.position.y < -9.70 ) {
				gameObject.transform.position = startPosition;
				gameObject.transform.position += new Vector3( Random.Range(-1, 1) * 2.5f, 0, 0);
			}
		}
	}
}
