Пример #1
0
        public override void Update(AnimationManager animMan)
        {
            Polygon?.Update(animMan);
            if (Polygon?.Points == null)
            {
                return;
            }

            if (Timing != null)
            {
                float t = Math.Max(0f, Math.Min((Time - Timing[0] * TimeScale - TimeDelay) / Timing[1] / TimeScale, 1f));
                Progress = (float)Math.Sin(t * Math.PI / 2f);
                if (TimeAuto)
                {
                    Time += animMan.DeltaTime;
                }
            }

            int lengthShort = (int)Math.Floor(1 + (Polygon.Points.Length - 1) * ProgressF);
            int lengthLong  = Math.Min(lengthShort + 1, Polygon.Points.Length);
            int lengthArr   = lengthLong;

            if (lengthLong <= 1)
            {
                lengthArr = 2;
            }
            if (_Points == null || _Points.Length != lengthArr)
            {
                _Points = new PointF[lengthArr];
            }

            if (_Progress != ProgressF)
            {
                _Progress       = ProgressF;
                animMan.Repaint = true;
            }

            if (lengthLong <= 1)
            {
                PointF p = Polygon.Points[0];
                _Points[0] = p;
                _Points[1] = new PointF(
                    p.X + 0.001f,
                    p.Y
                    );

                return;
            }

            Array.Copy(Polygon.Points, _Points, lengthShort);

            float  endStep = (1 + (Polygon.Points.Length - 1) * ProgressF) - lengthShort;
            PointF a       = Polygon.Points[lengthShort - 1];
            PointF b       = Polygon.Points[lengthLong - 1];

            _Points[lengthLong - 1] = new PointF(
                a.X + (b.X - a.X) * endStep + 0.001f,
                a.Y + (b.Y - a.Y) * endStep
                );
        }