Example #1
0
    public void PlayAnimation(UIComponent component)
    {
        if (!Enabled)
        {
            return;
        }
        if (_currentAnimation != null)
        {
            Coroutiner.KillCoroutine(_currentAnimation);
        }
        OnStart?.Invoke();
        _currentAnimation = Coroutiner.Wait(_waitDuration, () => OnComplete?.Invoke());


        if (scale.Enabled)
        {
            switch (scale.AnimationType)
            {
            case AnimationType.Punch:
                ROJOAnimator.StopAnimation(component.RectTransform, AnimationType.Punch, AnimationAction.Scale);
                ROJOAnimator.ScalePunch(component.RectTransform, scale, component.StartScale);
                break;

            case AnimationType.State:
                ROJOAnimator.StopAnimation(component.RectTransform, AnimationType.State, AnimationAction.Scale);
                ROJOAnimator.ScaleState(component.RectTransform, scale, component.StartScale);
                break;

            default:
                break;
            }
        }

        if (move.Enabled)
        {
            switch (move.AnimationType)
            {
            case AnimationType.Punch:
                ROJOAnimator.StopAnimation(component.RectTransform, AnimationType.Punch, AnimationAction.Move);
                ROJOAnimator.MovePunch(component.RectTransform, move, component.StartPosition);
                break;

            case AnimationType.State:
                ROJOAnimator.StopAnimation(component.RectTransform, AnimationType.State, AnimationAction.Move);
                ROJOAnimator.MoveState(component.RectTransform, move, component.StartPosition);
                break;

            default:
                break;
            }
        }

        if (rotate.Enabled)
        {
            switch (rotate.AnimationType)
            {
            case AnimationType.Punch:
                ROJOAnimator.StopAnimation(component.RectTransform, AnimationType.Punch, AnimationAction.Rotate);
                ROJOAnimator.RotatePunch(component.RectTransform, rotate, component.StartRotation);
                break;

            case AnimationType.State:
                ROJOAnimator.StopAnimation(component.RectTransform, AnimationType.State, AnimationAction.Rotate);
                ROJOAnimator.RotateState(component.RectTransform, rotate, component.StartRotation);
                break;

            default:
                break;
            }
        }

        if (animatedProperty.Enabled)
        {
            switch (animatedProperty.property.AnimationType)
            {
            case AnimationType.Punch:
                ROJOAnimator.StopAnimation(component.material, AnimationType.Punch, AnimationAction.Property);
                ROJOAnimator.PropertyPunch(component.material, animatedProperty);
                break;

            case AnimationType.State:
                ROJOAnimator.StopAnimation(component.material, AnimationType.State, AnimationAction.Property);
                ROJOAnimator.PropertyState(component.material, animatedProperty);
                break;

            default:
                break;
            }
        }
    }