예제 #1
0
        private void DrawDiagnosticHitBox(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();

            Square hitBox = new Square
            {
                Alpha = 0.8f,
                Color = Color.OrangeRed,
                Bounds = (Rectangle)BoundingBox.Bounds
            };
            hitBox.Draw(spriteBatch, BoundingBox.Position);

            Square spriteBox = new Square
            {
                Alpha = 0.4f,
                Color = Color.OrangeRed,
                Bounds = new Rectangle(0, 0, ContentWidth, ContentHeight)
            };
            spriteBox.Draw(spriteBatch, Position);

            spriteBatch.End();
        }
예제 #2
0
        private void DrawGameOver()
        {
            string title = "SIAMO FUORI!";
            string legend = "(premere Enter per ricominciare)";

            Square square = new Square
            {
                Alpha = 0.7f,
                Bounds = GraphicsDevice.Viewport.Bounds,
                Color = Color.DarkRed
            };

            spriteBatch.Begin();
            square.Draw(spriteBatch);
            DrawText(title, titleFont, new Vector2(0, -30), Color.BlanchedAlmond);
            DrawText(legend, regularFont, new Vector2(160, 25), Color.AliceBlue);
            spriteBatch.End();
        }
        private void HighlightIntersection(IEnumerable<Tile> tiles, FloatRectangle bounds)
        {
            IList<Square> squares = new List<Square>();

            foreach (Tile tile in tiles)
            {
                Rectangle intersection = (Rectangle)FloatRectangle.Intersect(bounds, tile.Bounds);
                bool intersects = intersection.Width > 0 && intersection.Height > 0;
                if (!intersects)
                {
                    continue;
                }

                Square square = new Square
                {
                    Alpha = 1f,
                    Bounds = intersection,
                    Color = Color.DarkRed
                };
                squares.Add(square);
            }

            intersectionGrid = new SquareGrid(squares);
        }
        private void HighlightMatchingTiles(IEnumerable<Tile> tiles, FloatRectangle bounds)
        {
            IList<Square> squares = new List<Square>();

            foreach (Tile tile in tiles)
            {
                FloatRectangle intersection = (Rectangle)FloatRectangle.Intersect(bounds, tile.Bounds);
                bool intersects = intersection.Width > 0 && intersection.Height > 0;

                Square square = new Square
                {
                    Alpha = 0.7f,
                    Bounds = tile.Bounds,
                    Color = intersects ? Color.MediumPurple : Color.MintCream
                };
                squares.Add(square);
            }

            matchGrid = new SquareGrid(squares);
        }
예제 #5
0
        protected override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            if (!blackOutStart.HasValue || !blackOutDuration.HasValue)
            {
                return;
            }

            var difference = gameTime.TotalGameTime - blackOutStart.Value;
            if (difference > blackOutDuration)
            {
                blackOutStart = null;
                blackOutDuration = null;
            }
            else
            {
                double alpha = 1 - difference.TotalMilliseconds / blackOutDuration.Value.TotalMilliseconds;

                Square square = new Square
                {
                    Bounds = GraphicsDevice.Viewport.Bounds,
                    Color = Color.Black,
                    Alpha = (float)Math.Max(0.01, Math.Min(alpha, 1))
                };

                spriteBatch.Begin();
                square.Draw(spriteBatch);
                spriteBatch.End();
            }
        }
예제 #6
0
        private void DrawDiagnosticTileGrid(SpriteBatch spriteBatch)
        {
            if (diagnosticTextureGrid == null)
            {
                IList<Square> squares = new List<Square>();
                TileMatrix matrix = TileMatrix.Instance;

                int w = Tile.Width - 1;
                int h = Tile.Height - 1;

                foreach (Tile tile in matrix.Tiles)
                {
                    int x = tile.Position.X + 1;
                    int y = tile.Position.Y + 1;

                    Square square = new Square
                    {
                        Alpha = 0.65f,
                        Color = tile.Impassable ? Color.IndianRed : Color.LimeGreen,
                        Bounds = new Rectangle(x, y, w, h)
                    };
                    squares.Add(square);
                }
                diagnosticTextureGrid = new FragmentedSquareGrid(squares);
            }

            spriteBatch.Begin();
            diagnosticTextureGrid.Draw(spriteBatch);
            spriteBatch.End();
        }