private void DecrementProgress(int index)
        {
            _animationProgresses[index] -= (_animationDirections[index] == AnimationDirection.InOutOut || _animationDirections[index] == AnimationDirection.InOutRepeatingOut) ? SecondaryIncrement : Increment;
            if (_animationProgresses[index] < MinValue)
            {
                _animationProgresses[index] = MinValue;

                for (var i = 0; i < GetAnimationCount(); i++)
                {
                    if (_animationDirections[i] == AnimationDirection.InOutIn)
                    {
                        return;
                    }
                    if (_animationDirections[i] == AnimationDirection.InOutRepeatingIn)
                    {
                        return;
                    }
                    if (_animationDirections[i] == AnimationDirection.InOutRepeatingOut)
                    {
                        return;
                    }
                    if (_animationDirections[i] == AnimationDirection.InOutOut && _animationProgresses[i] != MinValue)
                    {
                        return;
                    }
                    if (_animationDirections[i] == AnimationDirection.Out && _animationProgresses[i] != MinValue)
                    {
                        return;
                    }
                }

                _animationTimer.Stop();
                OnAnimationFinished?.Invoke(this);
            }
        }
Exemplo n.º 2
0
    public IEnumerator Animate()
    {
        var startTime = Time.time;

        while (Vector3.Distance(sourceCamera.transform.position, destinationCamera.transform.position) > 0.05)
        {
            var timeSinceStarted = Time.time - startTime;

            sourceCamera.transform.position = Vector3.Lerp(
                sourceCamera.transform.position,
                destinationCamera.transform.position,
                Time.deltaTime * timeSinceStarted);

            sourceCamera.transform.rotation = Quaternion.Lerp(
                sourceCamera.transform.rotation,
                destinationCamera.transform.rotation,
                Time.deltaTime * timeSinceStarted);

            yield return(null);
        }

        OnAnimationFinished?.Invoke();

        sourceCamera.gameObject.SetActive(false);
        destinationCamera.gameObject.SetActive(true);

        sourceCamera.transform.rotation = startRotation;
        sourceCamera.transform.position = startPosition;
    }
Exemplo n.º 3
0
    void ShootProjectile()
    {
        if (target == null || throwing)
        {
            return;
        }

        if (currentState == EnemyState.Chasing && Random.Range(0, 100) < chanceToThrowRock)
        {
            //Throw rock
            agent.isStopped = true;
            throwing        = true;
            animator.Play("ThrowRock", 0, 0);
            UpdateAnimation("IsThrowing", true);

            OnAnimationFinished onAnimationFinished = delegate()
            {
                agent.isStopped = false;
                UpdateAnimation("IsThrowing", false);
                throwing = false;
                photonView.RPC(nameof(EnemyGolemThrowRock), RpcTarget.All);
            };


            StopCoroutine(nameof(WaitForRockThrow));
            StartCoroutine(nameof(WaitForRockThrow), onAnimationFinished);
        }
    }
Exemplo n.º 4
0
        private void IncrementProgress(int index)
        {
            animationProgresses[index] += Increment;
            if (animationProgresses[index] > MAX_VALUE)
            {
                animationProgresses[index] = MAX_VALUE;

                for (int i = 0; i < GetAnimationCount(); i++)
                {
                    if (animationDirections[i] == AnimationDirection.InOutIn)
                    {
                        return;
                    }
                    if (animationDirections[i] == AnimationDirection.InOutRepeatingIn)
                    {
                        return;
                    }
                    if (animationDirections[i] == AnimationDirection.InOutRepeatingOut)
                    {
                        return;
                    }
                    if (animationDirections[i] == AnimationDirection.InOutOut && animationProgresses[i] != MAX_VALUE)
                    {
                        return;
                    }
                    if (animationDirections[i] == AnimationDirection.In && animationProgresses[i] != MAX_VALUE)
                    {
                        return;
                    }
                }

                animationTimer.Stop();
                OnAnimationFinished?.Invoke(this);
            }
        }
