Esempio n. 1
0
        public override void Start()
        {
            isStarted = true;

            this.originalSize = new Vector2(sprite.Width, sprite.Height);

            if (isFromNull)
            {
                fromScale = new Vector2(1, 1);
            }

            fromSize   = UtilityHelper.MultiplyVector(this.originalSize, this.fromScale);
            fromSize.X = (int)fromSize.X; fromSize.Y = (int)fromSize.Y;
            toSize     = UtilityHelper.MultiplyVector(this.originalSize, this.toScale);
            toSize.X   = (int)toSize.X; toSize.Y = (int)toSize.Y;

            if (duration == 0)
            {
                sprite.SetSize(this.toSize);
                if (!isInfinite)
                {
                    this.Stop();
                }
                return;
            }

            velocity = UtilityHelper.CalculateVelocity(this.fromSize, this.toSize, duration);

            Sign = UtilityHelper.CalculateSign(this.fromSize, this.toSize);

            currentSize = this.fromSize;

            if (isAnimatedFromOrigin)
            {
                currentSize = this.originalSize;
                Sign        = UtilityHelper.CalculateSign(currentSize, this.fromSize);
            }
            else
            {
                sprite.SetSize(this.currentSize);
            }

            CurrentTime   = TimeSpan.Zero;
            Duration      = TimeSpan.FromSeconds(duration);
            totalDistance = UtilityHelper.VectorAbs(Vector2.Subtract(toSize, fromSize));

            if (graphFunction == null)
            {
                graphFunction = new ConstantGraphFunction(duration);
            }
        }