using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class TutorialImageController : MonoBehaviour {

	public Image img;
	public float maxDistance;
	public float minDistance;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		Vector2 playerPos = CameraController.player.transform.position;
		Vector2 dist = playerPos - (Vector2)this.transform.position;
		float d = dist.magnitude;

		if (d<maxDistance){
			float t  = 1f-(d-minDistance)/(maxDistance-minDistance);
			Debug.Log(t);
			img.color = new Color(1,1,1,t*t);
		} else img.color = new Color(1,1,1,0);
	}
}
