using UnityEngine;
using System.Collections;

public class Motin : MonoBehaviour
{
	public float gap = 0.06F;
	public float motionSpeed = 0.002F;
	
	bool isUp = true;
	private Vector3 pos;
	private float orig_y = 0.0F;
	private float max_y = 0.0F;
	
	void Start()
	{
		pos = transform.position;
		orig_y = pos.y;
		max_y = orig_y + gap;
	}

	void Update ()
	{
		pos = transform.position;
		
		if(isUp == true)		{			pos.y += motionSpeed;		}
		else if(isUp == false)	{			pos.y -= motionSpeed;		}
		
		if(pos.y < orig_y)
		{
			isUp = true;
			pos.y = orig_y;
		}
		else if(pos.y > max_y)
		{
			isUp = false;
			pos.y = max_y;
		}
		
		transform.position = pos;
	}
	
	public Vector3 getPosition()
	{
		Vector3 tmpPos = transform.position;
		
		return tmpPos;
	}
}