Пример #1
0
        public override M_Rectangle GetNoMatrixRectangle()
        {
            M_Rectangle rect = new M_Rectangle(0, 0, 0, 0);

            for (int i = 0; i < masks.Count; i++)
            {
                M_Rectangle cRect = masks[i].GetNoMatrixRectangle();
                if (i == 0)
                {
                    rect = cRect;
                }
                else
                {
                    if (cRect.pos.X < rect.pos.X)
                    {
                        rect.X = cRect.pos.X;
                    }
                    if (cRect.pos.Y < rect.pos.Y)
                    {
                        rect.Y = cRect.pos.Y;
                    }
                    if (cRect.size.X > rect.size.X)
                    {
                        rect.size.X = cRect.size.X;
                    }
                    if (cRect.size.Y > rect.size.Y)
                    {
                        rect.size.Y = cRect.size.Y;
                    }
                }
            }
            //rect.pos += this.pos;
            return(rect);
        }
Пример #2
0
 public override CollisionResult DistToRectangle(M_Rectangle rectangle)
 {
     return(new CollisionResult()
     {
         collision = masks.Any(f => f.ColRectangle(rectangle))
     });
     //return MaxCol(f => f.DistToRectangle(rectangle));
 }
Пример #3
0
        public virtual void Draw(SpriteBatch spriteBatch, M_Rectangle destinationRectangle, Color color, float depth = -1f)
        {
            if (visible)
            {
                if (depth == -1)
                {
                    depth = this.depth;
                }
                Vector2 scale       = new Vector2(destinationRectangle.size.X / sizex, destinationRectangle.size.Y / sizey);
                Vector2 imageOrigin = new Vector2(0, 0);

                spriteBatch.Draw(texture, (destinationRectangle.pos), new Rectangle(GetSourceX(), GetSourceY(), sizex, sizey), color, rotation, imageOrigin, scale, mirror, depth);
            }
        }
Пример #4
0
        public static string ToString(object input)
        {
            Type typeIn  = input.GetType();
            Type typeOut = typeof(string);

            if (typeIn == typeof(Color))
            {
                Color color = (Color)input;
                return(color.R.ToString("X2") + color.G.ToString("X2") + color.B.ToString("X2"));
            }
            else if (typeIn == typeof(M_Rectangle))
            {
                M_Rectangle rect = input as M_Rectangle;
                return(rect.pos.X.ToString(CultureInfo.InvariantCulture) + "," + rect.pos.Y.ToString(CultureInfo.InvariantCulture) + "," + rect.size.X.ToString(CultureInfo.InvariantCulture) + "," + rect.size.Y.ToString(CultureInfo.InvariantCulture));
            }
            TypeConverter converter = TypeDescriptor.GetConverter(typeIn);

            if (converter.CanConvertTo(typeOut))
            {
                return(converter.ConvertToInvariantString(input));
            }
            return("");
        }
Пример #5
0
        public override M_Rectangle GetRectangle()
        {
            Vector2 min = Vector2.Zero, max = Vector2.Zero;

            for (int i = 0; i < masks.Count; i++)
            {
                M_Rectangle cRect = masks[i].GetRectangle();
                if (i == 0)
                {
                    min = cRect.pos;
                    max = cRect.BottomRight;
                }
                else
                {
                    if (cRect.X < min.X)
                    {
                        min.X = cRect.X;
                    }
                    if (cRect.Right > max.X)
                    {
                        max.X = cRect.Right;
                    }
                    if (cRect.Y < min.Y)
                    {
                        min.Y = cRect.Y;
                    }
                    if (cRect.Bottom > max.Y)
                    {
                        max.Y = cRect.Bottom;
                    }
                }
            }
            M_Rectangle rect = new M_Rectangle(min, max - min);

            //rect.pos += this.pos;
            return(rect);
        }
Пример #6
0
 public override CollisionResult DistToRectangle(M_Rectangle rectangle, Vector2 dir)
 {
     return(Collision.DistRectanglePolygon(rectangle, this, -dir).GetAxisInvert());
 }
Пример #7
0
 public abstract CollisionResult DistToRectangle(M_Rectangle rectangle, Vector2 dir);
Пример #8
0
 public override CollisionResult DistToRectangle(M_Rectangle rectangle, Vector2 dir)
 {
     return(MinCol(f => f.DistToRectangle(rectangle, dir)));
 }
Пример #9
0
 public override bool ColRectangle(M_Rectangle rectangle)
 {
     return(masks.Any(f => f.ColRectangle(rectangle)));
 }
Пример #10
0
 public override CollisionResult DistToRectangle(M_Rectangle rectangle)
 {
     return(Collision.DistRectangleCircle(rectangle, this).GetAxisInvert());
 }
Пример #11
0
 public override bool ColRectangle(M_Rectangle rectangle)
 {
     return(Collision.ColRectangleCircle(rectangle, this));
 }
Пример #12
0
 public override CollisionResult DistToRectangle(M_Rectangle rectangle)
 {
     throw new NotImplementedException();
 }
Пример #13
0
 public abstract bool ColRectangle(M_Rectangle rectangle);
Пример #14
0
 public override CollisionResult DistToRectangle(M_Rectangle rectangle)
 {
     return(Collision.DistVectorRectangle(pos, rectangle));
 }
Пример #15
0
 public override bool ColRectangle(M_Rectangle rectangle)
 {
     return(Collision.ColVectorRectangle(pos, rectangle));
 }
Пример #16
0
 public override void Draw(SpriteBatch spriteBatch, M_Rectangle destinationRectangle, Color color, float depth = -1f)
 {
     DrawEffect();
     base.Draw(spriteBatch, destinationRectangle, color, depth);
 }
Пример #17
0
        public virtual void Draw(SpriteBatch spriteBatch, Color color, float depth = 0f)
        {
            M_Rectangle rect = GetRectangle();

            spriteBatch.Draw(DrawM.pixel, rect.pos, new Rectangle(0, 0, 1, 1), color, 0f, Vector2.Zero, rect.size, SpriteEffects.None, depth);
        }
Пример #18
0
 public abstract CollisionResult DistToRectangle(M_Rectangle rectangle);