Exemple #1
0
        private IEnumerator MakeShield(GameObject gameObject, float duration)
        {
            var        endTime    = Time.time + duration;
            TankHealth tankHealth = gameObject.GetComponent <TankHealth>();

            tankHealth.SetIsShielded(true);
            while (Time.time < endTime)
            {
                MeshRenderer[] renderers = gameObject.GetComponentsInChildren <MeshRenderer>();

                for (int i = 0; i < renderers.Length; i++)
                {
                    renderers[i].enabled = false;
                }
                yield return(new WaitForSeconds(0.1f));

                for (int i = 0; i < renderers.Length; i++)
                {
                    renderers[i].enabled = true;
                }
                yield return(new WaitForSeconds(0.4f));
            }
            tankHealth.SetIsShielded(false);
        }