public Vector3 GetRandom(Vector3 maxRandom, int iElement) { MathUtils.tempV3.x = maxRandom.x * (DRandom.GetUnit(iElement)); MathUtils.tempV3.y = maxRandom.y * (DRandom.GetUnit(iElement + 13 * iElement)); MathUtils.tempV3.z = maxRandom.z * (DRandom.GetUnit(iElement + 29 * iElement)); return(MathUtils.tempV3); }
public void InitTimes(TextAnimation se, bool force = false) { if (mRandomSeed < 0) { mRandomSeed = DRandom.GetSeed(); } int nElements = (se == null) ? 1 : TextAnimation.mCharacters.Size; if (mNumElements == nElements && !force) { return; } mNumElements = nElements; mTotalTime = 0; for (int i = 0, imax = _Sequences.Length; i < imax; ++i) //if (_Sequences[i]._Enabled || force) { _Sequences[i].InitTimes(se, this, i, nElements); float seqDuration = _Sequences[i].mTotalTime; if (mTotalTime < 0 || seqDuration < 0) { mTotalTime = float.MaxValue; } else { mTotalTime = mTotalTime > seqDuration ? mTotalTime : seqDuration; } } mTotalTime += _ExtraTimePerLoop; }
public override void OnStop(TextAnimation se, SE_Animation anim, int sequenceIndex) { if (!Application.isPlaying || !_OnFinish_SetAlphaToFinalValue) { return; } var currentAlpha = se.mWidgetColor.a; float t = anim._Backwards ? 0 : 1; var progress = _EasingCurve.Evaluate(t); //--[ From ]---------------------------- float aFrom = _From * 255; if (_AnimBlend_From == eFloatAnimBlendMode.Offset) { aFrom = aFrom + currentAlpha; } if (_AnimBlend_From == eFloatAnimBlendMode.Blend) { aFrom = _From * currentAlpha; } if (HasRandom(_FromRandom)) { aFrom += 255 * _FromRandom * DRandom.GetUnit(0); } //--[ To ]---------------------------- float aTo = 255 * _To; if (_AnimBlend_To == eFloatAnimBlendMode.Offset) { aTo = (currentAlpha + _To); } if (_AnimBlend_To == eFloatAnimBlendMode.Blend) { aTo = (currentAlpha * _To); } if (HasRandom(_ToRandom)) { aTo += 255 * _ToRandom * DRandom.GetUnit(0 * 2 + 90); } // Find Alpha for this Character float falpha = (aFrom + (aTo - aFrom) * progress); byte alpha = (byte)(falpha < 0 ? 0 : falpha > 255 ? 255 : falpha); var color = se.mWidgetColor; color.a = alpha; se.SetWidgetColor(color); }
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; } }
public override void Apply_Characters(TextAnimation se, SE_Animation anim, int sequenceIndex) { if (anim.mTime < mDelay && !_InitAllElements) { return; } bool applyRandomFrom = HasRandom(_FromRandom); bool applyRandomTo = HasRandom(_ToRandom); DRandom.mCurrentSeed = GetRandomSeed(anim, sequenceIndex); // Iterate through all the valid range for (int iElement = mElementRangeStart; iElement < mElementRangeEnd; ++iElement) { float progress = GetProgress(anim.mTime, anim, iElement); if (!_InitAllElements && progress < 0) { continue; } progress = progress < 0 ? 0 : progress; progress = _EasingCurve.Evaluate(progress); var currentAlpha = TextAnimation.mOriginalVertices.Buffer[iElement * 4].color.a; //--[ From ]---------------------------- float aFrom = _From * 255; if (_AnimBlend_From == eFloatAnimBlendMode.Offset) { aFrom = aFrom + currentAlpha; } if (_AnimBlend_From == eFloatAnimBlendMode.Blend) { aFrom = _From * currentAlpha; } if (applyRandomFrom) { aFrom += 255 * _FromRandom * DRandom.GetUnit(iElement); } //--[ To ]---------------------------- float aTo = 255 * _To; if (_AnimBlend_To == eFloatAnimBlendMode.Offset) { aTo = (currentAlpha + _To); } if (_AnimBlend_To == eFloatAnimBlendMode.Blend) { aTo = (currentAlpha * _To); } if (applyRandomTo) { aTo += 255 * _ToRandom * DRandom.GetUnit(iElement * 2 + 90); } // Find Alpha for this Character float falpha = (aFrom + (aTo - aFrom) * progress); byte alpha = (byte)(falpha < 0?0 : falpha > 255?255: falpha); // Apply to all Vertices for (int v = iElement * 4; v < iElement * 4 + 4; ++v) { TextAnimation.mOriginalVertices.Buffer[v].color.a = alpha; } } }