当前位置: 首页>>代码示例>>C#>>正文


C# Renderer.DrawText方法代码示例

本文整理汇总了C#中Renderer.DrawText方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.DrawText方法的具体用法?C# Renderer.DrawText怎么用?C# Renderer.DrawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Renderer的用法示例。


在下文中一共展示了Renderer.DrawText方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: drawMenuOptions

        private void drawMenuOptions(Renderer renderer)
        {
            Vector2 minScale = Game1.MinScreenScaleFactor;
            float fontSize = Font.DefaultSize * minScale.Y;
            Vector2 position = new Vector2(400.0f) * minScale;
            Vector2 textSize = Vector2.Zero;
            for (int i = 0; i < Menu.MenuOptions.Length; ++i)
            {
                string text = Menu.MenuOptions[i];
                textSize = renderer.Font.MeasureString(text, fontSize);
                renderer.DrawText(text, position, Color.White, 0.0f, Vector2.Zero, minScale);

                if (i == overworldState.CurrentMenuOptionIndex)
                {
                    Vector2 arrowSize = renderer.Font.MeasureString(">", fontSize);
                    renderer.DrawText(">", position - new Vector2(arrowSize.X, 0.0f), Color.White, 0.0f, Vector2.Zero, minScale);
                }

                position.Y += textSize.Y * 1.1f;
            }
            position.Y += textSize.Y * 2.2f;
            renderer.DrawText("TIPS:", position, Color.White, 0.0f, Vector2.Zero, minScale);
            position.Y += textSize.Y * 1.1f;
            renderer.DrawText("- Move your party around for strategic layouts", position, Color.White, 0.0f, Vector2.Zero, minScale);
            position.Y += textSize.Y * 1.1f;
            renderer.DrawText("- The front line defends the party members at the back", position, Color.White, 0.0f, Vector2.Zero, minScale);
            position.Y += textSize.Y * 1.1f;
            renderer.DrawText("- Shields will give extra defence, and will be returned to the inventory if unscathed during a round", position, Color.White, 0.0f, Vector2.Zero, minScale);
            position.Y += textSize.Y * 1.1f;
            renderer.DrawText("- You can only use ranged weapons when you're not in the front line", position, Color.White, 0.0f, Vector2.Zero, minScale);
            position.Y += textSize.Y * 1.1f;
            renderer.DrawText("- The more items you use, the more you win back at the end of a battle", position, Color.White, 0.0f, Vector2.Zero, minScale);
            position.Y += textSize.Y * 1.1f;
            renderer.DrawText("- Don't be afraid to use items. You'll win more items than you started with", position, Color.White, 0.0f, Vector2.Zero, minScale);
            position.Y += textSize.Y * 1.1f;
            renderer.DrawText("- Try to work out what the items do to build a decent strategy", position, Color.White, 0.0f, Vector2.Zero, minScale);
        }
开发者ID:supermaximo93,项目名称:SuperFantasticSteampunk,代码行数:37,代码来源:MenuRenderer.cs

示例2: DrawUIAbove

        public void DrawUIAbove(GameTime gameTime, Renderer renderer, Player localPlayer, Vector2 offset)
        {
            Context g = renderer.Context;
            Vector2 position = GetPosition(renderer, offset);

            renderer.DrawText(position, ((Player)Unit.Owner).Number.ToString(), renderer.GetUnitSize((double)Arena.Config.ActorSize / 2) * 0.7, TextAlign.Center, TextAlign.Middle, ColorPresets.White, (Unit.Team == Teams.Home ? Arena.Config.HomeColor2 : Arena.Config.AwayColor2), null, 0, "chunky_aa");

            g.Save();

            double rangeRadius = renderer.GetUnitSize() * Unit.AttackRange;
            double rangeCircum = 2 * MathHelper.Pi * rangeRadius;
            double start = gameTime.TotalGameTime.TotalSeconds / MathHelper.TwoPi * 1;
            double[] dash = new double[] { rangeCircum / 80, rangeCircum / 120 };
            g.SetDash(dash, 0);
            g.LineWidth = 2;
            g.Arc(position.X, position.Y, rangeRadius, start, start + MathHelper.TwoPi);
            g.SetSourceRGBA(0, 0, 0, 0.1);
            g.Stroke();
            g.Restore();
        }
