FlatRedBallExtensions.ScaledPolygon.UpdateDependencies C# (CSharp) Метод

UpdateDependencies() публичный Метод

public UpdateDependencies ( double currentTime ) : void
currentTime double
Результат void
        public override void UpdateDependencies(double currentTime)
        {
            lock (this)
            {
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                if (mLastDependencyUpdate == currentTime)
                {
                    return;
                }
                mLastDependencyUpdate = currentTime;
            }

            this.UpdateDependenciesHelper(currentTime);

            if (!_alreadyScaled)
            {
                _alreadyScaled = true;
                SetUnscaledPoints(Points);
            }

            if (Visible)
            {
                // I am only calling this so it calls FillVertexArray();
                // The logic in PositionedObject.UpdateDependencies(double) should mean it doesn't do anything else
                UpdateDependencies(currentTime, true);
            }
        }

Usage Example

        public void ChangingScale()
        {
            var parent = new ScaledPositionedObject { ScaleX = .5f, ScaleY = .5f };
            var polygon = new ScaledPolygon
            {
                X = 10,
                Y = 10,
                Points = new List<Point>
                {
                    new Point(0, 0),
                    new Point(32, 0),
                    new Point(32, 32),
                    new Point(0, 32),
                    new Point(0, 0)
                }
            };

            polygon.AttachTo(parent, true);

            polygon.UpdateDependencies(1.0);
            polygon.RelativeScaleX = .5f;
            polygon.RelativeScaleY = .5f;
            polygon.UpdateDependencies(2.0);

            Assert.IsTrue(Math.Abs(polygon.Points[0].X) < Single.Epsilon);
            Assert.IsTrue(Math.Abs(polygon.Points[1].X - 8f) < Single.Epsilon);
            Assert.IsTrue(Math.Abs(polygon.Points[2].X - 8f) < Single.Epsilon);
            Assert.IsTrue(Math.Abs(polygon.Points[3].X) < Single.Epsilon);
            Assert.IsTrue(Math.Abs(polygon.Points[4].X) < Single.Epsilon);
            Assert.IsTrue(Math.Abs(polygon.Points[0].Y) < Single.Epsilon);
            Assert.IsTrue(Math.Abs(polygon.Points[1].Y) < Single.Epsilon);
            Assert.IsTrue(Math.Abs(polygon.Points[2].Y - 8f) < Single.Epsilon);
            Assert.IsTrue(Math.Abs(polygon.Points[3].Y - 8f) < Single.Epsilon);
            Assert.IsTrue(Math.Abs(polygon.Points[4].Y) < Single.Epsilon);
        }
All Usage Examples Of FlatRedBallExtensions.ScaledPolygon::UpdateDependencies