コード例 #1
0
        private void drawBoxes()
        {
            XnaColor constantBox = XnaColor.Lerp(Level.BackgroundColor.Inverted, XnaColor.Red, .5f);
            XnaColor screenBox   = XnaColor.Lerp(Level.BackgroundColor.Inverted, XnaColor.Blue, .5f);

            Vector topLeft  = ActiveCamera.getGameCoordinate(Vector.Zero);
            Vector botRight = ActiveCamera.getGameCoordinate(new Vector(GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight));



            //draw screen-box
            int    screenWidth  = 1280;
            int    screenHeight = 720;
            Vector screenSize   = new Vector(screenWidth, screenHeight);
            Vector center       = (topLeft + botRight) / 2;

            Vector screenTopLeft  = center - screenSize / 2;
            Vector screenBotRight = center + screenSize / 2;
            Vector screenBoxSize  = screenBotRight - screenTopLeft;



            drawBox(spriteBatch, screenBox, .02f, 4, screenTopLeft, screenBotRight);
            drawBox(spriteBatch, constantBox, .03f, 8, Vector.Zero, Vector.Zero + screenSize);

            if (Level.PreviewHud)
            {
                spriteBatch.Draw(hudObjectsTarget, screenTopLeft, null, XnaColor.White);
            }
        }
コード例 #2
0
        private void drawGrid()
        {
            Vector topLeft  = ActiveCamera.getGameCoordinate(Vector.Zero);
            Vector botRight = ActiveCamera.getGameCoordinate(new Vector(GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight));
            Vector size     = botRight - topLeft;


            float    intensity = Level.BackgroundColor.Intensity;
            XnaColor lineColor = Level.BackgroundColor.Inverted;

            if (intensity > .4f && intensity < .6f)
            {
                lineColor = XnaColor.Lerp(lineColor, XnaColor.White, 1 - Math.Abs(.5f - intensity));
            }


            float currY = GridManager.Instance.snapY(topLeft.Y);//topLeft.Y - (topLeft.Y % gridSize);

            while (currY < botRight.Y)
            {
                XnaColor color = lineColor;
                if (currY == 0)
                {
                    color = Level.BackgroundColor.Inverted;
                }
                drawLine(spriteBatch, ((WhiskeyColor)lineColor).Inverted, 0f, new Vector(topLeft.X, currY), new Vector(botRight.X, currY), 8f);
                drawLine(spriteBatch, color, .01f, new Vector(topLeft.X, currY), new Vector(botRight.X, currY), 4f);
                spriteBatch.DrawString(WhiskeyControl.Resources.getDefaultFont(), "" + currY, new Vector2(topLeft.X, currY - WhiskeyControl.Resources.getDefaultFont().MeasureString("A").Y), XnaColor.Tomato, 0, Vector2.Zero, 1 / ActiveCamera.Zoom, SpriteEffects.None, .04f);

                currY += GridManager.Instance.GridSizeY;
            }

            float currX = GridManager.Instance.snapX(topLeft.X);//topLeft.X - (topLeft.X % gridSize);

            while (currX < botRight.X)
            {
                XnaColor color = lineColor;
                if (currX == 0)
                {
                    color = Level.BackgroundColor.Inverted;
                }
                drawLine(spriteBatch, ((WhiskeyColor)lineColor).Inverted, 0f, new Vector(currX, topLeft.Y), new Vector(currX, botRight.Y), 8.0f);
                drawLine(spriteBatch, color, .01f, new Vector(currX, topLeft.Y), new Vector(currX, botRight.Y), 4.0f);

                spriteBatch.DrawString(WhiskeyControl.Resources.getDefaultFont(), "" + currX, new Vector2(currX - WhiskeyControl.Resources.getDefaultFont().MeasureString("A").X, topLeft.Y), XnaColor.Tomato, (float)Math.PI / 2f, Vector2.Zero, 1 / ActiveCamera.Zoom, SpriteEffects.None, .04f);


                currX += GridManager.Instance.GridSizeX;
            }
        }