Exemplo n.º 1
0
    public BattleTextPositionAnimation[] ClonePosition()
    {
        int length = Position.Length;

        for (int i = 0; i < length; ++i)
        {
            if (Position[i].Random)
            {
                HasRandomPosition = true;
                BattleTextPositionAnimation[] clone = new BattleTextPositionAnimation[Position.Length];

                for (int j = 0; j < length; ++j)
                {
                    clone[j] = new BattleTextPositionAnimation();
                    clone[j].Random = Position[j].Random;
                    clone[j].Amount = Position[j].Amount;
                    clone[j].Time = Position[j].Time;
                    clone[j].Start = Position[j].Start;
                    clone[j].Falloff = Position[j].Falloff;
                }

                return clone;
            }
        }

        return Position;
    }
Exemplo n.º 2
0
    public BattleTextPositionAnimation[] ClonePosition()
    {
        int length = Position.Length;

        for (int i = 0; i < length; ++i)
        {
            if (Position[i].Random)
            {
                HasRandomPosition = true;
                BattleTextPositionAnimation[] clone = new BattleTextPositionAnimation[Position.Length];

                for (int j = 0; j < length; ++j)
                {
                    clone[j]         = new BattleTextPositionAnimation();
                    clone[j].Random  = Position[j].Random;
                    clone[j].Amount  = Position[j].Amount;
                    clone[j].Time    = Position[j].Time;
                    clone[j].Start   = Position[j].Start;
                    clone[j].Falloff = Position[j].Falloff;
                }

                return(clone);
            }
        }

        return(Position);
    }
Exemplo n.º 3
0
    void Update()
    {
        float t = Time.time - startTime;

        if (t > Animation.Time)
        {
            Destroy(gameObject);
        }
        else
        {
            Vector3 realPosition;

            if (Target != null)
            {
                if (Animation.AnimateInWorld)
                {
                    realPosition = Target.position + WorldOffset;
                }
                else
                {
                    realPosition = BattleTextCamera.Instance.WorldToTextPosition(Target.position + WorldOffset);
                }
            }
            else
            {
                realPosition = ScreenPosition;
            }

            // Position animation
            for (int i = 0; i < positions.Length; ++i)
            {
                BattleTextPositionAnimation anim = positions[i];

                if (anim.Start <= t)
                {
                    float pt = (t - anim.Start) / anim.Time;

                    if (pt <= 1f)
                    {
                        if (anim.Falloff > 0f)
                        {
                            animatedPosition += anim.Amount * Time.deltaTime * Mathf.Lerp(1f, 0f, pt * anim.Falloff);
                        }
                        else
                        {
                            animatedPosition += anim.Amount * Time.deltaTime;
                        }
                    }
                }
            }

            // Size animation
            while (sizeAnimationIndex < Animation.Size.Length)
            {
                BattleTextSizeAnimation anim = Animation.Size[sizeAnimationIndex];

                float sz = (Time.time - sizeAnimationStart) / anim.Time;

                if (sz > 1)
                {
                    sizeAnimationStart  = Time.time;
                    sizeAnimationIndex += 1;
                    continue;
                }

                textRenderer.GlyphSize = Mathf.Lerp(anim.From, anim.To, sz);
                break;
            }

            // Apply scaling
            textRenderer.GlyphSize = textRenderer.GlyphSize * Scale;

            // Add all positions together
            realPosition += Animation.FixedOffset;
            realPosition += RandomOffset;
            realPosition += animatedPosition;

            if (!Animation.AnimateInWorld)
            {
                realPosition.z = 1;
            }

            // Set our position
            transform.position = realPosition;
        }
    }