Ejemplo n.º 1
0
 public void StopLoopingFlash(float id, FlashSettings settings)
 {
     if (_loopingFlashes.TryGetValue(id, out var flashCoroutine))
     {
         StopCoroutine(flashCoroutine);
         _changeVisibilityCoroutine = StartCoroutine(_changeFlashVisibilityCached(false, settings));
     }
 }
Ejemplo n.º 2
0
        public float LoopFlash(FlashSettings settings)
        {
            var id = Time.time;

            settings.color.a = 0;
            image.color      = settings.color;
            _loopingFlashes.Add(id, StartCoroutine(_flashLoopingCached(settings, id)));
            return(id);
        }
Ejemplo n.º 3
0
        private IEnumerator FlashLooping(FlashSettings flashSettings, float id)
        {
            while (true)
            {
                yield return(_startFlashingCached(flashSettings));

                var now = Time.time;
                while (Time.time - now < flashSettings.timeBetweenFlashes)
                {
                    yield return(null);
                }
            }
        }
Ejemplo n.º 4
0
 public void Flash(FlashSettings flashSettings)
 {
     image.color = flashSettings.color;
     if (_flashing && _startFlashingCoroutine != null)
     {
         StopCoroutine(_startFlashingCoroutine);
     }
     if (_changingVisibility && _changeVisibilityCoroutine != null)
     {
         StopCoroutine(_changeVisibilityCoroutine);
     }
     _startFlashingCoroutine = StartCoroutine(_startFlashingCached(flashSettings));
 }
Ejemplo n.º 5
0
        private IEnumerator StartFlashing(FlashSettings flashSettings)
        {
            _flashing = true;
            var showing    = true;
            var imageColor = image.color;

            imageColor.a = 0;
            image.color  = imageColor;
            for (var i = 0; i < flashSettings.quantityOfFlashes * 2; i++)
            {
                yield return(_changeFlashVisibilityCached(showing, flashSettings));

                showing = !showing;
            }
            _flashing = false;
        }
Ejemplo n.º 6
0
 private IEnumerator ChangeFlashVisibility(bool show, FlashSettings flashSettings)
 {
     _changingVisibility = true;
     while (true)
     {
         var color = image.color;
         if (show && color.a >= flashSettings.maxAlpha)
         {
             break;
         }
         if (!show && color.a <= flashSettings.minAlpha)
         {
             break;
         }
         var imageColor = color;
         imageColor.a += flashSettings.speed * Time.deltaTime * (show ? 1 : -1);
         image.color   = imageColor;
         yield return(null);
     }
     _changingVisibility = false;
 }