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


C# CPos.ToMPos方法代码示例

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


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

示例1: CoarseToMapProjection

        public void CoarseToMapProjection()
        {
            foreach (var gridType in Enum.GetValues(typeof(MapGridType)).Cast<MapGridType>())
            {
                for (var x = 0; x < 12; x++)
                {
                    for (var y = 0; y < 12; y++)
                    {
                        var cell = new CPos(x, y);
                        try
                        {
                            Assert.That(cell, Is.EqualTo(cell.ToMPos(gridType).ToCPos(gridType)));
                        }
                        catch
                        {
                            // Known problem on isometric mods that shouldn't be visible to players as these are outside the map.
                            if (gridType == MapGridType.RectangularIsometric && y > x)
                                continue;

                            Console.WriteLine("Coordinate {0} on grid type {1} failed to convert back.".F(cell, gridType));
                            throw;
                        }
                    }
                }
            }
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:26,代码来源:CoordinateTest.cs

示例2: ConvertToPreview

 public int2 ConvertToPreview(CPos cell)
 {
     var preview = Preview();
     var tileShape = Game.ModData.Manifest.TileShape;
     var point = cell.ToMPos(tileShape);
     var dx = (int)(previewScale * (point.U - preview.Bounds.Left));
     var dy = (int)(previewScale * (point.V - preview.Bounds.Top));
     return new int2(mapRect.X + dx, mapRect.Y + dy);
 }
开发者ID:ushardul,项目名称:OpenRA,代码行数:9,代码来源:MapPreviewWidget.cs

示例3: Update

 public void Update(CPos cell, Sprite sprite)
 {
     var pos = sprite == null ? float2.Zero :
         worldRenderer.ScreenPosition(map.CenterOfCell(cell)) + sprite.Offset - 0.5f * sprite.Size;
     Update(cell.ToMPos(map.Grid.Type), sprite, pos);
 }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:6,代码来源:TerrainSpriteLayer.cs

示例4: ConvertToPreview

        public int2 ConvertToPreview(CPos cell, MapGridType gridType)
        {
            var preview = Preview();
            var point = cell.ToMPos(gridType);
            var cellWidth = gridType == MapGridType.RectangularIsometric ? 2 : 1;
            var dx = (int)(previewScale * cellWidth * (point.U - preview.Bounds.Left));
            var dy = (int)(previewScale * (point.V - preview.Bounds.Top));

            // Odd rows are shifted right by 1px
            if ((point.V & 1) == 1)
                dx += 1;

            return new int2(mapRect.X + dx, mapRect.Y + dy);
        }
开发者ID:xavieryang007,项目名称:OpenRA,代码行数:14,代码来源:MapPreviewWidget.cs

示例5: ConvertToPreview

        public int2 ConvertToPreview(CPos cell)
        {
            var preview = Preview();
            var tileShape = Game.ModData.Manifest.TileShape;
            var point = cell.ToMPos(tileShape);
            var dx = (int)(previewScale * cellWidth * (point.U - preview.Bounds.Left));
            var dy = (int)(previewScale * (point.V - preview.Bounds.Top));

            // Odd rows are shifted right by 1px
            if ((point.V & 1) == 1)
                dx += 1;

            return new int2(mapRect.X + dx, mapRect.Y + dy);
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:14,代码来源:MapPreviewWidget.cs

示例6: UpdateTerrainCell

        void UpdateTerrainCell(CPos cell)
        {
            var uv = cell.ToMPos(world.Map);

            if (!world.Map.CustomTerrain.Contains(uv))
                return;

            var custom = world.Map.CustomTerrain[uv];
            int leftColor, rightColor;
            if (custom == byte.MaxValue)
            {
                var type = world.Map.Rules.TileSet.GetTileInfo(world.Map.Tiles[uv]);
                leftColor = type != null ? type.LeftColor.ToArgb() : Color.Black.ToArgb();
                rightColor = type != null ? type.RightColor.ToArgb() : Color.Black.ToArgb();
            }
            else
                leftColor = rightColor = world.Map.Rules.TileSet[custom].Color.ToArgb();

            var stride = radarSheet.Size.Width;

            unsafe
            {
                fixed (byte* colorBytes = &radarData[0])
                {
                    var colors = (int*)colorBytes;
                    if (isRectangularIsometric)
                    {
                        // Odd rows are shifted right by 1px
                        var dx = uv.V & 1;
                        if (uv.U + dx > 0)
                            colors[uv.V * stride + 2 * uv.U + dx - 1] = leftColor;

                        if (2 * uv.U + dx < stride)
                            colors[uv.V * stride + 2 * uv.U + dx] = rightColor;
                    }
                    else
                        colors[uv.V * stride + uv.U] = leftColor;
                }
            }
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:40,代码来源:RadarWidget.cs

示例7: CellToMinimapPixel

        int2 CellToMinimapPixel(CPos p)
        {
            var uv = p.ToMPos(world.Map);
            var dx = (int)(previewScale * cellWidth * (uv.U - world.Map.Bounds.Left));
            var dy = (int)(previewScale * (uv.V - world.Map.Bounds.Top));

            // Odd rows are shifted right by 1px
            if (isRectangularIsometric && (uv.V & 1) == 1)
                dx += 1;

            return new int2(mapRect.X + dx, mapRect.Y + dy);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:12,代码来源:RadarWidget.cs

示例8: IsVisible

		public bool IsVisible(CPos cell)
		{
			return IsVisible(cell.ToMPos(map));
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:4,代码来源:Shroud.cs

示例9: IsExplored

		public bool IsExplored(CPos cell)
		{
			return IsExplored(cell.ToMPos(map));
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:4,代码来源:Shroud.cs

示例10: UpdateCell

        public void UpdateCell(CPos cell)
        {
            var uv = cell.ToMPos(map.TileShape);
            var offset = rowStride * (uv.V - map.Bounds.Top) + 4 * (uv.U - map.Bounds.Left);

            GenerateTileVertices(updateCellVertices, 0, cell);
            vertexBuffer.SetData(updateCellVertices, offset, 4);
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:8,代码来源:TerrainRenderer.cs

示例11: UpdateTerrainCell

        void UpdateTerrainCell(CPos cell)
        {
            if (!world.Map.Contains(cell))
                return;

            var stride = radarSheet.Size.Width;
            var uv = cell.ToMPos(world.Map);

            var custom = world.Map.CustomTerrain[uv];
            Color color;
            if (custom == byte.MaxValue)
            {
                var type = world.TileSet.GetTileInfo(world.Map.MapTiles.Value[uv]);
                color = type != null ? type.LeftColor : Color.Black;
            }
            else
                color = world.TileSet[custom].Color;

            var dx = terrainSprite.Bounds.Left - world.Map.Bounds.Left;
            var dy = terrainSprite.Bounds.Top - world.Map.Bounds.Top;

            unsafe
            {
                fixed (byte* colorBytes = &radarData[0])
                {
                    var colors = (int*)colorBytes;
                    colors[(uv.V + dy) * stride + uv.U + dx] = color.ToArgb();
                }
            }
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:30,代码来源:RadarWidget.cs

示例12: UpdateShroudCell

        void UpdateShroudCell(CPos cell)
        {
            if (!world.Map.Contains(cell))
                return;

            var stride = radarSheet.Size.Width;
            var uv = cell.ToMPos(world.Map);
            var dx = shroudSprite.Bounds.Left - world.Map.Bounds.Left;
            var dy = shroudSprite.Bounds.Top - world.Map.Bounds.Top;

            var color = 0;
            if (world.ShroudObscures(cell))
                color = Color.Black.ToArgb();
            else if (world.FogObscures(cell))
                color = Color.FromArgb(128, Color.Black).ToArgb();

            unsafe
            {
                fixed (byte* colorBytes = &radarData[0])
                {
                    var colors = (int*)colorBytes;
                    colors[(uv.V + dy) * stride + uv.U + dx] = color;
                }
            }
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:25,代码来源:RadarWidget.cs

示例13: CellToMinimapPixel

 int2 CellToMinimapPixel(CPos p)
 {
     var uv = p.ToMPos(world.Map);
     var mapOffset = new float2(uv.U - world.Map.Bounds.Left, uv.V - world.Map.Bounds.Top);
     return new int2(mapRect.X, mapRect.Y) + (previewScale * mapOffset).ToInt2();
 }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:6,代码来源:RadarWidget.cs

示例14: IsVisible

 public bool IsVisible(CPos cell)
 {
     var uv = cell.ToMPos(map);
     return IsVisible(uv);
 }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:5,代码来源:Shroud.cs


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