Example #1
0
    void DrawPointyBoardGizmos()
    {
        float width  = GetTileFlatOffsetWithSpacing();
        float height = GetTilePointyOffsetWithSpacing();

        Vector3 boardOffset = transform.position;

        if (_type == Type.Hexagon)
        {
            int boardHeight      = GetPointyHexagonBoardSize();
            int boardWidthOffset = (Mathf.FloorToInt(boardHeight * 0.5f) % 2);
            boardWidthOffset -= Mathf.Abs((Mathf.CeilToInt(boardHeight * 0.5f) % 2) - 1);
            boardOffset.x    += boardWidthOffset * width;

            boardOffset += GetPointyHexagonBoardAlignOffset();
        }
        else
        {
            boardOffset += GetPointyRectangleBoardAlignOffset();
        }

        for (int i = 0; i < _boardHeight; ++i)
        {
            float lineOffset = (i % 2) * width;
            for (int j = 0; j < _boardWidth; ++j)
            {
                Vector3 position = boardOffset;
                position.x += width * 2.0f * j + lineOffset;
                position.y -= height * i;

                GizmosUtilities.DrawWireHexagon(
                    position,
                    Hexagon.Orientation.Pointy,
                    _tilePrefab.outerRadius,
                    Color.magenta
                    );

                GizmosUtilities.DrawString(
                    string.Format("{0}, {1}", i, j),
                    position
                    );
            }
        }
    }
        void OnDrawGizmos()
        {
            CalculateBounds();

            GizmosUtilities.DrawRect(_levelBounds, lineColor);
        }