Ejemplo n.º 1
0
        protected override void Draw(GameTime gameTime)
        {
            drawTimeStep = gameTime.ElapsedGameTime.TotalMilliseconds / 1000d;
            GraphicsDevice.Clear(backgroundColor);

            //Draw Background objects.
            MainSpriteBatch.Begin(samplerState: SamplerState.PointClamp);
            CurrentStage.DrawBackground(ChoiceMaker.Active ? drawTimeStep / 4d : drawTimeStep);
            MainSpriteBatch.End();

            //Draw Stage objects.
            MainSpriteBatch.Begin(transformMatrix: CurrentStage.Camera.GetViewMatrix());
            CurrentStage.DrawForeground(drawTimeStep);
            MainSpriteBatch.End();

            //Draw Choice Maker.
            MainSpriteBatch.Begin(samplerState: SamplerState.AnisotropicWrap, blendState: BlendState.AlphaBlend);
            if (SorryScreen.Active)
            {
                SorryScreen.Draw(drawTimeStep);
            }
            else
            {
                ChoiceMaker.Draw(drawTimeStep);
            }
            MainSpriteBatch.End();
            base.Draw(gameTime);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Integral positioning.
 /// </summary>
 public void DrawRectangle(Point pos, Point size, Color color, Single rotation = 0.0f, Single opacity = 1.0f,
                           Vector2 origin = default(Vector2))
 {
     MainSpriteBatch.Draw(_whiteRect,
                          new Rectangle(pos.X * Options.GetResolutionScaleFactor(), pos.Y * Options.GetResolutionScaleFactor(),
                                        size.X * Options.GetResolutionScaleFactor(), size.Y * Options.GetResolutionScaleFactor()), null,
                          color * opacity, rotation, origin, SpriteEffects.None, 0f);
 }
Ejemplo n.º 3
0
        public static void DrawHollowRectangleUnshifted(int x, int y, int w, int h, int thickness, Color color)
        {
            // draw top side
            MainSpriteBatch.Draw(ContentAccessor.Empty, new Rectangle(x, y, w, thickness), color);

            // draw right side
            MainSpriteBatch.Draw(ContentAccessor.Empty, new Rectangle(x + w - thickness, y, thickness, h), color);

            // draw bottom side
            MainSpriteBatch.Draw(ContentAccessor.Empty, new Rectangle(x, y + h - thickness, w, thickness), color);

            // draw left side
            MainSpriteBatch.Draw(ContentAccessor.Empty, new Rectangle(x, y, thickness, h), color);
        }
Ejemplo n.º 4
0
        public static void DrawStringOnScreen(this string text, Vector2 position, Color?color = null, float scale = 1, SpriteFont font = null)
        {
            if (font == null)
            {
                font = ContentAccessor.StandardFont;
            }
            if (color == null)
            {
                color = Color.Black;
            }

            Vector2 stringSize = ContentAccessor.StandardFont.MeasureString(text);

            stringSize = new Vector2(stringSize.X * scale, stringSize.Y * scale);

            MainSpriteBatch.DrawString(font, text, (new Vector2(position.X - stringSize.X / 2, position.Y - stringSize.Y / 2)), color.Value, 0, Vector2.Zero, scale, SpriteEffects.None, 0);
        }
Ejemplo n.º 5
0
        public static void Draw(this GameObject gameObject, bool devBorder = false)
        {
            var drawMethod = gameObject.DrawMethod;

            for (int i = 0; i < drawMethod.Textures.Count; i++)
            {
                Texture2D texture   = drawMethod.Textures[i];
                Rectangle rectangle = drawMethod.Rectangles[i];

                // Camera shift
                rectangle.Location = new Point(rectangle.Location.X + rectangle.Width / 2, rectangle.Location.Y + rectangle.Height / 2);

                Vector2 origin         = new Vector2(texture.Width / 2, texture.Height / 2);
                float   rotationRadian = (-1) * (float)(gameObject.Rotation * (Math.PI / 180));

                rectangle = new Rectangle((int)(rectangle.X + CameraShift.X), (int)(rectangle.Y + CameraShift.Y), rectangle.Width, rectangle.Height);
                MainSpriteBatch.Draw(texture, rectangle, null, Color.White, rotationRadian, origin, SpriteEffects.None, 0f);
                if (devBorder)
                {
                    gameObject.Body.Rectangle.DrawDevBorder();
                }
            }
        }
Ejemplo n.º 6
0
        public static void DrawSimple(this GameObject gameObject)
        {
            Rectangle rectangle = new Rectangle(gameObject.Body.Rectangle.Location + CameraShift.ToPoint(), gameObject.Body.Rectangle.Size);

            MainSpriteBatch.Draw(gameObject.Texture, rectangle, Color.White);
        }