Exemplo n.º 1
0
        public void Draw(SpriteBatch spriteBatch, SpriteFont font)
        {
            if (open)
            {
                //int ratio = Game1.HEIGHT / texture.Height;
                int height = Game1.HEIGHT - 20; //texture.Height * ratio;
                int width  = Game1.WIDTH - 20;  //texture.Width * ratio;
                int x      = (Game1.WIDTH - width) / 2;
                int y      = 10;

                spriteBatch.Draw(texture, new Rectangle(x, y, width, height), Color.White);

                Rectangle textRect1 = new Rectangle(50, 80, (width - 150) / 2, height - 110);
                Rectangle textRect2 = new Rectangle(width / 2 + 70, 80, (width - 150) / 2, height - 110);
                Rectangle curRect   = textRect1;

                int h = (int)font.MeasureString("A").Y;
                y = curRect.Y;

                foreach (Hint hint in hints)
                {
                    List <string> lines = TextWrap.Wrap(hint.Text, curRect.Width, font);
                    foreach (string line in lines)
                    {
                        spriteBatch.DrawString(font, line, new Vector2(curRect.X, y), Color.Black);
                        y += 2 * h;
                        if (y > curRect.Y + curRect.Height)
                        {
                            curRect = textRect2;
                            y       = curRect.Y;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Draw(SpriteBatch spriteBatch, int cameraX)
        {
            int offset = 0;

            if (talker.Flip)
            {
                offset = Game1.HEIGHT / 3;
            }

            SpriteEffects effects = SpriteEffects.FlipHorizontally;

            if (talker.Flip)
            {
                effects = SpriteEffects.None;
            }
            spriteBatch.Draw(dialogBoxTexture, new Rectangle(offset, 2 * Game1.HEIGHT / 3 - 30, boxRect.Width, boxRect.Height), null, Color.White, 0, new Vector2(), effects, 0);

            if (talker.Flip)
            {
                talker.DrawFace(spriteBatch, 10, Game1.HEIGHT * 2 / 3 - 10);
            }
            else
            {
                talker.DrawFace(spriteBatch, Game1.WIDTH - Game1.HEIGHT / 3 - 10, Game1.HEIGHT * 2 / 3 - 10);
            }

            Rectangle textRect = new Rectangle(offset + 50, 2 * Game1.HEIGHT / 3 + 20, boxRect.Width - 150, boxRect.Height - 100);

            int           lineHeight = (int)font.MeasureString(text).Y;
            List <string> lines      = TextWrap.Wrap(text, textRect.Width, font);

            for (int i = 0; i < lines.Count; i++)
            {
                spriteBatch.DrawString(font, lines[i],
                                       new Vector2(textRect.X, textRect.Y + i * lineHeight),
                                       Color.Black, 0, new Vector2(0, 0), 1, SpriteEffects.None, 0);
            }
        }