Beispiel #1
0
 private static float easeCombined(TransitFunction startFunc, TransitFunction endFunc, float ratio)
 {
     if (ratio < 0.5f)
     {
         return(0.5f * startFunc(ratio * 2.0f));
     }
     else
     {
         return(0.5f * endFunc((ratio - 0.5f) * 2.0f) + 0.5f);
     }
 }
Beispiel #2
0
        public void Update()
        {
            float previousTime = currentTime;

            currentTime += Time.deltaTime;
            if (currentTime < 0 || previousTime >= totalTime)
            {
                return;
            }
            float ratio = Mathf.Min(totalTime, currentTime) / totalTime;
            int   numAnimatedProperties = startValues.Count;

            for (int i = 0; i < numAnimatedProperties; ++i)
            {
                if (float.IsNaN(startValues[i]))
                {
                    startValues[i] = float.Parse(Comm.GetPropertyValue(target, properties[i]).ToString());
                }

                float startValue = startValues[i];
                float endValue   = endValues[i];
                float delta      = endValue - startValue;

                TransitFunction transitionFunc = Transitions.getTransition(transition);
                float           temp           = transitionFunc(ratio) * delta;
                float           currentValue   = startValue + temp;

                if (roundToInt)
                {
                    currentValue = Mathf.Round(currentValue);
                }
                Comm.SetPropertyValue(target, properties[i], currentValue.ToString());
            }

            if (previousTime < totalTime && currentTime >= totalTime)
            {
                if (completed != null)
                {
                    completed.Invoke(target);
                }
                ing = false;
            }
        }