Beispiel #1
0
        private IEnumerator InvincibleRoutine()
        {
            Health.SetInvincible(true);

            SpriteRenderer sr = GetComponent <SpriteRenderer>();

            if (sr == null)
            {
                throw new Exception("No renderer found in PlayerSpaceShip object.");
            }

            Color color = sr.color;

            float timer = 0f;

            while (timer < invincibleTime)
            {
                timer += blinkInterval;

                color.a  = (color.a == 1 ? 0.3f : 1);
                sr.color = color;

                yield return(new WaitForSeconds(blinkInterval));
            }

            color.a  = 1;
            sr.color = color;

            Health.SetInvincible(false);
        }