本文整理汇总了C#中MCForge.Utils.Vector3S.PathTo方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3S.PathTo方法的具体用法?C# Vector3S.PathTo怎么用?C# Vector3S.PathTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MCForge.Utils.Vector3S
的用法示例。
在下文中一共展示了Vector3S.PathTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BlockString
//TODO: fix if target is to close at origin
IEnumerable<Vector3S> BlockString(string text, Vector3S origin, Vector3S target, Vector3S lvlSize) {
Font font = new Font("Sans-serief",12);
Image tmp = new Bitmap(1000, 1000);
Bitmap img = new Bitmap((int)Graphics.FromImage(tmp).MeasureString(text, font).Width, (int)Graphics.FromImage(tmp).MeasureString(text, font).Height);
tmp = null;
Graphics g = Graphics.FromImage(img);
g.FillRectangle(Brushes.White, 0, 0, img.Width, img.Height);
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;
g.DrawString(text, font, Brushes.Black, new PointF(0, 0));
List<Vector3S> path = new List<Vector3S>();
foreach (Vector3S p in origin.PathTo(target)) {
path.Add(p);
}
if (path.Count < 2) yield break;
for (int x = 0; x < img.Width; x++) {
for (int y = 0; y < img.Height; y++) {
if (img.GetPixel(x, y).ToArgb() != Color.White.ToArgb()) {
Vector3S ret = new Vector3S();
ret.x = (short)(origin.x + ((path[x % path.Count].x - origin.x) + (path[path.Count - 1].x - origin.x + path[1].x - origin.x) * (x / path.Count)));
ret.y = (short)(origin.y + ((path[x % path.Count].y - origin.y) + (path[path.Count - 1].y - origin.y + path[1].y - origin.y) * (x / path.Count)) + img.Height - y);
ret.z = (short)(origin.z + ((path[x % path.Count].z - origin.z) + (path[path.Count - 1].z - origin.z + path[1].z - origin.z) * (x / path.Count)));
if (ret.x < lvlSize.x && ret.y < lvlSize.y && ret.z < lvlSize.z && ret.x >= 0 && ret.y >= 0 && ret.z >= 0)
yield return ret;
}
}
}
}