Exemplo n.º 5
0
        private void DecrementProgress(int index)
        {
            animationProgresses[index] -= (animationDirections[index] == AnimationDirection.InOutOut || animationDirections[index] == AnimationDirection.InOutRepeatingOut) ? SecondaryIncrement : Increment;
            if (animationProgresses[index] < MIN_VALUE)
            {
                animationProgresses[index] = MIN_VALUE;

                for (int i = 0; i < GetAnimationCount(); i++)
                {
                    if (animationDirections[i] == AnimationDirection.InOutIn)
                    {
                        return;
                    }
                    if (animationDirections[i] == AnimationDirection.InOutRepeatingIn)
                    {
                        return;
                    }
                    if (animationDirections[i] == AnimationDirection.InOutRepeatingOut)
                    {
                        return;
                    }
                    if (animationDirections[i] == AnimationDirection.InOutOut && animationProgresses[i] != MIN_VALUE)
                    {
                        return;
                    }
                    if (animationDirections[i] == AnimationDirection.Out && animationProgresses[i] != MIN_VALUE)
                    {
                        return;
                    }
                }

                animationTimer.Stop();
                OnAnimationFinished?.Invoke(this);
            }
        }
    public void AnimationEventOnFinishedCalled()
    {
        if (Debug.isDebugBuild)
        {
            Debug.Log($"<color=purple>GETCALLED</color>");
        }

        OnAnimationFinished?.Invoke();
    }
Exemplo n.º 7
0
    private void OnEnable()
    {
        transform.localPosition = stagePositions[currentStage];

        selectDaggerAnim = Instantiate(selectDaggerAnim.gameObject, transform.localPosition, Quaternion.identity, transform.parent).GetComponent <OnAnimationFinished>();
        selectDaggerAnim.transform.localPosition = cursorPos;
        selectDaggerAnim.onAnimationFinished    += DaggerSelected;

        winInfo.OnLeaveLevel();
    }
Exemplo n.º 8
0
 void FinishAnimation()
 {
     isAnimationActive        = false;
     animationCurrentDuration = animationDuration;
     SetAnimationFrame();
     if (OnAnimationFinished != null)
     {
         OnAnimationFinished.Invoke();                                  // call OnAnimationFinished event
     }
 }
Exemplo n.º 9
0
    IEnumerator WaitForRockThrow(OnAnimationFinished onAnimationFinished)
    {
        yield return(null);

        while (target != null && animator.GetCurrentAnimatorStateInfo(0).IsName("ThrowRock") && animator.GetCurrentAnimatorStateInfo(0).normalizedTime < 0.7)
        {
            if (target != null)
            {
                transform.LookAt(target.transform.position);
            }
            yield return(null);
        }
        onAnimationFinished();
    }
Exemplo n.º 10
0
    protected IEnumerator WaitForAnimation(OnAnimationFinished onAnimationFinished)
    {
        yield return(new WaitForEndOfFrame());

        AnimatorStateInfo animatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);

        while (animatorStateInfo.normalizedTime < 1.0f)
        {
            animatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
            yield return(null);
        }
        Debug.Log("Finished animation coroutine");
        onAnimationFinished();
    }
Exemplo n.º 11
0
        private async void AnimateWheel()
        {
            // cancel previous animation
            if (_isAnimating)
            {
                CancelProgressToAnimation();
            }

            // when wheel resets
            if (TargetProgress < CurrentProgress)
            {
                CurrentProgress = TargetProgress;
            }

            // find starting segment
            var segmentWidth = (TotalProgress / SegmentCount);
            var startSegment = (uint)(CurrentProgress / segmentWidth);
            var deltaTime    = (MillisecondsToCompleteWheel / SegmentCount);

            for (var i = startSegment; i < SegmentCount; i++)
            {
                _isAnimating = true;
                var segmentStart  = i * segmentWidth;
                var segmentEnd    = segmentStart + segmentWidth;
                var segmentTarget = Math.Min(TargetProgress, segmentEnd);

                await ProgressTo(
                    CurrentProgress,
                    segmentTarget,
                    value =>
                {
                    CurrentProgress = float.IsNaN(value) ? CurrentProgress : value;
                    InvalidateSurface();
                },
                    (uint)(deltaTime * ((segmentStart + segmentTarget) / segmentEnd)),
                    Easing.SinInOut
                    );

                _isAnimating = false;
            }
            OnAnimationFinished?.Invoke();
        }
Exemplo n.º 12
0
    public virtual void Die()
    {
        IncreaseScore(points);
        OnAnimationFinished onAnimationFinished = delegate()
        {
            UpdateAnimation("IsDead", true);
            agent.isStopped = false;
            GameObject deathAnimationObj = Instantiate(deathAnimation.gameObject);
            deathAnimationObj.transform.position = transform.position;

            if (photonView.IsMine)
            {
                PhotonNetwork.Destroy(gameObject);
            }
        };

        agent.isStopped = true;
        animator.Play("Die", 0, 0);
        StopCoroutine(nameof(WaitForAnimation));
        StartCoroutine(nameof(WaitForAnimation), onAnimationFinished);
    }
