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


C# float2.ToInt2方法代码示例

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


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

示例1: ApplyOrders

        public void ApplyOrders(World world, float2 xy, MouseInput mi)
        {
            if (world.OrderGenerator == null) return;

            var orders = world.OrderGenerator.Order(world, xy.ToInt2(), mi).ToArray();
            orders.Do( o => world.IssueOrder( o ) );

            world.PlayVoiceForOrders(orders);
        }
开发者ID:FMode,项目名称:OpenRA,代码行数:9,代码来源:WorldInteractionControllerWidget.cs

示例2: DoExplosion

        public static void DoExplosion(Actor attacker, string weapontype, float2 pos, int altitude)
        {
            var args = new ProjectileArgs
            {
                src = pos.ToInt2(),
                dest = pos.ToInt2(),
                srcAltitude = altitude,
                destAltitude = altitude,
                firedBy = attacker,
                target = Target.FromPos(pos),
                weapon = Rules.Weapons[ weapontype.ToLowerInvariant() ],
                facing = 0
            };

            if (args.weapon.Report != null)
                Sound.Play(args.weapon.Report + ".aud", pos);

            DoImpacts(args);
        }
开发者ID:geckosoft,项目名称:OpenRA,代码行数:19,代码来源:Combat.cs

示例3: DrawSprite

        public void DrawSprite(Sprite s, float2 location, string palette, float2 size)
        {
            if (s.sheet != currentSheet)
                Flush();

            currentSheet = s.sheet;
            Util.FastCreateQuad(vertices, indices, location.ToInt2(), s, Game.world.WorldRenderer.GetPaletteIndex(palette), nv, ni, size);
            nv += 4; ni += 6;
            if (++sprites >= spritesPerBatch)
                Flush();
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:11,代码来源:SpriteRenderer.cs

示例4: DrawSprite

        public void DrawSprite(Sprite s, float2 location, int paletteIndex, float2 size)
        {
            Renderer.CurrentBatchRenderer = this;

            if (s.sheet != currentSheet)
                Flush();

            if( nv + 4 > Renderer.TempBufferSize )
                Flush();

            currentSheet = s.sheet;
            Util.FastCreateQuad(vertices, location.ToInt2(), s, paletteIndex, nv, size);
            nv += 4;
        }
开发者ID:maruchinu,项目名称:OpenRA,代码行数:14,代码来源:SpriteRenderer.cs

示例5: ApplyOrders

        public void ApplyOrders(World world, float2 xy, MouseInput mi)
        {
            if (world.OrderGenerator == null) return;

            var orders = world.OrderGenerator.Order(world, xy.ToInt2(), mi).ToArray();
            Game.orderManager.IssueOrders( orders );

            // Find an actor with a phrase to say
            var done = false;
            foreach (var o in orders)
            {
                foreach (var v in o.Subject.TraitsImplementing<IOrderVoice>())
                {
                    if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o), o.Subject, o.Subject.Owner.Country.Race))
                    {
                        done = true;
                        break;
                    }
                }
                if (done) break;
            }
        }
开发者ID:subspace,项目名称:OpenRA,代码行数:22,代码来源:WorldInteractionControllerWidget.cs

示例6: Draw

        public override void Draw()
        {
            buttons.Clear();

            if( world.LocalPlayer == null ) return;

            var manager = world.LocalPlayer.PlayerActor.Trait<SupportPowerManager>();
            var powers = manager.Powers.Where(p => !p.Value.Disabled);
            var numPowers = powers.Count();
            if (numPowers == 0) return;

            var rectBounds = RenderBounds;
            WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-top"),new float2(rectBounds.X,rectBounds.Y));
            for (var i = 1; i < numPowers; i++)
                WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-middle"), new float2(rectBounds.X, rectBounds.Y + i * 51));
            WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-bottom"), new float2(rectBounds.X, rectBounds.Y + numPowers * 51));

            // Hack Hack Hack
            rectBounds.Width = 69;
            rectBounds.Height = 10 + numPowers * 51 + 21;

            var y = rectBounds.Y + 10;
            foreach (var kv in powers)
            {
                var sp = kv.Value;
                var image = spsprites[sp.Info.Image];

                var drawPos = new float2(rectBounds.X + 5, y);
                var rect = new Rectangle(rectBounds.X + 5, y, 64, 48);

                if (rect.Contains(Viewport.LastMousePos))
                {
                    var pos = drawPos.ToInt2();
                    var tl = new int2(pos.X-3,pos.Y-3);
                    var m = new int2(pos.X+64+3,pos.Y+48+3);
                    var br = tl + new int2(64+3+20,40);

                    if (sp.TotalTime > 0)
                        br += new int2(0,20);

                    if (sp.Info.LongDesc != null)
                        br += Game.Renderer.Fonts["Regular"].Measure(sp.Info.LongDesc.Replace("\\n", "\n"));
                    else
                        br += new int2(300,0);

                    var border = WidgetUtils.GetBorderSizes("dialog4");

                    WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(tl.X, tl.Y, m.X + border[3], m.Y),
                        PanelSides.Left | PanelSides.Top | PanelSides.Bottom | PanelSides.Center);
                    WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X - border[2], tl.Y, br.X, m.Y + border[1]),
                        PanelSides.Top | PanelSides.Right | PanelSides.Center);
                    WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X, m.Y - border[1], br.X, br.Y),
                        PanelSides.Left | PanelSides.Right | PanelSides.Bottom | PanelSides.Center);

                    pos += new int2(77, 5);
                    Game.Renderer.Fonts["Bold"].DrawText(sp.Info.Description, pos, Color.White);

                    if (sp.TotalTime > 0)
                    {
                        pos += new int2(0,20);
                        Game.Renderer.Fonts["Bold"].DrawText(WidgetUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
                        Game.Renderer.Fonts["Bold"].DrawText("/ {0}".F(WidgetUtils.FormatTime(sp.TotalTime)), pos + new int2(45,0), Color.White);
                    }

                    if (sp.Info.LongDesc != null)
                    {
                        pos += new int2(0, 20);
                        Game.Renderer.Fonts["Regular"].DrawText(sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
                    }
                }

                WidgetUtils.DrawSHP(image, drawPos, worldRenderer);

                clock.PlayFetchIndex("idle",
                    () => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime)
                        * (clock.CurrentSequence.Length - 1) / sp.TotalTime);
                clock.Tick();

                WidgetUtils.DrawSHP(clock.Image, drawPos, worldRenderer);

                var overlay = sp.Ready ? "ready" : sp.Active ? null : "hold";
                if (overlay != null)
                {
                    ready.Play(overlay);
                    WidgetUtils.DrawSHP(ready.Image, drawPos + new float2((64 - ready.Image.size.X) / 2, 2), worldRenderer);
                }

                buttons.Add(Pair.New(rect,HandleSupportPower(kv.Key, manager)));

                y += 51;
            }
        }
