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


C# WorldRenderer.Position方法代码示例

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


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

示例1: Render

        public IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr)
        {
            var pos = wr.ScreenPxPosition(self.CenterPosition);
            var bounds = self.Bounds.Value;
            bounds.Offset(pos.X, pos.Y);
            var spaceBuffer = (int)(10 / wr.Viewport.Zoom);
            var effectPos = wr.Position(new int2(pos.X, bounds.Y - spaceBuffer));

            yield return new TextRenderable(font, effectPos, 0, color, name);
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:10,代码来源:RenderNameTag.cs

示例2: RenderAfterWorld

        public void RenderAfterWorld(WorldRenderer wr, World world)
        {
            var position = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
            var topLeft = position - FootprintUtils.AdjustForBuildingSize(BuildingInfo);

            var rules = world.Map.Rules;

            var actorInfo = rules.Actors[Building];
            foreach (var dec in actorInfo.Traits.WithInterface<IPlaceBuildingDecoration>())
                dec.Render(wr, world, actorInfo, position.CenterPosition);	/* hack hack */

            var cells = new Dictionary<CPos, bool>();
            // Linebuild for walls.
            // Assumes a 1x1 footprint; weird things will happen for other footprints
            if (rules.Actors[Building].Traits.Contains<LineBuildInfo>())
            {
                foreach (var t in BuildingUtils.GetLineBuildCells(world, topLeft, Building, BuildingInfo))
                    cells.Add(t, BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, t));
            }
            else
            {
                if (!initialized)
                {
                    var rbi = rules.Actors[Building].Traits.GetOrDefault<RenderBuildingInfo>();
                    if (rbi == null)
                        preview = new IRenderable[0];
                    else
                    {
                        var palette = rbi.Palette ?? (Producer.Owner != null ?
                            rbi.PlayerPalette + Producer.Owner.InternalName : null);

                        preview = rbi.RenderPreview(world, rules.Actors[Building], wr.Palette(palette));
                    }

                    initialized = true;
                }

                var offset = topLeft.CenterPosition + FootprintUtils.CenterOffset(BuildingInfo) - WPos.Zero;
                foreach (var r in preview)
                    r.OffsetBy(offset).Render(wr);

                var res = world.WorldActor.Trait<ResourceLayer>();
                var isCloseEnough = BuildingInfo.IsCloseEnoughToBase(world, world.LocalPlayer, Building, topLeft);
                foreach (var t in FootprintUtils.Tiles(rules, Building, BuildingInfo, topLeft))
                    cells.Add(t, isCloseEnough && world.IsCellBuildable(t, BuildingInfo) && res.GetResource(t) == null);
            }

            var pal = wr.Palette("terrain");
            foreach (var c in cells)
            {
                var tile = c.Value ? buildOk : buildBlocked;
                new SpriteRenderable(tile, c.Key.CenterPosition,
                    WVec.Zero, -511, pal, 1f, true).Render(wr);
            }
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:55,代码来源:PlaceBuildingOrderGenerator.cs

示例3: Render

        public IEnumerable<IRenderable> Render(WorldRenderer wr)
        {
            if (!self.IsInWorld)
                yield break;

            if (self.IsDead())
                yield break;

            if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
                yield break;

            if (wr.world.FogObscures(self))
                yield break;

            var pos = wr.ScreenPxPosition(self.CenterPosition);
            var bounds = self.Bounds.Value;
            bounds.Offset(pos.X, pos.Y);

            var offset = (int)(4 / wr.Viewport.Zoom);
            var effectPos = wr.Position(new int2(bounds.Right - offset, bounds.Bottom - offset));
            yield return new SpriteRenderable(anim.Image, effectPos, WVec.Zero, 0, wr.Palette("effect"), 1f / wr.Viewport.Zoom, true);
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:22,代码来源:Rank.cs

示例4: DrawZap

        static IEnumerable<IRenderable> DrawZap(WorldRenderer wr, float2 from, float2 to, Sequence s, out float2 p, string palette)
        {
            var dist = to - from;
            var q = new float2(-dist.Y, dist.X);
            var c = -float2.Dot(from, q);
            var rs = new List<IRenderable>();
            var z = from;
            var pal = wr.Palette(palette);

            while ((to - z).X > 5 || (to - z).X < -5 || (to - z).Y > 5 || (to - z).Y < -5)
            {
                var step = steps.Where(t => (to - (z + new float2(t[0], t[1]))).LengthSquared < (to - z).LengthSquared)
                    .OrderBy(t => Math.Abs(float2.Dot(z + new float2(t[0], t[1]), q) + c)).First();

                var pos = wr.Position((z + new float2(step[2], step[3])).ToInt2());
                rs.Add(new SpriteRenderable(s.GetSprite(step[4]), pos, WVec.Zero, 0, pal, 1f, true));

                z += new float2(step[0], step[1]);
                if (rs.Count >= 1000)
                    break;
            }

            p = z;

            return rs;
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:26,代码来源:TeslaZapRenderable.cs

示例5: RenderAfterWorld

 public void RenderAfterWorld(WorldRenderer wr, World world)
 {
     var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
     foreach (var unit in power.UnitsInRange(xy))
         wr.DrawSelectionBox(unit, Color.Red);
 }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:6,代码来源:IronCurtainPower.cs

示例6: Render

 public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
 {
     var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
     var pal = wr.Palette("terrain");
     foreach (var t in world.FindTilesInCircle(xy, range))
         yield return new SpriteRenderable(tile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);
 }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:7,代码来源:IronCurtainPower.cs

示例7: RenderAfterWorld

 public void RenderAfterWorld(WorldRenderer wr, World world)
 {
     var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
     var targetUnits = power.UnitsInRange(xy);
     foreach (var unit in targetUnits)
         if (manager.self.Owner.Shroud.IsTargetable(unit) || manager.self.Owner.HasFogVisibility())
             wr.DrawSelectionBox(unit, Color.Red);
 }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:8,代码来源:ChronoshiftPower.cs

示例8: Render

            public IEnumerable<IRenderable> Render(WorldRenderer wr, World world)
            {
                var xy = wr.Position(wr.Viewport.ViewToWorldPx(Viewport.LastMousePos)).ToCPos();
                var pal = wr.Palette("terrain");

                // Source tiles
                foreach (var t in world.FindTilesInCircle(sourceLocation, range))
                    yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);

                // Destination tiles
                foreach (var t in world.FindTilesInCircle(xy, range))
                    yield return new SpriteRenderable(sourceTile, t.CenterPosition, WVec.Zero, -511, pal, 1f, true);

                // Unit previews
                foreach (var unit in power.UnitsInRange(sourceLocation))
                {
                    var offset = (xy - sourceLocation).ToWVec();
                    if (manager.self.Owner.Shroud.IsTargetable(unit))
                        foreach (var r in unit.Render(wr))
                            yield return r.OffsetBy(offset);
                }

                // Unit tiles
                foreach (var unit in power.UnitsInRange(sourceLocation))
                {
                    if (manager.self.Owner.Shroud.IsTargetable(unit))
                    {
                        var targetCell = unit.Location + (xy - sourceLocation);
                        var canEnter = ((manager.self.Owner.Shroud.IsExplored(targetCell) || manager.self.Owner.HasFogVisibility()) &&
                                        unit.Trait<Chronoshiftable>().CanChronoshiftTo(unit,targetCell));
                        var tile = canEnter ? validTile : invalidTile;
                        yield return new SpriteRenderable(tile, targetCell.CenterPosition, WVec.Zero, -511, pal, 1f, true);
                    }
                }
            }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:35,代码来源:ChronoshiftPower.cs


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