Example #1
0
        private int DrawFromVertex4(IntVector2 topLeftCell, HexSprite currentSprite, IntVector2 currentCell, List <IntVector2> gridCells, List <Vector3> vertexList)
        {
            // see if there is a node directly below us
            IntVector2 nextCell = gridCells.FirstOrDefault(c => c.x == currentCell.x && c.y == currentCell.y + 1);

            if (nextCell != null)
            {
                // we need 2->3 of the next cell
                HexSprite nextSprite = _cells[nextCell.x, nextCell.y].GetComponent <HexSprite>();
                vertexList.Add(nextSprite.FindVertex3());
                return(DrawFromVertex3(topLeftCell, nextSprite, nextCell, gridCells, vertexList));
            }
            else
            {
                //top left cannot be directly below us
                // draw 4->5 and continue
                vertexList.Add(currentSprite.FindVertex5());
                return(DrawFromVertex5(topLeftCell, currentSprite, currentCell, gridCells, vertexList));
            }
        }
Example #2
0
        private int DrawFromVertex6(IntVector2 topLeftCell, HexSprite currentSprite, IntVector2 currentCell, List <IntVector2> gridCells, List <Vector3> vertexList)
        {
            IntVector2 nextCell;

            // compare the coordinates of the next
            // if current x even, the next cell on the same y level is up; if odd, it's down
            // if even and x, y or if odd and x, y-1
            if (currentCell.x % 2 == 0)
            {
                nextCell = gridCells.FirstOrDefault(c => c.x == currentCell.x - 1 && c.y == currentCell.y);
            }
            else
            {
                nextCell = gridCells.FirstOrDefault(c => c.x == currentCell.x - 1 && c.y == currentCell.y - 1);
            }

            if (nextCell != null)
            {
                // we need 4->5 of the next cell
                HexSprite nextSprite = _cells[nextCell.x, nextCell.y].GetComponent <HexSprite>();
                vertexList.Add(nextSprite.FindVertex5());
                return(DrawFromVertex5(topLeftCell, nextSprite, nextCell, gridCells, vertexList));
            }
            else
            {
                // see if the top left hex is to our top left
                if ((currentCell.x % 2 == 0 && topLeftCell.x == currentCell.x - 1 && topLeftCell.y == currentCell.y) ||
                    (currentCell.x % 2 == 1 && topLeftCell.x == currentCell.x - 1 && topLeftCell.y == currentCell.y - 1))
                {
                    return(4);
                }
                else
                {
                    // draw 6->1 on this cell and continue
                    vertexList.Add(currentSprite.FindVertex1());
                    return(DrawFromVertex1(topLeftCell, currentSprite, currentCell, gridCells, vertexList));
                }
            }
        }