Пример #1
0
 public Sprite(Texture2D image, float x, float y, float scale, SpriteEffects spriteEffect)
     : base(x, y, image.Width, image.Height, scale)
 {
     Image        = image;
     this.bounds  = new RectangleGraphic(x, y, image.Width, image.Height, scale);
     SpriteEffect = spriteEffect;
 }
Пример #2
0
        public void DrawBounds(GraphicsHandler graphicsHandler, Color color)
        {
            RectangleGraphic scaledBounds = GetScaledBounds();

            scaledBounds.Color = color;
            scaledBounds.Draw(graphicsHandler);
        }
Пример #3
0
        // check if this overlaps with another rectangle
        public bool Overlaps(IntersectableRectangle other)
        {
            RectangleGraphic intersectRectangle      = GetIntersectRectangle();
            RectangleGraphic otherIntersectRectangle = other.GetIntersectRectangle();

            return(intersectRectangle.GetX1().Round() <= otherIntersectRectangle.GetX2().Round() && intersectRectangle.GetX2().Round() >= otherIntersectRectangle.GetX1().Round() &&
                   intersectRectangle.GetY1().Round() <= otherIntersectRectangle.GetY2().Round() && intersectRectangle.GetY2().Round() >= otherIntersectRectangle.GetY1().Round());
        }
Пример #4
0
 public Frame(Texture2D image, float scale, SpriteEffects spriteEffect, RectangleGraphic bounds, int delay)
     : base(image, scale, spriteEffect)
 {
     if (bounds != null)
     {
         this.bounds       = bounds;
         this.bounds.Scale = scale;
     }
     this.delay = delay;
 }
Пример #5
0
 public override void DrawBounds(GraphicsHandler graphicsHandler, Color color)
 {
     if (map != null)
     {
         RectangleGraphic scaledCalibratedBounds = GetCalibratedScaledBounds();
         scaledCalibratedBounds.Color = color;
         scaledCalibratedBounds.Draw(graphicsHandler);
     }
     else
     {
         base.DrawBounds(graphicsHandler, color);
     }
 }
Пример #6
0
 // gets scaled bounds taking into account map camera position
 public RectangleGraphic GetCalibratedScaledBounds()
 {
     if (map != null)
     {
         RectangleGraphic scaledBounds = GetScaledBounds();
         return(new RectangleGraphic(
                    scaledBounds.GetX1().Round() - map.GetCamera().X.Round(),
                    scaledBounds.GetY1().Round() - map.GetCamera().Y.Round(),
                    scaledBounds.GetScaledWidth(),
                    scaledBounds.GetScaledHeight()
                    ));
     }
     else
     {
         return(GetScaledBounds());
     }
 }
Пример #7
0
 public void SetBounds(RectangleGraphic bounds)
 {
     currentFrame.SetBounds(bounds);
 }
Пример #8
0
 public void SetBounds(RectangleGraphic hurtbox)
 {
     this.bounds = new RectangleGraphic(hurtbox.X, hurtbox.Y, hurtbox.Width, hurtbox.Height, Scale);
 }
Пример #9
0
 public void SetBounds(float x, float y, int width, int height)
 {
     this.bounds = new RectangleGraphic(x, y, width, height, Scale);
 }
Пример #10
0
 public GameObject(Texture2D image, float x, float y, float scale, SpriteEffects spriteEffect, RectangleGraphic bounds)
     : base(x, y)
 {
     this.animations = new Dictionary <string, Frame[]>();
     this.animations.Add("DEFAULT", new Frame[] {
         new FrameBuilder(image, 0)
         .WithScale(scale)
         .WithSpriteEffect(spriteEffect)
         .WithBounds(bounds)
         .Build()
     });
     this.currentAnimationName = "DEFAULT";
     UpdateCurrentFrame();
     this.startPositionX = x;
     this.startPositionY = y;
     this.previousX      = x;
     this.previousY      = y;
 }