Ejemplo n.º 1
0
        public virtual int GetRandomSeed(SE_Animation anim, int sequenceIndex)
        {
            float t = anim.mTime - mDelay;

            if (t < 0.0001f)
            {
                t = 0.0001f;
            }
            return(anim.mRandomSeed + (anim.GetCurrentLoop() * anim._Sequences.Length + Mathf.CeilToInt(t / mTotalLoopDuration)) * 20 * sequenceIndex);
        }
Ejemplo n.º 2
0
        public void GetElementTimes(SE_Animation anim, int index, out float startTime, out float elementDuration)
        {
            startTime       = index * mElementDelay;
            elementDuration = mElementDuration;
            float loopTime = mTotalTime - mDelay;

            int randomSeedBase = anim.mRandomSeed + 10 * anim.GetCurrentLoop() - DRandom.mCurrentSeed;

            if (_DurationRandom_Slower > 0 || _DurationRandom_Faster > 0)
            {
                float durRangeSlower = _DurationRandom_Slower * loopTime;
                float durRangeFaster = _DurationRandom_Faster * elementDuration;

                float minDuration = elementDuration - durRangeFaster; if (minDuration < 0.001f)
                {
                    minDuration = 0.001f;
                }
                float maxDuration = elementDuration + durRangeSlower; if (maxDuration > loopTime - startTime)
                {
                    maxDuration = loopTime - startTime;
                }
                elementDuration = DRandom.Get(index + randomSeedBase, minDuration, maxDuration);
            }

            if (_RandomStart > 0)
            {
                float randRange = _RandomStart * loopTime;
                float minStart  = startTime - randRange; if (minStart < 0)
                {
                    minStart = 0;
                }
                float maxStart = startTime + randRange; if (maxStart > loopTime - elementDuration)
                {
                    maxStart = loopTime - elementDuration;
                }
                startTime = DRandom.Get(index + randomSeedBase, minStart, maxStart);
            }

            if (_Backwards)
            {
                startTime = mTotalTime - (startTime + mDelay) - elementDuration;
            }
        }