using UnityEngine;
using System.Collections;

public class ThinkieCorpse : MonoBehaviour {

	private float countdown;
	private bool isFading;
	private float startTime;

	private float alpha;

	void Start(){
		countdown = 0.0f;
		isFading = false;
	}

	void FixedUpdate(){
		if (countdown < Constants.THINKIE_CORPSE) {
			countdown += Time.deltaTime;
		} else {
			if(!isFading) startTime = Time.time;
			isFading = true;
		}

		if (isFading) {
			alpha = Mathf.Lerp(1.0f, 0.0f, (Time.time - startTime) / 2.4f);
			GetComponent<SpriteRenderer>().color = new Color(1.0f,1.0f,1.0f, alpha);
			if(alpha < 0.1f)
				Destroy(this.gameObject);
		}
	}

}
