SGDE.Physics.Collision.CollisionUnit.Scale C# (CSharp) Метод

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

Scale the CollisionUnit a specified amount.
public Scale ( Vector2 scale ) : void
scale Vector2 The delta scale of the CollisionUnit.
Результат void
        public override void Scale(Vector2 scale)
        {
            base.Scale(scale);
            CollisionChief chief = CollisionChief.GetInstance();

            // no inside out scaling
            //if (scale.X < 0)
            //{
            //    scale.X *= -1;
            //}
            //if (scale.Y < 0)
            //{
            //    scale.Y *= -1;
            //}

            //chief.ScaleCollisionUnit(this, scale);

            if (mCollisionType == CollisionType.COLLISION_NONE)
            {
                return;
            }
            else if (mCollisionType == CollisionType.COLLISION_CIRCLE)
            {
                // no ovals
                //mCircleRadius = (int) (mCircleRadius * ((scale.X + scale.Y) / 2));
                //mCircleRadius = (int) (mCircleRadius + mCircleRadius * ((scale.X + scale.Y) / 2));
                //mCircleRadius *= (int)((GetScale().X + GetScale().Y) / 2);
                int newCircleRadius = (int)(mOrigRadius * ((GetScale().X + GetScale().Y) / 2));
                int radiusChange = newCircleRadius - mCircleRadius;

                if (radiusChange > 0 || radiusChange < 0)
                {
                    // important that chief scales first
                    chief.ScaleCollisionUnit(this, new Vector2(radiusChange, radiusChange));
                    mCircleRadius += radiusChange;
                }
            }
            else if (mCollisionType == CollisionType.COLLISION_BOX)
            {
                //int oldWidth = GetWidth();
                //int oldHeight = GetHeight();
                int newWidth = (int)(mOrigWidth * GetScale().X);
                int newHeight = (int)(mOrigHeight * GetScale().Y);

                int xChange = (newWidth - GetWidth()) / 2;
                int yChange = (newHeight - GetHeight()) / 2;

                //int xChange = (int)(((oldWidth * scale.X) - oldWidth) / 2);
                //int yChange = (int)(((oldHeight * scale.Y) - oldHeight) / 2);
                //int xChange = (int) (oldWidth * scale.X / 2);
                //int yChange = (int) (oldHeight * scale.Y / 2);

                if (xChange > 0 || xChange < 0 || yChange > 0 || yChange < 0)
                {
                    // important that chief scales first
                    chief.ScaleCollisionUnit(this, new Vector2(xChange, yChange));

                    // scale from center
                    //mPoint1.X -= xChange;
                    //mPoint1.Y -= yChange;

                    //mPoint2.X += xChange;
                    //mPoint2.Y += yChange;

                    // scale with top left stationary
                    mPoint2.X += xChange * 2;
                    mPoint2.Y += yChange * 2;
                }
            }
            else if (mCollisionType == CollisionType.COLLISION_LINE)
            {
                // TODO
            }

            if (!bNeedsUpdate)
            {
                bNeedsUpdate = true;
                chief.UpdateUnit(this);
            }
        }