开发者ID:hoxworth,项目名称:OpenRA,代码行数:92,代码来源:SupportPowerBinWidget.cs

示例7: Scroll

        public void Scroll(float2 delta, bool ignoreBorders)
        {
            var d = delta.ToInt2();
            var newScrollPosition = scrollPosition + d;

            if(!ignoreBorders)
                newScrollPosition = this.NormalizeScrollPosition(newScrollPosition);

            scrollPosition = newScrollPosition;
        }
开发者ID:geckosoft,项目名称:OpenRA,代码行数:10,代码来源:Viewport.cs

示例8: DrawInner

        public override void DrawInner(World world)
        {
            buttons.Clear();

            var powers = world.LocalPlayer.PlayerActor.TraitsImplementing<SupportPower>();
            var numPowers = powers.Count(p => p.IsAvailable);
            if (numPowers == 0) return;
            var rectBounds = RenderBounds;
            WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-top"),new float2(rectBounds.X,rectBounds.Y));
            for (var i = 1; i < numPowers; i++)
                WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world,"specialbin-middle"), new float2(rectBounds.X, rectBounds.Y + i * 51));
            WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world,"specialbin-bottom"), new float2(rectBounds.X, rectBounds.Y + numPowers * 51));

            Game.Renderer.RgbaSpriteRenderer.Flush();

            // Hack Hack Hack
            rectBounds.Width = 69;
            rectBounds.Height = 10 + numPowers * 51 + 21;

            var y = rectBounds.Y + 10;
            foreach (var sp in powers)
            {
                var image = spsprites[sp.Info.Image];
                if (sp.IsAvailable)
                {
                    var drawPos = new float2(rectBounds.X + 5, y);
                    var rect = new Rectangle(rectBounds.X + 5, y, 64, 48);

                    if (rect.Contains(Viewport.LastMousePos.ToPoint()))
                    {
                        var pos = drawPos.ToInt2();
                        var tl = new int2(pos.X-3,pos.Y-3);
                        var m = new int2(pos.X+64+3,pos.Y+48+3);
                        var br = tl + new int2(64+3+20,60);

                        if (sp.Info.LongDesc != null)
                            br += Game.Renderer.RegularFont.Measure(sp.Info.LongDesc.Replace("\\n", "\n"));
                        else
                            br += new int2(300,0);

                        var border = WidgetUtils.GetBorderSizes("dialog4");

                        WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(tl.X, tl.Y, m.X + border[3], m.Y),
                            PanelSides.Left | PanelSides.Top | PanelSides.Bottom);
                        WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X - border[2], tl.Y, br.X, m.Y + border[1]),
                            PanelSides.Top | PanelSides.Right);
                        WidgetUtils.DrawPanelPartial("dialog4", Rectangle.FromLTRB(m.X, m.Y - border[1], br.X, br.Y),
                            PanelSides.Left | PanelSides.Right | PanelSides.Bottom);

                        pos += new int2(77, 5);
                        Game.Renderer.BoldFont.DrawText(sp.Info.Description, pos, Color.White);

                        pos += new int2(0,20);
                        Game.Renderer.BoldFont.DrawText(WorldUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
                        Game.Renderer.BoldFont.DrawText("/ {0}".F(WorldUtils.FormatTime(sp.TotalTime)), pos + new int2(45,0), Color.White);

                        if (sp.Info.LongDesc != null)
                        {
                            pos += new int2(0, 20);
                            Game.Renderer.RegularFont.DrawText(sp.Info.LongDesc.Replace("\\n", "\n"), pos, Color.White);
                        }
                    }

                    WidgetUtils.DrawSHP(image, drawPos);

                    clock.PlayFetchIndex("idle",
                        () => (sp.TotalTime - sp.RemainingTime)
                            * (clock.CurrentSequence.Length - 1) / sp.TotalTime);
                    clock.Tick();

                    WidgetUtils.DrawSHP(clock.Image, drawPos);

                    if (sp.IsReady)
                    {
                        ready.Play("ready");
                        WidgetUtils.DrawSHP(ready.Image, drawPos + new float2((64 - ready.Image.size.X) / 2, 2));
                    }

                    buttons.Add(Pair.New(rect,HandleSupportPower(sp)));

                    y += 51;
                }
            }
            Game.Renderer.WorldSpriteRenderer.Flush();
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:85,代码来源:SpecialPowerBinWidget.cs


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