using UnityEngine;
using System.Collections;

public class FloatingTip : MonoBehaviour {
	public Vector3 sPos;
	float posY = 0f;
	float sliderY = 50f;
	public GameObject door;
	public bool inScreen = false;

	void Start () {
		Vector3 p = transform.position;
		sPos = new Vector3 (p.x, p.y, p.z);
	}
	

	void Update () {
		Doors c = door.GetComponent<Doors> ();
		if (c == null) {
			return;
		}

		posY = Mathf.Cos (Time.time * Mathf.Deg2Rad * 100f) / 25f;
		transform.position = new Vector3 (sPos.x, sPos.y + posY + sliderY , sPos.z);
		if (inScreen == true) {
			if (sliderY > 0) {
				sliderY = sliderY * .85f;
			}

		}

		if (inScreen == false) {
			if (sliderY < 50) {
				sliderY = sliderY + 50f * 0.005f;
			}

		}
		if (inScreen == true) {
			if (Input.GetKeyDown (KeyCode.Return) == true) {
				c.open = true;
			}
		} else {
			c.open = false;
		}
	}
}
