本文整理汇总了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;
}
}
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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);
}
示例8: IsVisible
public bool IsVisible(CPos cell)
{
return IsVisible(cell.ToMPos(map));
}
示例9: IsExplored
public bool IsExplored(CPos cell)
{
return IsExplored(cell.ToMPos(map));
}
示例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);
}
示例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();
}
}
}
示例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;
}
}
}
示例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();
}
示例14: IsVisible
public bool IsVisible(CPos cell)
{
var uv = cell.ToMPos(map);
return IsVisible(uv);
}