Пример #1
0
        protected float PlayAnimation(string text)
        {
            if (!tagActionRunning)
            {
                string[] components = text.Split(',');

                if (components.Length < 2)
                {
                    tagActionRunning = false;
                    return(actionComplete);
                }

                actionActor = GetActorFrom(components[0]);

                if (actionActor == null)
                {
                    return(actionComplete);
                }

                SetAnimOptions(components);

                tagActionRunning      = true;
                actionActor.charState = CharState.Custom;
                actionActor.GetAnimator().CrossFade(components[1].Trim(), 0, 0);

                if (!animOptions.waitFinish)
                {
                    tagActionRunning = false;
                    return(actionComplete);
                }
                return(defaultPauseTime);
            }
            else
            {
                float totalLength = actionActor.GetAnimator().GetCurrentAnimatorStateInfo(animOptions.layer).length;
                float timeLeft    = (1f - actionActor.GetAnimator().GetCurrentAnimatorStateInfo(animOptions.layer).normalizedTime) * totalLength;
                timeLeft -= 0.1f;

                if (timeLeft > 0f)
                {
                    return(timeLeft);
                }

                if (animOptions.resetToIdle)
                {
                    actionActor.charState = CharState.Idle;
                }
            }

            tagActionRunning = false;
            actionActor      = null;
            return(actionComplete);
        }