using UnityEngine;
using System.Collections;

public class Hole : MonoBehaviour {

	private float startTime;
	private float rotationSpeed;
	private float scaleFactor;

	void Start(){
		startTime = Time.time;
		rotationSpeed = Constants.HOLE_ROTATION_MIN_SPEED;
		scaleFactor = Constants.HOLE_MAX_SCALE;
	}

	void FixedUpdate () {
		rotationSpeed = Mathf.Lerp (Constants.HOLE_ROTATION_MIN_SPEED, Constants.HOLE_ROTATION_MAX_SPEED, (Time.time - startTime) / Constants.GAME_TIME_LIMIT);
		scaleFactor = Mathf.Lerp (Constants.HOLE_MAX_SCALE, Constants.HOLE_MIN_SCALE, (Time.time - startTime) / Constants.GAME_TIME_LIMIT);

		if (scaleFactor == Constants.HOLE_MIN_SCALE)
			GameObject.FindGameObjectWithTag ("EndButtons").gameObject.SetActive (true);

		transform.eulerAngles = new Vector3 (0.0f, 0.0f, transform.eulerAngles.z + rotationSpeed);
		transform.localScale = new Vector3 (scaleFactor, scaleFactor, scaleFactor);
	}
}