开发者ID:adamrezich,项目名称:arena,代码行数:20,代码来源:Actor.cs

示例3: Draw

        public static void Draw(GameTime gameTime, Renderer renderer, Player player)
        {
            Context g = renderer.Context;
            if (player == null)
                return;

            // SCOREBOARD
            int sbTop = 3;
            if (ScoreboardScale > 0) {
                renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), "HOME", 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, Config.HomeColor2, 0, "chunky");
                sbTop++;
                foreach (KeyValuePair<int, Player> kvp in Client.Local.Players) {
                    if (kvp.Value.Team == Teams.Home) {
                        renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), kvp.Value.Name.ToUpper(), 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
                        sbTop++;
                    }
                }
                renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), "AWAY", 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, Config.AwayColor2, 0, "chunky");
                sbTop++;
                foreach (KeyValuePair<int, Player> kvp in Client.Local.Players) {
                    if (kvp.Value.Team == Teams.Away) {
                        renderer.DrawText(new Vector2(BoxWidth + Margin - 400 + (float)(400 * ScoreboardScale), Margin + sbTop * 22), kvp.Value.Name.ToUpper(), 20, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
                        sbTop++;
                    }
                }
            }

            // LEFT
            DrawBox(renderer, LeftBox, Arena.Config.HUDBackground, null);

            // health background
            g.MoveTo(new Vector2(0 + Margin, 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin + BarWidth), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2(0 + Margin, renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.ClosePath();
            renderer.StrokeAndFill(new Cairo.Color(0, 0, 0), null);

            // health foreground
            if (player.CurrentUnit != null) {
                g.MoveTo(new Vector2(0 + Margin, renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetHealthPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetHealthPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.LineTo(new Vector2(0 + Margin, renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.ClosePath();
                renderer.StrokeAndFill(new Cairo.Color(0, 128, 0), null);
            }

            // energy background
            g.MoveTo(new Vector2((float)(0 + Margin * 2 + BarWidth), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.ClosePath();
            renderer.StrokeAndFill(new Cairo.Color(0, 0, 0), null);

            // energy foreground
            if (player.CurrentUnit != null) {
                g.MoveTo(new Vector2((float)(0 + Margin * 2 + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetEnergyPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetEnergyPercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 2 + BarWidth), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.ClosePath();
                renderer.StrokeAndFill(new Cairo.Color(0, 0, 128), null);
            }

            // experience background
            g.MoveTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), 0 + Margin * 2 + (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
            g.ClosePath();
            renderer.StrokeAndFill(new Cairo.Color(0, 0, 0), null);

            // experience foreground
            if (player.CurrentUnit != null) {
                g.MoveTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetExperiencePercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), renderer.Height - Margin * 2 - (float)MinimapSize - (float)(BarHeight * player.CurrentUnit.GetExperiencePercent())).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 3), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.LineTo(new Vector2((float)(0 + Margin * 3 + BarWidth * 2), renderer.Height - Margin * 2 - (float)MinimapSize).ToPointD());
                g.ClosePath();
                renderer.StrokeAndFill(new Cairo.Color(0, 128, 128), null);
            }

            // minimap
            DrawBox(renderer, MinimapBackground, new Cairo.Color(0, 0, 0), null);
            renderer.DrawText(MinimapBackground[0] + new Vector2((float)(MinimapSize / 2), (float)(MinimapSize / 2)), "MINIMAP", 14, TextAlign.Center, TextAlign.Middle, MainTextFill, MainTextStroke, null, 0, "chunky");

            // RIGHT
            DrawBox(renderer, RightBox, Arena.Config.HUDBackground, null);

            if (player.CurrentUnit != null) {
                DrawAbility(gameTime, renderer, player, 0);
                DrawAbility(gameTime, renderer, player, 2);
                DrawAbility(gameTime, renderer, player, 1);
                DrawAbility(gameTime, renderer, player, 3);
            }

            if (player.CurrentUnit != null) {
                renderer.DrawText(new Vector2(Margin, Margin), "MOVE SPEED: " + player.CurrentUnit.MoveSpeed.ToString(), 14, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, null, 0, "chunky");
//.........这里部分代码省略.........
开发者ID:adamrezich,项目名称:arena,代码行数:101,代码来源:HUD.cs

示例4: DrawAbility

 private static void DrawAbility(GameTime gameTime, Renderer renderer, Player player, int ability)
 {
     Context g = renderer.Context;
     DrawBox(renderer, Ability[ability], new Cairo.Color(0, 0, 0), null);
     if (player.CurrentUnit.Abilities[ability].Ready || player.CurrentUnit.Abilities[ability].ActivationType == AbilityActivationType.Passive) {
         if (player.CurrentUnit.Abilities[ability].Level > 0)
             if (player.CurrentUnit.Energy >= player.CurrentUnit.Abilities[ability].EnergyCost && player.CurrentUnit.Abilities[ability].ActivationType != AbilityActivationType.Passive)
                 DrawBox(renderer, Ability[ability], new Cairo.Color(0, 0.9, 0), null);
             else
                 DrawBox(renderer, Ability[ability], new Cairo.Color(0.25, 0.5, 0.25), null);
         else
             DrawBox(renderer, Ability[ability], new Cairo.Color(0.1, 0.2, 0.1), null);
     }
     else {
         DrawBox(renderer, Ability[ability], new Cairo.Color(0, 0, 0.9), null);
         Vector2 timerCenter = Ability[ability][0] + new Vector2((float)AbilitySize / 2);
         g.MoveTo(timerCenter.ToPointD());
         double angle = Math.Max(0, MathHelper.TwoPi - (player.CurrentUnit.Abilities[ability].ReadyTime - gameTime.TotalGameTime).TotalMilliseconds / player.CurrentUnit.Abilities[ability].Cooldown / 25 / MathHelper.TwoPi);
         double adjustedAngle = angle - MathHelper.PiOver2;
         double flip = angle % MathHelper.PiOver2;
         if (flip > MathHelper.PiOver4) {
             flip -= MathHelper.PiOver2;
             flip = Math.Abs(flip);
         }
         g.LineTo(timerCenter.AddLengthDir(AbilitySize / 2 / Math.Cos(flip), adjustedAngle).ToPointD());
         if (angle > 7 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][0].ToPointD());
         if (angle > 5 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][3].ToPointD());
         if (angle > 3 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][2].ToPointD());
         if (angle > 1 * MathHelper.PiOver4)
             g.LineTo(Ability[ability][1].ToPointD());
         g.LineTo(timerCenter.AddLengthDir(AbilitySize / 2, 3 * MathHelper.PiOver2).ToPointD());
         //g.LineTo(timerCenter.AddLengthDir(AbilitySize / 2, 3 * MathHelper.PiOver2).ToPointD());
         g.ClosePath();
         if (player.CurrentUnit.Energy >= player.CurrentUnit.Abilities[ability].EnergyCost)
             renderer.StrokeAndFill(new Cairo.Color(0, 0.5, 0), null);
         else
             renderer.StrokeAndFill(new Cairo.Color(0.25, 0.4, 0.25), null);
     }
     renderer.DrawText(Ability[ability][0] + new Vector2(Padding, Padding), player.CurrentUnit.Abilities[ability].Name.ToUpper(), 14, TextAlign.Left, TextAlign.Top, MainTextFill, MainTextStroke, AbilityNameBackground, 0, "chunky");
     if (player.CurrentUnit.Abilities[ability].ActivationType != AbilityActivationType.Passive) {
         renderer.DrawText(Ability[ability][1] + new Vector2(-Padding, Padding), TemporaryKeyList[ability], 19, TextAlign.Right, TextAlign.Top, MainTextFill, MainTextStroke, AbilityKeyBackground, 0, "chunky");
         renderer.DrawText(Ability[ability][2] + new Vector2(-Padding, -Padding), player.CurrentUnit.Abilities[ability].Cooldown.ToString(), 14, TextAlign.Right, TextAlign.Bottom, MainTextFill, MainTextStroke, AbilityCooldownBackground, 0, "chunky");
         renderer.DrawText(Ability[ability][3] + new Vector2(Padding, -Padding), player.CurrentUnit.Abilities[ability].EnergyCost.ToString(), 14, TextAlign.Left, TextAlign.Bottom, MainTextFill, MainTextStroke, AbilityEnergyBackground, 0, "chunky");
     }
     if (!player.CurrentUnit.Abilities[ability].Ready && player.CurrentUnit.Abilities[ability].ActivationType != AbilityActivationType.Passive) {
         string str = Math.Round(((double)(player.CurrentUnit.Abilities[ability].ReadyTime - gameTime.TotalGameTime).TotalMilliseconds) / (double)1000, 1).ToString().MakeDecimal();
         renderer.DrawText(Ability[ability][0] + new Vector2((float)(AbilitySize / 2), (float)(AbilitySize / 2)), str, 32, TextAlign.Center, TextAlign.Middle, MainTextFill, MainTextStroke, null, 0, "chunky");
     }
     Vector2 levelOrigin = Ability[ability][1] + new Vector2(-Padding - LevelBoxSize, (float)((AbilitySize / 2) - (LevelBoxSize * player.CurrentUnit.Abilities[ability].Levels) / 2 - (LevelBoxPadding * (player.CurrentUnit.Abilities[ability].Levels) / 2) + LevelBoxPadding / 2));
     for (var i = 0; i < player.CurrentUnit.Abilities[ability].Levels; i++) {
         DrawBox(renderer, new List<Vector2>() {
             levelOrigin + new Vector2(0, LevelBoxSize * i + LevelBoxPadding * i),
             levelOrigin + new Vector2(LevelBoxSize, LevelBoxSize * i + LevelBoxPadding * i),
             levelOrigin + new Vector2(LevelBoxSize, LevelBoxSize * i + LevelBoxSize + LevelBoxPadding * i),
             levelOrigin + new Vector2(0, LevelBoxSize * i + LevelBoxSize + LevelBoxPadding * i)
         }, (player.CurrentUnit.Abilities[ability].Level >= i + 1 ? new Cairo.Color(1, 1, 1) : new Cairo.Color(0, 0, 0)), new Cairo.Color(1, 1, 1));
     }
 }
开发者ID:adamrezich,项目名称:arena,代码行数:61,代码来源:HUD.cs

示例5: drawWinMessage

        private Vector2 drawWinMessage(float alpha, Renderer renderer)
        {
            Vector2 fontScale = new Vector2(Font.DefaultSize * 3.0f * minScale.Y);
            Vector2 textSize = renderer.Font.MeasureString(battleState.WinMessage, fontScale.X);
            Vector2 position = new Vector2(Game1.ScreenSize.X / 2.0f, textSize.Y * 2);
            renderer.DrawText(battleState.WinMessage, position, new Color(1.0f, 1.0f, 1.0f, alpha), 0.0f, textSize / 2.0f, fontScale / Font.DefaultSize);

            string spoilMessage = "Here's what you won:";
            fontScale = new Vector2(Font.DefaultSize * 1.5f * minScale.Y);
            textSize = renderer.Font.MeasureString(spoilMessage, fontScale.X);
            position += new Vector2(0.0f, textSize.Y * 2.5f);
            renderer.DrawText(spoilMessage, position, new Color(1.0f, 1.0f, 1.0f, alpha), 0.0f, textSize / 2.0f, fontScale / Font.DefaultSize);

            return position + new Vector2(0.0f, textSize.Y * 2.5f);
        }
开发者ID:supermaximo93,项目名称:SuperFantasticSteampunk,代码行数:15,代码来源:WinRenderer.cs

示例6: drawWonItemsText

        private void drawWonItemsText(Vector2 position, float alpha, Renderer renderer)
        {
            Color textColor = new Color(1.0f, 1.0f, 1.0f, alpha);
            float characterClassHeadPadding = 10.0f * minScale.X;

            int startIndex;
            int finishIndex;
            battleState.Battle.CalculateStartAndFinishIndexesForMenuList(battleState.ItemsWon.Count, visibleItemCount, battleState.CurrentItemIndex, out startIndex, out finishIndex);

            float fontSize = 14.0f * minScale.Y;
            float arrowFontSize = 18.0f * minScale.Y;
            Vector2 fontScale = new Vector2(fontSize / Font.DefaultSize);
            Vector2 arrowFontScale = new Vector2(arrowFontSize / Font.DefaultSize);
            Vector2 arrowSize = renderer.Font.MeasureString("^", arrowFontSize);
            arrowSize = new Vector2(arrowSize.Y, arrowSize.X);

            Vector2 upArrowPosition = Vector2.Zero;
            for (int i = startIndex; i <= finishIndex; ++i)
            {
                string text = battleState.ItemsWon[i].Item1.Replace('-', ' ');
                Vector2 textSize = renderer.Font.MeasureString(text, fontSize);
                renderer.DrawText(text, position, textColor, 0.0f, textSize / 2.0f, fontScale);

                CharacterClass characterClass = battleState.ItemsWon[i].Item2;
                if (characterClass != CharacterClass.Enemy)
                {
                    TextureData textureData = battleState.Battle.CharacterClassHeadTextureData[characterClass];
                    Vector2 scale = new Vector2((1.0f / textureData.Height) * textSize.Y);
                    renderer.Draw(textureData, position - new Vector2((textSize.X / 2.0f) + characterClassHeadPadding + (textureData.Width * scale.X), textSize.Y / 2.0f), Color.White, 0.0f, scale, false);
                }

                float yPositionIncrement = textSize.Y * 1.5f;
                if (i == startIndex)
                    upArrowPosition = new Vector2(position.X, position.Y - yPositionIncrement);
                position.Y += yPositionIncrement;
            }

            float yOffset = 10.0f * minScale.Y;
            if (arrowMoveTimer <= arrowMoveTime)
                yOffset *= arrowMoveTimer / arrowMoveTime;
            else
                yOffset *= 1.0f - ((arrowMoveTimer - arrowMoveTime) / arrowMoveTime);
            if (startIndex > 0)
                renderer.DrawText("^", new Vector2(upArrowPosition.X, upArrowPosition.Y - yOffset), textColor, 0.0f, arrowSize / 2.0f, arrowFontScale);
            if (finishIndex < battleState.ItemsWon.Count - 1)
                renderer.DrawText("^", new Vector2(position.X, position.Y + yOffset), textColor, 0.0f, arrowSize / 2.0f, new Vector2(arrowFontScale.X, -arrowFontScale.Y));
        }
开发者ID:supermaximo93,项目名称:SuperFantasticSteampunk,代码行数:47,代码来源:WinRenderer.cs

示例7: DrawChat

        public void DrawChat(Renderer renderer, Vector2 position, int entries)
        {
            string font = "pixel";
            int textSize = 12;

            renderer.Context.SelectFontFace(font, Cairo.FontSlant.Normal, Cairo.FontWeight.Normal);
            renderer.Context.SetFontSize(textSize);
            float chatHeight = (float)renderer.Context.FontExtents.Height;

            for (int i = 0; i < Math.Min(Client.Local.Messages.Count, entries); i++) {
                Message msg = Client.Local.Messages[Client.Local.Messages.Count - 1 - i];
                string str = msg.ToString();
                Cairo.Color? col = null;
                if (msg.Team == Teams.Home)
                    col = Config.HomeColor2;
                if (msg.Team == Teams.Away)
                    col = Config.AwayColor2;
                renderer.DrawText(position + new Vector2(0, -chatHeight * (float)((double)i + IsChattingScale)), str, 12, TextAlign.Left, TextAlign.Bottom, ColorPresets.White, ColorPresets.Black, col, 0, font, 0);
            }
            if (Client.Local.IsChatting) {
                Cairo.Color? col = null;
                if (!Client.Local.IsAllChatting && Client.Local.LocalPlayer.Team == Teams.Home)
                    col = Config.HomeColor2;
                if (!Client.Local.IsAllChatting && Client.Local.LocalPlayer.Team == Teams.Away)
                    col = Config.AwayColor2;
                renderer.DrawText(position + new Vector2(0, -chatHeight * (float)((double)-1 + IsChattingScale)), "> " + Client.Local.ChatBuffer, 12, TextAlign.Left, TextAlign.Bottom, ColorPresets.White, ColorPresets.Black, col, 0, "pixel", 0);
            }
        }
开发者ID:adamrezich,项目名称:arena,代码行数:28,代码来源:Client.cs

示例8: drawOptionNamesText

        private void drawOptionNamesText(Renderer renderer)
        {
            float fontHeight = renderer.Font.MeasureString("I", subMenuFontSize).Y;
            Vector2 scale = Game1.ScreenScaleFactor;
            Vector2 fontScale = new Vector2(subMenuFontSize / Font.DefaultSize) * Game1.ScreenScaleFactor.X;
            Vector2 position = new Vector2(subMenuX + subMenuPadding, subMenuY);
            float measureFontSize = Font.DefaultSize * fontScale.Y;
            Vector2 upArrowPosition = (position * scale) + new Vector2(subMenuWidth * Game1.ScreenScaleFactor.X * 0.5f, 0.0f);

            int startIndex;
            int finishIndex;
            battleState.Battle.CalculateStartAndFinishIndexesForMenuList(battleState.MenuOptions.Count, maxVisibleSubMenuOptions, battleState.CurrentOptionNameIndex, out startIndex, out finishIndex);

            for (int i = startIndex; i <= finishIndex; ++i)
            {
                ThinkMenuOption menuOption = battleState.MenuOptions[i];

                if (i == battleState.CurrentOptionNameIndex)
                {
                    Vector2 arrowPosition = (position - new Vector2(subMenuPadding, 0.0f)) * scale;
                    renderer.DrawText(">", arrowPosition, Color.White, 0.0f, Vector2.Zero, fontScale);
                    Vector2 arrowSize = renderer.Font.MeasureString(">", measureFontSize);
                    Vector2 buttonSize = new Vector2(renderer.Font.MeasureString("I", measureFontSize).Y);
                    Vector2 buttonPosition = arrowPosition - new Vector2(buttonSize.X + (arrowSize.X * 0.2f), (buttonSize.Y - (arrowSize.Y * 0.8f)) / 2.0f);
                    battleState.Battle.DrawButtonWithText(InputButton.A, null, buttonPosition, menuOption.Disabled ? Color.Gray : Color.White, renderer);
                    Vector2 containerSize = renderer.Font.MeasureString(menuOption.Description, measureFontSize) / scale;
                    Vector2 containerPosition = position + new Vector2(subMenuWidth + (borderTextureData[Battle.E].Width * 0.5f), 0.0f);
                    drawContainer(containerPosition.X, containerPosition.Y, containerSize.X, containerSize.Y, renderer);
                    renderer.DrawText(menuOption.Description, containerPosition * scale, Color.White, 0.0f, Vector2.Zero, fontScale);
                }

                renderer.DrawText(menuOption.Name.Replace('-', ' '), position * scale, menuOption.Disabled ? Color.Gray : Color.White, 0.0f, Vector2.Zero, fontScale);

                string amountString = menuOption.Amount < 0 ? "~" : menuOption.Amount.ToString();
                Vector2 amountSize = renderer.Font.MeasureString(amountString, subMenuFontSize);
                renderer.DrawText(amountString, (position + new Vector2(subMenuWidth - (subMenuPadding * 2) - amountSize.X, 0.0f)) * scale, menuOption.Disabled ? Color.Gray : Color.White, 0.0f, Vector2.Zero, fontScale);

                position.Y += fontHeight * fontHeightScale;
            }

            float arrowFontSize = measureFontSize * 1.5f;
            Vector2 arrowFontScale = fontScale * 1.5f;
            Vector2 scrollArrowSize = renderer.Font.MeasureString("^", arrowFontSize);
            scrollArrowSize = new Vector2(scrollArrowSize.Y, scrollArrowSize.X);
            float yOffset = 10.0f * scale.Y;
            if (arrowMoveTimer <= arrowMoveTime)
                yOffset *= arrowMoveTimer / arrowMoveTime;
            else
                yOffset *= 1.0f - ((arrowMoveTimer - arrowMoveTime) / arrowMoveTime);
            if (startIndex > 0)
                renderer.DrawText("^", new Vector2(upArrowPosition.X, upArrowPosition.Y - (scrollArrowSize.Y / 2.0f) - yOffset), Color.White, 0.0f, scrollArrowSize / 2.0f, arrowFontScale);
            if (finishIndex < battleState.MenuOptions.Count - 1)
                renderer.DrawText("^", new Vector2(upArrowPosition.X, (position.Y * scale.Y) + (scrollArrowSize.Y / 2.0f) + yOffset), Color.White, 0.0f, scrollArrowSize / 2.0f, new Vector2(arrowFontScale.X, -arrowFontScale.Y));
        }
开发者ID:supermaximo93,项目名称:SuperFantasticSteampunk,代码行数:54,代码来源:ThinkRenderer.cs


注:本文中的Renderer.DrawText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。