public void Execute(MadLevelIcon icon, ValueGetter getter, ValueSetter setter)
        {
            var animations = MadAnim.FindAnimations(icon.gameObject, animationName);

            for (int i = 0; i < animations.Count; ++i)
            {
                var animation = animations[i];

                float baseValue = getter(animation);

                switch (modifierFunction)
                {
                case ModifierFunc.Custom:
                    setter(animation, customModifierFunction(icon));
                    break;

                case ModifierFunc.Predefined:
                    float firstParameter = GetFirstParameterValue(icon);
                    float rightSideValue = Compute(firstParameter, secondParameter, valueOperator);
                    float leftSideValue  = Compute(baseValue, rightSideValue, baseOperator);
                    setter(animation, leftSideValue);
                    break;

                default:
                    Debug.LogError("Uknown modifier function:" + modifierFunction);
                    setter(animation, baseValue);
                    break;
                }
            }
        }
Пример #2
0
    private void Finish()
    {
        Anim(1);

        if (sendMessageOnFinish)
        {
            GameObject receiver = gameObject;
            if (messageReceiver != null)
            {
                receiver = messageReceiver;
            }

            receiver.SendMessage(messageName);
        }

        if (playAnimationOnFinish && !string.IsNullOrEmpty(playAnimationOnFinishName))
        {
            MadAnim.PlayAnimation(gameObject, playAnimationOnFinishName, playAnimationOnFinishFromTheBeginning);
        }

        if (destroyObjectOnFinish)
        {
            MadGameObject.SafeDestroy(gameObject);
        }
        isPlaying = false;

        if (!string.IsNullOrEmpty(animationQueue))
        {
            PlayAnimationNow(gameObject, animationQueue);
        }
    }
Пример #3
0
        private void StopAllAnimations(GameObject parent)
        {
            var animations = MadAnim.AllAnimations(parent);

            for (int i = 0; i < animations.Count; ++i)
            {
                var animation = animations[i];
                animation.Stop();
            }
        }
Пример #4
0
        private void PlayAnimations(GameObject parent)
        {
            for (int i = 0; i < playAnimations.Count; ++i)
            {
                var    anim  = playAnimations[i];
                string name  = anim.name;
                bool   reset = anim.fromTheBeginning;

                int playedCount = MadAnim.PlayAnimation(parent, name, reset);
                if (playedCount == 0)
                {
                    Debug.LogWarning("There's no animation with name '" + name + "'.");
                }
            }
        }