當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。