Example #1
0
        public List <Rectangle> GenerateHighscoreTableLines(ref GraphicsDeviceManager graphics)
        {
            // Those Rectangles represent the Lines of the table!
            List <Rectangle> lines = new List <Rectangle>();

            int hZero = graphics.PreferredBackBufferHeight;
            int bZero = graphics.PreferredBackBufferWidth;

            List <int> dimensions = Extension.CalculateDimensionsInPixel(ref graphics);

            // Offsets correct some lack of pixels in certain places
            // Out: Moves the table up a abit
            // Inline: Adds some Pixels to the horizontal lines to match the grid
            int offsetOut    = (int)Math.Round((double)hZero * 0.020);
            int offsetInline = (int)Math.Round((double)hZero * 0.004);

            // Horizontal Lines ([0]-[10])
            lines.Add(new Rectangle(dimensions[6], dimensions[3], dimensions[7] + offsetInline, 4));
            for (int i = 0; i < 10; i++)
            {
                lines.Add(new Rectangle(dimensions[6], dimensions[3] + (dimensions[2] * lines.Count + 1), dimensions[7] + offsetInline, 4));
            }

            // Vertical Lines ([11]-[14])
            lines.Add(new Rectangle(bZero - dimensions[6], dimensions[1] - offsetOut, 4, dimensions[0] + (int)(offsetInline * 2)));
            lines.Add(new Rectangle(dimensions[6] + dimensions[10] + dimensions[8], dimensions[3], 4, dimensions[0] - dimensions[3]));
            lines.Add(new Rectangle(dimensions[6] + dimensions[10], dimensions[3], 4, dimensions[0] - dimensions[3]));
            lines.Add(new Rectangle(dimensions[3], dimensions[1] - offsetOut, 4, dimensions[0] + (int)(offsetInline * 2)));

            return(lines);
        }
Example #2
0
        /// <summary>
        /// Generator for the position of the detailview buttons
        /// </summary>
        /// <param name="gdm"></param>
        /// <returns></returns>
        public static List <Rectangle> GenerateViewButtonPositions(ref GraphicsDeviceManager gdm)
        {
            List <Rectangle> positions  = new List <Rectangle>();
            List <int>       dimensions = Extension.CalculateDimensionsInPixel(ref gdm);

            int hZero = gdm.GraphicsDevice.DisplayMode.Height;
            int bZero = gdm.GraphicsDevice.DisplayMode.Width;

            int pictureWidth  = 0;
            int pictureHeight = 0;

            if (hZero < 1080)
            {
                pictureHeight = 150;
                pictureWidth  = 150;
            }
            else
            {
                pictureHeight = 200;
                pictureWidth  = 200;
            }

            int yStart = dimensions[3] + 4;

            for (int i = 0; i < 10; i++)
            {
                if (i == 0)
                {
                    positions.Add(new Rectangle((dimensions[6] + dimensions[9]), dimensions[4], pictureWidth, pictureHeight));
                }
                if (i == 1)
                {
                    positions.Add(new Rectangle(dimensions[6] + dimensions[8] + dimensions[10] + 8, yStart + (4 + dimensions[2] * 1), dimensions[8], dimensions[2]));
                }
                else
                {
                    positions.Add(new Rectangle(dimensions[6] + dimensions[8] + dimensions[10] + 8, yStart + (4 + dimensions[2] * i), dimensions[8], dimensions[2]));
                }
            }

            return(positions);
        }
Example #3
0
        public void Draw(Microsoft.Xna.Framework.GameTime gameTime, ref Microsoft.Xna.Framework.Graphics.SpriteBatch sp, ref Microsoft.Xna.Framework.GraphicsDeviceManager g, ref Microsoft.Xna.Framework.Graphics.SpriteFont font)
        {
            sp.Begin();

            g.GraphicsDevice.Clear(Color.Black);

            /// Logic for drawing the ActiveBackground
            ActiveBackground.DrawSky();
            ActiveBackground.DrawSunrays();
            ActiveBackground.DrawFlowers();
            ActiveBackground.DrawGrass();
            ActiveBackground.DrawSun();
            ActiveBackground.DrawCloud1();
            ActiveBackground.DrawCloud2();
            ActiveBackground.DrawCloud3();
            ActiveBackground.DrawCloud4();
            ActiveBackground.DrawCloud5();

            // sp.Draw(background, new Rectangle(0, 0, g.PreferredBackBufferWidth, g.PreferredBackBufferHeight), Color.White);

            // sp.DrawString(font, "Highscore", new Vector2(20, 20), Color.Black);

            /// <summary>
            /// Draws all the Lines necessary for the table to be displayed
            /// </summary>
            int index = 0;

            foreach (Rectangle line in lines)
            {
                sp.Draw(lineTexture, lines[index], Color.OrangeRed);
                index++;
            }

            int offsetX = (int)Math.Round((double)g.PreferredBackBufferWidth * 0.020);
            int offsetY = (int)Math.Round((double)g.PreferredBackBufferHeight * 0.020);

            /// <summary>
            /// Draws the linenumbers onto the table
            /// </summary>
            for (int i = 0; i < 10; i++)
            {
                switch (i)
                {
                case 0:
                {
                    sp.DrawString(GameSpecs.scoreFont, (i + 1).ToString(), new Vector2(lines[i].X + offsetX, lines[i].Y - (int)(offsetY * 10)), Color.OrangeRed);
                    break;
                }

                case 1:
                case 2:
                case 3:
                case 4:
                case 5:
                case 6:
                case 7:
                case 8:
                case 9:
                {
                    sp.DrawString(font, (i + 1).ToString(), new Vector2(lines[i - 1].X + offsetX, lines[i - 1].Y + offsetY), Color.OrangeRed);
                    break;
                }
                }
            }

            ///<summary>
            /// Writes the Highscores into the table
            ///</summary>

            int[] scores = scoreValues.ToArray();

            for (int i = 0; i < 10; i++)
            {
                if (i == 0)
                {
                    sp.DrawString(GameSpecs.scoreFont, scores[i].ToString(), new Vector2(lines[i].X + offsetX * 20, lines[i].Y + (int)(offsetY - offsetY * 11)), Color.OrangeRed);
                }
                else
                {
                    sp.DrawString(font, scores[i].ToString(), new Vector2(lines[i - 1].X + offsetX * 4, lines[i - 1].Y + offsetY), Color.OrangeRed);
                }
            }

            // Draw the Button(s)
            foreach (Button btn in bl)
            {
                sp.Draw(btn.Texture, new Rectangle((int)btn.Position.X, (int)btn.Position.Y, btn.SourceRectangle.Width, btn.SourceRectangle.Height), Color.White);
            }

            List <int> dimensions = Extension.CalculateDimensionsInPixel(ref g);

            int pictureWidth  = 0;
            int pictureHeight = 0;

            if (g.GraphicsDevice.DisplayMode.Height < 1080)
            {
                pictureHeight = 150;
                pictureWidth  = 150;
            }
            else
            {
                pictureHeight = 200;
                pictureWidth  = 200;
            }
            // Draws the picture of the leader of the highscore-ladder to the screen
            sp.Draw(player_picture_frame, new Rectangle((dimensions[6] + dimensions[9]) - 15, dimensions[4] - 15, pictureWidth + 30, pictureHeight + 30), Color.White);
            sp.Draw(leader_picture, new Rectangle(dimensions[6] + dimensions[9], dimensions[4], pictureWidth, pictureHeight), Color.White);

            sp.End();
        }