C# 给定索引位置和纹理大小,如何计算六边形位置?

C# 给定索引位置和纹理大小,如何计算六边形位置?,c#,xna,C#,Xna,我正在尝试创建一个六角平铺地图,如下所示: 但是我在将列表中的tiles X(行)和Y(列)索引转换为屏幕位置时遇到了一些问题: public static Vector2 GetDisplayCoordOfTile(GameTile t, Texture2D texture) { Vector2 screenPadding = new Vector2(2, 2); float ypos = (t.Column

我正在尝试创建一个六角平铺地图,如下所示:

但是我在将列表中的tiles X(行)和Y(列)索引转换为屏幕位置时遇到了一些问题:

        public static Vector2 GetDisplayCoordOfTile(GameTile t, Texture2D texture)
        {
            Vector2 screenPadding = new Vector2(2, 2);

            float ypos = (t.Column * (texture.Height + 2)) - (t.Row * texture.Height / (float)2) + screenPadding.Y;
            float xpos = (t.Row * (texture.Width)) + screenPadding.X;

            return new Vector2(xpos, ypos);
        }

如果有人知道事情会发展到什么地步,我无法让我的思维围绕这个想法,因为坐标系统不同于常规阵列的思维方式

这里有一个关于如何绘制六边形地图的很棒的教程:

此外,如果您在此处询问与游戏开发相关的问题,您可能会得到更多帮助: