예제 #1
0
    public void PlayAnim(AnimationSO forcedAnim = null)
    {
        if (animSO == null && forcedAnim == null)
        {
            Debug.LogError("Failed playing anim: anim is null");
            return;
        }
        if (!canBeOverride && animPlaying)
        {
            Debug.Log("Anim is already playing " + gameObject.name);
            return;
        }

        if (forcedAnim != null)
        {
            animSO = forcedAnim;
        }

        highlightCoroutine = StartCoroutine(C_Anim());
    }
예제 #2
0
    public Tweener Animate(AnimationTweenType localAnimationTweenType, Vector2 startPoint, Vector2 endPoint)
    {
        // Initializing and finding correct SO ------------------

        AnimationSO animSO     = animationSOs[0];
        int         arrayIndex = 0;
        float       overShoot  = 1.701f; // default value

        // This loop finds the given animation that corresponds to
        // the desired type as given by the parameter enum
        for (int i = 0; i < animationSOs.Length; i++)
        {
            AnimationSO tempSO = animationSOs[i];

            if (tempSO.animationTweenType == localAnimationTweenType)
            {
                animSO     = tempSO;
                arrayIndex = i;
                if (tempSO.overShoot == 0f)
                {
                    overShoot = DOTween.defaultEaseOvershootOrAmplitude;
                }
                else
                {
                    overShoot = tempSO.overShoot;
                }
                break;
            }
        }

        // End initialization -------------------------

        switch (localAnimationTweenType)
        {
        case AnimationTweenType.Move:
            //startPoint = checkVectVals(startPoint);
            return(transform.DOMove(endPoint, animSO.moveDuration).SetEase(animSO.moveEase, overShoot));

            break;

        case AnimationTweenType.Move2:
            //startPoint = checkVectVals(startPoint);
            return(transform.DOMove(endPoint, animSO.moveDuration).SetEase(animSO.moveEase, overShoot));

            break;

        case AnimationTweenType.Scale:
            transform.localScale = new Vector3(animSO.startValue, animSO.startValue, animSO.startValue);
            return(transform.DOScale(animSO.endValue, animSO.moveDuration).SetEase(animSO.moveEase, overShoot));

            break;

        case AnimationTweenType.RotateZ:
            transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, animSO.startValue);
            Vector3 endValue = new Vector3(transform.rotation.x, transform.rotation.y, animSO.endValue);
            return(transform.DOLocalRotate(endValue, animSO.moveDuration).SetEase(animSO.moveEase, overShoot));

            break;

        case AnimationTweenType.RotateZ2:
            transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, animSO.startValue);
            Vector3 endValue2 = new Vector3(transform.rotation.x, transform.rotation.y, animSO.endValue);
            return(transform.DOLocalRotate(endValue2, animSO.moveDuration).SetEase(animSO.moveEase, overShoot));

            break;


        case AnimationTweenType.FadeOutText:
            TextMeshProUGUI myText = GetComponent <TextMeshProUGUI>();
            return(myText.DOFade(0f, animSO.moveDuration).SetEase(animSO.moveEase));

        case AnimationTweenType.EndMove:
            //startPoint = checkVectVals(startPoint);
            return(transform.DOMove(endPoint, animSO.moveDuration).SetEase(animSO.moveEase, overShoot));

            break;

        case AnimationTweenType.FadeRadio:
            foreach (Transform child in transform)
            {
                SpriteRenderer sr = child.gameObject.GetComponent <SpriteRenderer>();
                sr.DOFade(0f, animSO.moveDuration).SetEase(animSO.moveEase);
            }
            return(null);

            break;

        default:
            return(null);

            break;
        }
    }
예제 #3
0
 protected void SetInitialState(AnimationSO animation = null)
 {
 }