public void Fade(float alphaTowards, AnimationCompleteCallback callback)
 {
     this.alphaTowards = alphaTowards;
     if (!isFading)
     {
         new Task(() => FadeTowards(callback)).Start();
     }
 }
Exemplo n.º 2
0
 public ReticleAnimation(bool pAnimate)
 {
     startRadius       = 0;
     endRadius         = 0;
     startRotation     = Quaternion.identity;
     endRotation       = Quaternion.identity;
     animationDuration = 0;
     startTime         = 0;
     timeElapsed       = 0;
     t          = 0;
     animate    = pAnimate;
     OnComplete = null;
 }
Exemplo n.º 3
0
 public void StartAnimation(float pStartRadius, float pEndRadius, float startRotationDeg, float endRotationDeg, float seconds, AnimationCompleteCallback pOnComplete = null)
 {
     startRadius       = pStartRadius;
     endRadius         = pEndRadius;
     startRotation     = Quaternion.Euler(0, 0, startRotationDeg);
     endRotation       = Quaternion.Euler(0, 0, endRotationDeg);
     animationDuration = seconds;
     startTime         = Time.time;
     timeElapsed       = 0;
     t          = 0;
     animate    = true;
     OnComplete = pOnComplete;
 }
    protected async void FadeTowards(AnimationCompleteCallback callback)
    {
        isFading = true;

        while (Math.Abs(Alpha - alphaTowards) > 0.25f)
        {
            Alpha = alpha + moveSpeed * (alphaTowards - alpha);
            await Task.Delay(frameRateMS);
        }

        Alpha    = alphaTowards;
        isFading = false;

        callback?.Invoke(this);
    }
Exemplo n.º 5
0
 public void Update()
 {
     for (int i = 0; i < _currentAnimations.Count;)
     {
         if (_currentAnimations[i].Update())
         {
             i++;
         }
         else
         {
             AnimationCompleteCallback onCompleteCallback = _currentAnimations[i].OnAnimationCompleted;
             Animation completeAnimation = _currentAnimations[i];
             _currentAnimations.RemoveAt(i);
             if (onCompleteCallback != null)
             {
                 onCompleteCallback(completeAnimation);
             }
         }
     }
 }