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


C# int2.ToInt2方法代码示例

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


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

示例1: DrawProductionTooltip

        void DrawProductionTooltip(World world, string unit, int2 pos)
        {
            pos.Y += 15;

            var pl = world.LocalPlayer;
            var p = pos.ToFloat2() - new float2(297, -3);

            var info = Rules.Info[unit];
            var tooltip = info.Traits.Get<TooltipInfo>();
            var buildable = info.Traits.Get<BuildableInfo>();
            var cost = info.Traits.Get<ValuedInfo>().Cost;
            var canBuildThis = CurrentQueue.CanBuild(info);

            var longDescSize = Game.Renderer.Fonts["Regular"].Measure(tooltip.Description.Replace("\\n", "\n")).Y;
            if (!canBuildThis) longDescSize += 8;

            WidgetUtils.DrawPanel("dialog4", new Rectangle(Game.viewport.Width - 300, pos.Y, 300, longDescSize + 65));

            Game.Renderer.Fonts["Bold"].DrawText(
                tooltip.Name + ((buildable.Hotkey != null)? " ({0})".F(buildable.Hotkey.ToUpper()) : ""),
                                                   p.ToInt2() + new int2(5, 5), Color.White);

            var resources = pl.PlayerActor.Trait<PlayerResources>();
            var power = pl.PlayerActor.Trait<PowerManager>();

            DrawRightAligned("${0}".F(cost), pos + new int2(-5, 5),
                (resources.DisplayCash + resources.DisplayOre >= cost ? Color.White : Color.Red ));

            var lowpower = power.PowerState != PowerState.Normal;
            var time = CurrentQueue.GetBuildTime(info.Name)
                * ((lowpower)? CurrentQueue.Info.LowPowerSlowdown : 1);
            DrawRightAligned(WidgetUtils.FormatTime(time), pos + new int2(-5, 35), lowpower ? Color.Red: Color.White);

            var bi = info.Traits.GetOrDefault<BuildingInfo>();
            if (bi != null)
                DrawRightAligned("{1}{0}".F(bi.Power, bi.Power > 0 ? "+" : ""), pos + new int2(-5, 20),
                                 ((power.PowerProvided - power.PowerDrained) >= -bi.Power || bi.Power > 0)? Color.White: Color.Red);

            p += new int2(5, 35);
            if (!canBuildThis)
            {
                var prereqs = buildable.Prerequisites
                    .Select( a => Description( a ) );
                Game.Renderer.Fonts["Regular"].DrawText(
                    "Requires {0}".F(string.Join(", ", prereqs.ToArray())),
                    p.ToInt2(),
                    Color.White);

                p += new int2(0, 8);
            }

            p += new int2(0, 15);
            Game.Renderer.Fonts["Regular"].DrawText(tooltip.Description.Replace("\\n", "\n"),
                p.ToInt2(), Color.White);
        }
开发者ID:hoxworth,项目名称:OpenRA,代码行数:55,代码来源:BuildPaletteWidget.cs

示例2: DrawProductionTooltip

        void DrawProductionTooltip(World world, string unit, Hotkey hotkey, int2 pos)
        {
            pos.Y += 15;

            var pl = world.LocalPlayer;
            var p = pos.ToFloat2() - new float2(297, -3);

            var info = world.Map.Rules.Actors[unit];
            var tooltip = info.Traits.Get<TooltipInfo>();
            var buildable = info.Traits.Get<BuildableInfo>();
            var cost = info.Traits.Get<ValuedInfo>().Cost;
            var canBuildThis = CurrentQueue.CanBuild(info);

            var longDescSize = Game.Renderer.Fonts["Regular"].Measure(tooltip.Description.Replace("\\n", "\n")).Y;
            if (!canBuildThis) longDescSize += 8;

            WidgetUtils.DrawPanel("dialog4", new Rectangle(Game.Renderer.Resolution.Width - 300, pos.Y, 300, longDescSize + 65));

            Game.Renderer.Fonts["Bold"].DrawText(
                tooltip.Name + (hotkey.IsValid() ? " ({0})".F(hotkey.DisplayString()) : ""),
                                                   p.ToInt2() + new int2(5, 5), Color.White);

            var resources = pl.PlayerActor.Trait<PlayerResources>();
            var power = pl.PlayerActor.Trait<PowerManager>();

            DrawRightAligned("${0}".F(cost), pos + new int2(-5, 5),
                (resources.DisplayCash + resources.DisplayResources >= cost ? Color.White : Color.Red));

            var lowpower = power.PowerState != PowerState.Normal;
            var time = CurrentQueue.GetBuildTime(info.Name)
                * ((lowpower) ? CurrentQueue.Info.LowPowerSlowdown : 1);
            DrawRightAligned(WidgetUtils.FormatTime(time), pos + new int2(-5, 35), lowpower ? Color.Red : Color.White);

            var pi = info.Traits.GetOrDefault<PowerInfo>();
            if (pi != null)
                DrawRightAligned("{1}{0}".F(pi.Amount, pi.Amount > 0 ? "+" : ""), pos + new int2(-5, 20),
                    ((power.PowerProvided - power.PowerDrained) >= -pi.Amount || pi.Amount > 0) ? Color.White : Color.Red);

            p += new int2(5, 35);
            if (!canBuildThis)
            {
                var prereqs = buildable.Prerequisites.Select(s => Description(world.Map.Rules, s)).Where(s => !s.StartsWith("~"));
                if (prereqs.Any())
                {
                    Game.Renderer.Fonts["Regular"].DrawText(RequiresText.F(prereqs.JoinWith(", ")), p.ToInt2(), Color.White);

                    p += new int2(0, 8);
                }
            }

            p += new int2(0, 15);
            Game.Renderer.Fonts["Regular"].DrawText(tooltip.Description.Replace("\\n", "\n"),
                p.ToInt2(), Color.White);
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:54,代码来源:BuildPaletteWidget.cs


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