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


C# WorldRenderer.ScreenPosition方法代码示例

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


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

示例1: Render

		public void Render(WorldRenderer wr)
		{
			// Need at least 4 points to smooth the contrail over
			if (length - skip < 4)
				return;

			var wlr = Game.Renderer.WorldLineRenderer;
			var oldWidth = wlr.LineWidth;
			wlr.LineWidth = wr.Viewport.Zoom;

			// Start of the first line segment is the tail of the list - don't smooth it.
			var curPos = trail[Index(next - skip - 1)];
			var curColor = color;
			for (var i = 0; i < length - skip - 4; i++)
			{
				var j = next - skip - i - 2;
				var nextPos = Average(trail[Index(j)], trail[Index(j - 1)], trail[Index(j - 2)], trail[Index(j - 3)]);
				var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent);

				if (!world.FogObscures(curPos) && !world.FogObscures(nextPos))
					wlr.DrawLine(wr.ScreenPosition(curPos), wr.ScreenPosition(nextPos), curColor, nextColor);

				curPos = nextPos;
				curColor = nextColor;
			}

			wlr.LineWidth = oldWidth;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:28,代码来源:ContrailRenderable.cs

示例2: RenderAfterWorld

        public void RenderAfterWorld(WorldRenderer wr, Actor self)
        {
            if (devMode == null || !devMode.ShowMuzzles)
                return;

            if (health.Value != null)
                wr.DrawRangeCircle(Color.Red, wr.ScreenPxPosition(self.CenterPosition), health.Value.Info.Radius / Game.CellSize);

            var wlr = Game.Renderer.WorldLineRenderer;
            var c = Color.White;

            foreach (var a in armaments.Value)
            {
                foreach (var b in a.Barrels)
                {
                    var muzzle = self.CenterPosition + a.MuzzleOffset(self, b);
                    var dirOffset = new WVec(0, -224, 0).Rotate(a.MuzzleOrientation(self, b));

                    var sm = wr.ScreenPosition(muzzle);
                    var sd = wr.ScreenPosition(muzzle + dirOffset);
                    wlr.DrawLine(sm, sd, c, c);
                    wr.DrawTargetMarker(c, sm);
                }
            }
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:25,代码来源:CombatDebugOverlay.cs

示例3: RenderAfterWorld

        public void RenderAfterWorld(WorldRenderer wr, Actor self)
        {
            foreach (var i in impacts)
            {
                var alpha = 255.0f * i.Time / info.DisplayDuration;
                var rangeStep = alpha / i.Range.Length;

                RangeCircleRenderable.DrawRangeCircle(wr, i.CenterPosition, i.OuterRange,
                    1, Color.FromArgb((int)alpha, i.Color), 0, i.Color);

                foreach (var r in i.Range)
                {
                    var tl = wr.ScreenPosition(i.CenterPosition - new WVec(r.Length, r.Length, 0));
                    var br = wr.ScreenPosition(i.CenterPosition + new WVec(r.Length, r.Length, 0));
                    var rect = RectangleF.FromLTRB(tl.X, tl.Y, br.X, br.Y);

                    Game.Renderer.WorldRgbaColorRenderer.FillEllipse(rect, Color.FromArgb((int)alpha, i.Color));

                    alpha -= rangeStep;
                }

                if (!wr.World.Paused)
                    i.Time--;
            }

            impacts.RemoveAll(i => i.Time == 0);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:27,代码来源:WarheadDebugOverlay.cs

示例4: Render

		public void Render(WorldRenderer wr)
		{
			var wlr = Game.Renderer.WorldLineRenderer;
			var src = wr.ScreenPosition(pos);
			var dest = wr.ScreenPosition(pos + length);

			var oldWidth = wlr.LineWidth;
			wlr.LineWidth = wr.Viewport.Zoom * width;
			wlr.DrawLine(src, dest, color);
			wlr.LineWidth = oldWidth;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:11,代码来源:BeamRenderable.cs

示例5: RenderAfterWorld

        public void RenderAfterWorld(WorldRenderer wr, Actor self)
        {
            if (devMode == null || !devMode.ShowCombatGeometry)
                return;

            if (health.Value != null)
                wr.DrawRangeCircle(self.CenterPosition, health.Value.Info.Radius, Color.Red);

            // No armaments to draw
            if (attack.Value == null)
                return;

            var wlr = Game.Renderer.WorldLineRenderer;
            var c = Color.White;

            // Fire ports on garrisonable structures
            var garrison = attack.Value as AttackGarrisoned;
            if (garrison != null)
            {
                var bodyOrientation = coords.Value.QuantizeOrientation(self, self.Orientation);
                foreach (var p in garrison.Ports)
                {
                    var pos = self.CenterPosition + coords.Value.LocalToWorld(p.Offset.Rotate(bodyOrientation));
                    var da = coords.Value.LocalToWorld(new WVec(224, 0, 0).Rotate(WRot.FromYaw(p.Yaw + p.Cone)).Rotate(bodyOrientation));
                    var db = coords.Value.LocalToWorld(new WVec(224, 0, 0).Rotate(WRot.FromYaw(p.Yaw - p.Cone)).Rotate(bodyOrientation));

                    var o = wr.ScreenPosition(pos);
                    var a = wr.ScreenPosition(pos + da * 224 / da.Length);
                    var b = wr.ScreenPosition(pos + db * 224 / db.Length);
                    wlr.DrawLine(o, a, c, c);
                    wlr.DrawLine(o, b, c, c);
                }

                return;
            }

            foreach (var a in attack.Value.Armaments)
            {
                foreach (var b in a.Barrels)
                {
                    var muzzle = self.CenterPosition + a.MuzzleOffset(self, b);
                    var dirOffset = new WVec(0, -224, 0).Rotate(a.MuzzleOrientation(self, b));

                    var sm = wr.ScreenPosition(muzzle);
                    var sd = wr.ScreenPosition(muzzle + dirOffset);
                    wlr.DrawLine(sm, sd, c, c);
                    wr.DrawTargetMarker(c, sm);
                }
            }
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:50,代码来源:CombatDebugOverlay.cs

示例6: GenerateRenderables

		public IEnumerable<IRenderable> GenerateRenderables(WorldRenderer wr)
		{
			var bright = wr.world.Map.SequenceProvider.GetSequence(image, "bright");
			var dim = wr.world.Map.SequenceProvider.GetSequence(image, "dim");
			
			var source = wr.ScreenPosition(pos);
			var target = wr.ScreenPosition(pos + length);
			
			for (var n = 0; n < dimZaps; n++)
				foreach (var z in DrawZapWandering(wr, source, target, dim, palette))
					yield return z;
			for (var n = 0; n < brightZaps; n++)
				foreach (var z in DrawZapWandering(wr, source, target, bright, palette))
					yield return z;
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:15,代码来源:TeslaZapRenderable.cs

示例7: DrawRangeCircle

        public static void DrawRangeCircle(WorldRenderer wr, WPos centerPosition, WDist radius,
			float width, Color color, float contrastWidth, Color contrastColor)
        {
            var wcr = Game.Renderer.WorldRgbaColorRenderer;
            var offset = new WVec(radius.Length, 0, 0);
            for (var i = 0; i < RangeCircleSegments; i++)
            {
                var a = wr.ScreenPosition(centerPosition + offset.Rotate(RangeCircleStartRotations[i]));
                var b = wr.ScreenPosition(centerPosition + offset.Rotate(RangeCircleEndRotations[i]));

                if (contrastWidth > 0)
                    wcr.DrawLine(a, b, contrastWidth / wr.Viewport.Zoom, contrastColor);

                if (width > 0)
                    wcr.DrawLine(a, b, width / wr.Viewport.Zoom, color);
            }
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:17,代码来源:RangeCircleRenderable.cs

示例8: RenderAfterWorld

        public void RenderAfterWorld(WorldRenderer wr, Actor self)
        {
            if (devMode == null || !devMode.ShowMuzzles)
                return;

            var wlr = Game.Renderer.WorldLineRenderer;
            var c = Color.White;

            foreach (var a in armaments.Value)
                foreach (var b in a.Barrels)
                {
                    var muzzle = self.CenterPosition + a.MuzzleOffset(self, b);
                    var dirOffset = new WVec(0,-224,0).Rotate(a.MuzzleOrientation(self, b));

                    var sm = wr.ScreenPosition(muzzle);
                    var sd = wr.ScreenPosition(muzzle + dirOffset);
                    wlr.DrawLine(sm, sd, c, c);
                    wlr.DrawLine(sm + new float2(-1, -1), sm + new float2(-1, 1), c, c);
                    wlr.DrawLine(sm + new float2(-1, 1), sm + new float2(1, 1), c, c);
                    wlr.DrawLine(sm + new float2(1, 1), sm + new float2(1, -1), c, c);
                    wlr.DrawLine(sm + new float2(1, -1), sm + new float2(-1, -1), c, c);
                }
        }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:23,代码来源:DebugMuzzlePositions.cs

示例9: TerrainRenderer

		public TerrainRenderer(World world, WorldRenderer wr)
		{
			this.world = world;
			this.map = world.Map;

			var terrainPalette = wr.Palette("terrain").Index;
			var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width];
			var nv = 0;

			foreach (var cell in map.Cells)
			{
				var tile = wr.Theater.TileSprite(map.MapTiles.Value[cell]);
				var pos = wr.ScreenPosition(map.CenterOfCell(cell)) - 0.5f * tile.size;
				Util.FastCreateQuad(vertices, pos, tile, terrainPalette, nv, tile.size);
				nv += 4;
			}

			vertexBuffer = Game.Renderer.Device.CreateVertexBuffer(vertices.Length);
			vertexBuffer.SetData(vertices, nv);
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:20,代码来源:TerrainRenderer.cs

示例10: TerrainRenderer

        public TerrainRenderer(World world, WorldRenderer wr)
        {
            this.world = world;
            this.map = world.Map;

            var terrainPalette = wr.Palette("terrain").Index;
            var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width];
            int nv = 0;

            for (var j = map.Bounds.Top; j < map.Bounds.Bottom; j++)
            {
                for (var i = map.Bounds.Left; i < map.Bounds.Right; i++)
                {
                    var tile = wr.Theater.TileSprite(map.MapTiles.Value[i, j]);
                    var pos = wr.ScreenPosition(new CPos(i, j).CenterPosition) - 0.5f * tile.size;
                    Util.FastCreateQuad(vertices, pos, tile, terrainPalette, nv, tile.size);
                    nv += 4;
                }
            }

            vertexBuffer = Game.Renderer.Device.CreateVertexBuffer(vertices.Length);
            vertexBuffer.SetData(vertices, nv);
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:23,代码来源:TerrainRenderer.cs

示例11: Render

        public void Render(WorldRenderer wr)
        {
            var wcr = Game.Renderer.WorldRgbaColorRenderer;
            var center = wr.ScreenPosition(centerPosition);

            for (var i = 0; i < trailCount; i++)
            {
                var angle = trailAngle - new WAngle(i * (trailSeparation.Angle <= 512 ? 1 : -1));
                var length = radius.Length * new WVec(angle.Cos(), angle.Sin(), 0) / 1024;
                var end = wr.ScreenPosition(centerPosition + length);
                var alpha = color.A - i * color.A / trailCount;

                wcr.DrawLine(center, end, 3, Color.FromArgb(alpha, contrastColor));
                wcr.DrawLine(center, end, 1, Color.FromArgb(alpha, color));
            }

            RangeCircleRenderable.DrawRangeCircle(wr, centerPosition, radius, 1, color, 3, contrastColor);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:18,代码来源:DetectionCircleRenderable.cs

示例12: WorldLoaded

        public void WorldLoaded(World w, WorldRenderer wr)
        {
            // Initialize tile cache
            // This includes the region outside the visible area to cover any sprites peeking outside the map
            foreach (var uv in w.Map.AllCells.MapCoords)
            {
                var pos = w.Map.CenterOfCell(uv.ToCPos(map));
                var screen = wr.ScreenPosition(pos - new WVec(0, 0, pos.Z));
                var variant = (byte)Game.CosmeticRandom.Next(info.ShroudVariants.Length);
                tileInfos[uv] = new TileInfo(screen, variant);
            }

            // Dirty the whole projected space
            DirtyCells(map.AllCells.MapCoords.Select(uv => (PPos)uv));

            // All tiles are visible in the editor
            if (w.Type == WorldType.Editor)
                visibleUnderShroud = _ => true;
            else
                visibleUnderShroud = puv => map.Contains(puv);

            visibleUnderFog = puv => map.Contains(puv);

            var shroudSheet = shroudSprites[0].Sheet;
            if (shroudSprites.Any(s => s.Sheet != shroudSheet))
                throw new InvalidDataException("Shroud sprites span multiple sheets. Try loading their sequences earlier.");

            var shroudBlend = shroudSprites[0].BlendMode;
            if (shroudSprites.Any(s => s.BlendMode != shroudBlend))
                throw new InvalidDataException("Shroud sprites must all use the same blend mode.");

            var fogSheet = fogSprites[0].Sheet;
            if (fogSprites.Any(s => s.Sheet != fogSheet))
                throw new InvalidDataException("Fog sprites span multiple sheets. Try loading their sequences earlier.");

            var fogBlend = fogSprites[0].BlendMode;
            if (fogSprites.Any(s => s.BlendMode != fogBlend))
                throw new InvalidDataException("Fog sprites must all use the same blend mode.");

            shroudLayer = new TerrainSpriteLayer(w, wr, shroudSheet, shroudBlend, wr.Palette(info.ShroudPalette), false);
            fogLayer = new TerrainSpriteLayer(w, wr, fogSheet, fogBlend, wr.Palette(info.FogPalette), false);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:42,代码来源:ShroudRenderer.cs

示例13: RenderAfterWorld

        public void RenderAfterWorld(WorldRenderer wr, Actor self)
        {
            if (devMode == null || !devMode.ShowCombatGeometry)
                return;

            var wcr = Game.Renderer.WorldRgbaColorRenderer;
            var iz = 1 / wr.Viewport.Zoom;

            if (healthInfo != null)
                healthInfo.Shape.DrawCombatOverlay(wr, wcr, self);

            var blockers = allBlockers.Where(Exts.IsTraitEnabled).ToList();
            if (blockers.Count > 0)
            {
                var hc = Color.Orange;
                var height = new WVec(0, 0, blockers.Max(b => b.BlockingHeight.Length));
                var ha = wr.ScreenPosition(self.CenterPosition);
                var hb = wr.ScreenPosition(self.CenterPosition + height);
                wcr.DrawLine(ha, hb, iz, hc);
                TargetLineRenderable.DrawTargetMarker(wr, hc, ha);
                TargetLineRenderable.DrawTargetMarker(wr, hc, hb);
            }

            foreach (var attack in self.TraitsImplementing<AttackBase>().Where(x => !x.IsTraitDisabled))
                DrawArmaments(self, attack, wr, wcr, iz);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:26,代码来源:CombatDebugOverlay.cs

示例14: DrawArmaments

        void DrawArmaments(Actor self, AttackBase attack, WorldRenderer wr, RgbaColorRenderer wcr, float iz)
        {
            var c = Color.White;

            // Fire ports on garrisonable structures
            var garrison = attack as AttackGarrisoned;
            if (garrison != null)
            {
                var bodyOrientation = coords.Value.QuantizeOrientation(self, self.Orientation);
                foreach (var p in garrison.Info.Ports)
                {
                    var pos = self.CenterPosition + coords.Value.LocalToWorld(p.Offset.Rotate(bodyOrientation));
                    var da = coords.Value.LocalToWorld(new WVec(224, 0, 0).Rotate(WRot.FromYaw(p.Yaw + p.Cone)).Rotate(bodyOrientation));
                    var db = coords.Value.LocalToWorld(new WVec(224, 0, 0).Rotate(WRot.FromYaw(p.Yaw - p.Cone)).Rotate(bodyOrientation));

                    var o = wr.ScreenPosition(pos);
                    var a = wr.ScreenPosition(pos + da * 224 / da.Length);
                    var b = wr.ScreenPosition(pos + db * 224 / db.Length);
                    wcr.DrawLine(o, a, iz, c);
                    wcr.DrawLine(o, b, iz, c);
                }

                return;
            }

            foreach (var a in attack.Armaments)
            {
                foreach (var b in a.Barrels)
                {
                    var muzzle = self.CenterPosition + a.MuzzleOffset(self, b);
                    var dirOffset = new WVec(0, -224, 0).Rotate(a.MuzzleOrientation(self, b));

                    var sm = wr.ScreenPosition(muzzle);
                    var sd = wr.ScreenPosition(muzzle + dirOffset);
                    wcr.DrawLine(sm, sd, iz, c);
                    TargetLineRenderable.DrawTargetMarker(wr, c, sm);
                }
            }
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:39,代码来源:CombatDebugOverlay.cs

示例15: Render

 public void Render(WorldRenderer wr)
 {
     var screenPos = wr.Viewport.Zoom*(wr.ScreenPosition(pos) - wr.Viewport.TopLeft.ToFloat2()) - 0.5f*font.Measure(text).ToFloat2();
     var screenPxPos = new float2((float)Math.Round(screenPos.X), (float)Math.Round(screenPos.Y));
     font.DrawTextWithContrast(text, screenPxPos, color, Color.Black, 1);
 }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:6,代码来源:TextRenderable.cs


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