예제 #1
0
    public IEnumerator DeathRoutine(float duration)
    {
        acInfo.isDead  = true;
        rigid.velocity = Vector3.zero;
        float timer = 0f;

        while (timer <= 0.5f * duration)
        {
            timer += Time.deltaTime;
            for (int i = 0; i < mats.Length; i++)
            {
                var mat = mats [i];
                mat.SetColor("_Black", Color.Lerp(mat.GetColor("_Black"), Color.white, timer / (duration * 0.5f)));
            }
            skel.GetComponent <MeshRenderer> ().materials = mats;
            yield return(null);
        }
        GameObject newEffect = Instantiate(deathEffect, deathEffectPivot.position, Quaternion.identity);

        while (timer <= duration)
        {
            timer += Time.deltaTime;
            for (int i = 0; i < mats.Length; i++)
            {
                var mat = mats [i];
                mat.SetColor("_Color", Color.Lerp(Color.white, new Color(1f, 1f, 1f, 0f), timer / duration));
            }
            skel.GetComponent <MeshRenderer> ().materials = mats;
            yield return(null);
        }
        spanwer.SetPooledObject(gameObject);
    }