Exemplo n.º 13
0
        private void IncrementProgress(int index)
        {
            _effectsProgression[index] += Increment;
            if (_effectsProgression[index] > MaxValue)
            {
                _effectsProgression[index] = MaxValue;

                for (var i = 0; i < GetAnimationCount(); i++)
                {
                    if (_animationDirections[i] == AnimationDirection.InOutIn)
                    {
                        return;
                    }

                    if (_animationDirections[i] == AnimationDirection.InOutRepeatingIn)
                    {
                        return;
                    }

                    if (_animationDirections[i] == AnimationDirection.InOutRepeatingOut)
                    {
                        return;
                    }

                    if ((_animationDirections[i] == AnimationDirection.InOutOut) && (_effectsProgression[i] != MaxValue))
                    {
                        return;
                    }

                    if ((_animationDirections[i] == AnimationDirection.In) && (_effectsProgression[i] != MaxValue))
                    {
                        return;
                    }
                }

                _animationTimer.Stop();
                OnAnimationFinished?.Invoke(this);
            }
        }
Exemplo n.º 14
0
    private void Update()
    {
        if (!canUpdate)
        {
            return;
        }

        rend.GetPropertyBlock(props);

        var deltaTime = BloodSettings == null ? Time.deltaTime : Time.deltaTime * BloodSettings.AnimationSpeed;

        if (BloodSettings != null && BloodSettings.FreezeDecalDisappearance && (timeLapsed / GraphTimeMultiplier) > 0.3f)
        {
        }
        else
        {
            timeLapsed += deltaTime;
        }

        var eval = FloatCurve.Evaluate(timeLapsed / GraphTimeMultiplier) * GraphIntensityMultiplier;

        props.SetFloat(cutoutPropertyID, eval);

        if (BloodSettings != null)
        {
            props.SetFloat("_LightIntencity", Mathf.Clamp(BloodSettings.LightIntensityMultiplier, 0.01f, 1f));
        }

        if (timeLapsed >= GraphTimeMultiplier)
        {
            canUpdate = false;
            OnAnimationFinished?.Invoke();
        }
        props.SetVector(forwardDirPropertyID, transform.up);
        rend.SetPropertyBlock(props);
    }
Exemplo n.º 15
0
        public void Draw(Vector2 position, float layer, Matrix transform)
        {
            if (IsVisible)
            {
                Point offset = new Point(
                    CurrentAnimation.Directions[Direction].Offset.X + (int)(Math.Floor(CurrentAnimationFrame) * CurrentAnimation.Size.Width),
                    CurrentAnimation.Directions[Direction].Offset.Y
                    );

                SpriteEffects flipEffects = SpriteEffects.None;
                if (CurrentAnimation.Directions[Direction].FlippedHorizontally)
                {
                    flipEffects |= SpriteEffects.FlipHorizontally;
                }
                if (CurrentAnimation.Directions[Direction].FlippedVertically)
                {
                    flipEffects |= SpriteEffects.FlipVertically;
                }

                Effect?.Effect?.Parameters["TextureSize"]?.SetValue(texture.Bounds.Size.ToVector2());
                Effect?.Update();

                game.SpriteBatch?.Begin(
                    SpriteSortMode.Immediate,
                    BlendState.AlphaBlend,
                    SamplerState.PointClamp,
                    null,
                    null,
                    Effect?.Effect,
                    transform
                    );

                var drawPosition = new Vector2((float)Math.Round(position.X), (float)Math.Round(position.Y));

                game.SpriteBatch?.Draw(
                    texture: texture,
                    position: drawPosition - CurrentAnimation.HitBoxOffset.ToVector2(),
                    sourceRectangle: new Rectangle(
                        offset.X,
                        offset.Y,
                        (int)CurrentAnimation.Size.Width,
                        (int)CurrentAnimation.Size.Height
                        ),
                    color: Color.White,
                    rotation: 0f,
                    origin: new Vector2(0, 0),
                    scale: Vector2.One,
                    effects: flipEffects,
                    layerDepth: layer
                    );

                game.SpriteBatch?.End();

                // Increment animation frame counter
                if (IsAnimated)
                {
                    CurrentAnimationFrame += CurrentAnimation.Speed;
                }

                // End of animation sequence
                if (CurrentAnimationFrame >= CurrentAnimation.Length)
                {
                    if (CurrentAnimation.Looped)
                    {
                        CurrentAnimationFrame = 0;
                    }
                    else
                    {
                        OnAnimationFinished?.Invoke(this);
                        IsAnimated = false;
                    }
                }
            }
        }
Exemplo n.º 16
0
 private void Stop()
 {
     AnimationStepTimer.Enabled = false;
     OnAnimationFinished?.Invoke(this);
     Runtime.StopAnimation = false;
 }
 public void OnAnimationFinish()
 {
     OnAnimationFinished?.Invoke();
 }