Hero.deathEffectCoroutine C# (CSharp) Method

deathEffectCoroutine() private method

private deathEffectCoroutine ( CellControl cc ) : IEnumerator
cc CellControl
return IEnumerator
    IEnumerator deathEffectCoroutine(CellControl cc)
    {
        cc.enabled = false;
        
        iTween.ScaleTo(gameObject, _optionsOut);

        safeFadeTo(_optionsOutAlpha);  

        _flagella = new List<GameObject>();

        foreach (Transform child in transform)
        {
            if(child.name == "FBX_flagelPlayer" && child.gameObject.activeSelf)
            {
                _flagella.Add(child.gameObject);
            }
        }
        
        //1 wait sequence between flagella, pair of eyes disappearances
        //therefore #flagella + #pairs of eyes - 1
        int maxWaitSequences = _flagella.Count;
        
        //fractional elapsed time
        // 0<elapsed<maxWaitSequences
        float elapsed = 0.0f;

        _flagella[0].SetActive(false);
        for(int i=1; i<_flagella.Count; i++)
        {
            //to make flagella disappear
            float random = UnityEngine.Random.Range(0.0f,1.0f);
            yield return new WaitForSeconds(random*_respawnTimeS/maxWaitSequences);
            _flagella[i].SetActive(false);
            elapsed += random;
        }

        //to make eyes disappear
        float lastRandom = UnityEngine.Random.Range(0.0f,1.0f);
        yield return new WaitForSeconds(lastRandom*_respawnTimeS/maxWaitSequences);
        elapsed += lastRandom;        
        enableEyes(false);

        yield return new WaitForSeconds((maxWaitSequences-elapsed)*_respawnTimeS/maxWaitSequences);
        
        respawnCoroutine(cc);
    }