Example #1
0
    public static void DrawTile(Vector3 position, float size, Color color)
    {
        for (int i = 0; i < 6; i++)
        {
            Vector3 a = WorldRenderer.GetCorner(i) * size;
            Vector3 b = WorldRenderer.GetCorner(i + 1) * size;

            DrawLine(a + position, b + position, color);
        }
    }
Example #2
0
    public static void DrawTerritory(List <TileObject> territory, Color primaryColor, Color secondaryColor)
    {
        for (int i = 0; i < territory.Count; i++)
        {
            if (territory[i])
            {
                Vector3 offset   = Vector3.up * 0.02f;
                Vector3 position = territory[i].transform.position;

                bool left, right, topLeft, topRight, bottomLeft, bottomRight;
                left        = !territory[i].Left || territory[i].Left.Nation != territory[i].Nation;
                right       = !territory[i].Right || territory[i].Right.Nation != territory[i].Nation;
                topLeft     = !territory[i].TopLeft || territory[i].TopLeft.Nation != territory[i].Nation;
                topRight    = !territory[i].TopRight || territory[i].TopRight.Nation != territory[i].Nation;
                bottomLeft  = !territory[i].BottomLeft || territory[i].BottomLeft.Nation != territory[i].Nation;
                bottomRight = !territory[i].BottomRight || territory[i].BottomRight.Nation != territory[i].Nation;

                if (left && !topLeft)
                {
                    Vector3 a        = WorldRenderer.GetCorner(5) * WorldManager.OuterRadius;
                    Vector3 elevated = new Vector3(position.x, territory[i].TopLeft.transform.position.y, position.z);

                    DrawLine(a + position + offset, a + elevated + offset, primaryColor);
                }

                if (topRight && !right)
                {
                    Vector3 a        = WorldRenderer.GetCorner(1) * WorldManager.OuterRadius;
                    Vector3 elevated = new Vector3(position.x, territory[i].Right.transform.position.y, position.z);

                    DrawLine(a + position + offset, a + elevated + offset, primaryColor);
                }

                if (bottomRight && !right)
                {
                    Vector3 a        = WorldRenderer.GetCorner(2) * WorldManager.OuterRadius;
                    Vector3 elevated = new Vector3(position.x, territory[i].Right.transform.position.y, position.z);

                    DrawLine(a + position + offset, a + elevated + offset, primaryColor);
                }

                if (right && !topRight)
                {
                    Vector3 a        = WorldRenderer.GetCorner(1) * WorldManager.OuterRadius;
                    Vector3 elevated = new Vector3(position.x, territory[i].TopRight.transform.position.y, position.z);

                    DrawLine(a + position + offset, a + elevated + offset, primaryColor);
                }

                if (topLeft && !topRight)
                {
                    Vector3 a        = WorldRenderer.GetCorner(0) * WorldManager.OuterRadius;
                    Vector3 elevated = new Vector3(position.x, territory[i].TopRight.transform.position.y, position.z);

                    DrawLine(a + position + offset, a + elevated + offset, primaryColor);
                }

                if (right && !bottomRight)
                {
                    Vector3 a        = WorldRenderer.GetCorner(2) * WorldManager.OuterRadius;
                    Vector3 elevated = new Vector3(position.x, territory[i].BottomRight.transform.position.y, position.z);

                    DrawLine(a + position + offset, a + elevated + offset, primaryColor);
                }

                if (right)
                {
                    Vector3 a = WorldRenderer.GetCorner(1) * WorldManager.OuterRadius;
                    Vector3 b = WorldRenderer.GetCorner(2) * WorldManager.OuterRadius;

                    DrawLine(a + position + offset, b + position + offset, primaryColor);
                }
                if (left)
                {
                    Vector3 a = WorldRenderer.GetCorner(4) * WorldManager.OuterRadius;
                    Vector3 b = WorldRenderer.GetCorner(5) * WorldManager.OuterRadius;

                    DrawLine(a + position + offset, b + position + offset, primaryColor);
                }
                if (topRight)
                {
                    Vector3 a = WorldRenderer.GetCorner(0) * WorldManager.OuterRadius;
                    Vector3 b = WorldRenderer.GetCorner(1) * WorldManager.OuterRadius;

                    DrawLine(a + position + offset, b + position + offset, primaryColor);
                }
                if (topLeft)
                {
                    Vector3 a = WorldRenderer.GetCorner(5) * WorldManager.OuterRadius;
                    Vector3 b = WorldRenderer.GetCorner(6) * WorldManager.OuterRadius;

                    DrawLine(a + position + offset, b + position + offset, primaryColor);
                }
                if (bottomRight)
                {
                    Vector3 a = WorldRenderer.GetCorner(2) * WorldManager.OuterRadius;
                    Vector3 b = WorldRenderer.GetCorner(3) * WorldManager.OuterRadius;

                    DrawLine(a + position + offset, b + position + offset, primaryColor);
                }
                if (bottomLeft)
                {
                    Vector3 a = WorldRenderer.GetCorner(3) * WorldManager.OuterRadius;
                    Vector3 b = WorldRenderer.GetCorner(4) * WorldManager.OuterRadius;

                    DrawLine(a + position + offset, b + position + offset, primaryColor);
                }
            }
        }
    }