public void ApplyEffect(ref CharacterVertex targetCharacter) { // Check if this section effect should be applied if (Status == AnimationStatus.Stopped || !(targetCharacter.CharacterCount >= Start && targetCharacter.CharacterCount < Start + Length)) { return; } // Check progress & handle loop float charProgress = GetCharProgress(targetCharacter.CharacterCount - Start); if (charProgress >= 1f) { if (loop) { charProgress %= 1f; } else { Stop(); return; } } // Play effect effect.Apply(ref targetCharacter, charProgress); }
public override void Apply(ref CharacterVertex targetCharacter, float progress) { translation.x = magnitude * xBounce.Evaluate(progress); translation.y = magnitude * yBounce.Evaluate(progress); translation.z = magnitude * zBounce.Evaluate(progress); targetCharacter.BottomLeft.position += translation; targetCharacter.TopLeft.position += translation; if (offset != 0f) { progress = (progress + offset); if (progress > 1f) { progress -= 1f; } else if (progress < 0f) { progress += 1f; } translation.x = magnitude * xBounce.Evaluate(progress); translation.y = magnitude * yBounce.Evaluate(progress); translation.z = magnitude * zBounce.Evaluate(progress); } targetCharacter.BottomRight.position += translation; targetCharacter.TopRight.position += translation; }
public override void ModifyMesh(VertexHelper vh) { // Should it do anything? int vertexCount = vh.currentVertCount; if (isDirty || !IsActive() || vertexCount == 0) { vh.Clear(); return; } // Should it change states? if (isPlaying) { if (!play) { Pause(); } } else if (play) { Play(); } // Apply the effects uint currentCharacter; foreach (TextSection effect in effectSections) { currentCharacter = effect.Start; while (currentCharacter * 4 + 3 < vertexCount) { int startingVertex = (int)currentCharacter * 4; UIVertex topLeftVertex = new UIVertex(); vh.PopulateUIVertex(ref topLeftVertex, startingVertex); UIVertex topRightVertex = new UIVertex(); vh.PopulateUIVertex(ref topRightVertex, startingVertex + 1); UIVertex bottomRightVertex = new UIVertex(); vh.PopulateUIVertex(ref bottomRightVertex, startingVertex + 2); UIVertex bottomLeftVertex = new UIVertex(); vh.PopulateUIVertex(ref bottomLeftVertex, startingVertex + 3); CharacterVertex currentCharVertex = new CharacterVertex(ref topLeftVertex, ref topRightVertex, ref bottomRightVertex, ref bottomLeftVertex, currentCharacter); effect.ApplyEffect(ref currentCharVertex); vh.SetUIVertex(currentCharVertex.TopLeft, startingVertex); vh.SetUIVertex(currentCharVertex.TopRight, startingVertex + 1); vh.SetUIVertex(currentCharVertex.BottomRight, startingVertex + 2); vh.SetUIVertex(currentCharVertex.BottomLeft, startingVertex + 3); ++currentCharacter; } } }
public override void Apply(ref CharacterVertex targetCharacter, float progress) { leftColor = Color.Lerp(targetCharacter.TopLeft.color, endColor, curve.Evaluate(progress)); targetCharacter.TopLeft.color = leftColor; targetCharacter.BottomLeft.color = leftColor; rightColor = Color.Lerp(targetCharacter.TopRight.color, endColor, curve.Evaluate(leftToRight ? progress - offset : progress + offset)); targetCharacter.TopRight.color = rightColor; targetCharacter.BottomRight.color = rightColor; }
public override void Apply(ref CharacterVertex targetCharacter, float progress) { float power; if (horizontalForce != 0f) { power = horizontalForce * effectCurve.Evaluate(progress); targetCharacter.BottomLeft.position.x += Random.Range(-variance, variance) * power; targetCharacter.BottomRight.position.x += Random.Range(-variance, variance) * power; targetCharacter.TopRight.position.x += Random.Range(-variance, variance) * power; targetCharacter.TopLeft.position.x += Random.Range(-variance, variance) * power; } if (verticalForce != 0f) { power = verticalForce * (invertVerticalAnimation ? effectCurve.Evaluate(1f - progress) : effectCurve.Evaluate(progress)); targetCharacter.BottomLeft.position.y += Random.Range(-variance, variance) * power; targetCharacter.BottomRight.position.y += Random.Range(-variance, variance) * power; targetCharacter.TopRight.position.y += Random.Range(-variance, variance) * power; targetCharacter.TopLeft.position.y += Random.Range(-variance, variance) * power; } }
public override void Apply(ref CharacterVertex targetCharacter, float progress) { float currentScale = magnitude * scale.Evaluate(progress); targetCharacter.Scale(currentScale); }
public abstract void Apply(ref CharacterVertex targetCharacter, float progress);
public override void Apply(ref CharacterVertex targetCharacter, float progress) { float random = Random.Range(-variance, variance) * effectCurve.Evaluate(progress) * force; targetCharacter.Shift(new Vector3(random, random, 0f)); }