using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class isDead : MonoBehaviour {
    public bool dead = false;
    private float visibility = 1.0f;
	// Use this for initialization
	void Start () {
        
    }
	
	// Update is called once per frame
	void Update () {
		if(dead && visibility==1.0f)
        {
            visibility = 0.9f;
            Invoke("Disappear",0.1f * Time.deltaTime);
        }
	}

    void Disappear()
    {
            if(visibility>-0.1)
        {
            Color tmp = GetComponent<SpriteRenderer>().color;
            tmp.a = visibility;
            GetComponent<SpriteRenderer>().color = tmp;
            Invoke("Disappear", 1.0f * Time.deltaTime);
            visibility -= 0.2f * Time.deltaTime;
        }
        
    }
}
