 using UnityEngine;
using System.Collections;

public class PowerUpRotator : MonoBehaviour {
	private bool fstate = false;
	private float y = 0f;
	private float sy = 0f;
	private Vector3 old;

	void Start () {
		transform.eulerAngles = new Vector3 (90, 0, 0);
		sy = 0.1f;;
		old = transform.position;
	}

	void Update () {
		transform.Rotate (new Vector3 (0,0,360f) * Time.deltaTime,Space.Self);
		if (fstate == false) {
			y += .005f;
			if (y > .2) {
				fstate = true;
			}
		}
		if (fstate == true) {
			y -= .005f;
			if (y < 0) {
				fstate = false;
			}
		}
		Vector3 p = transform.position;
		old = new Vector3 (p.x, sy + y, p.z);
		transform.position = new Vector3(p.x,p.y * 0.97f + old.y * 0.03f,p.z);


	}
}
