Example #1
0
        private int DrawFromVertex3(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 + 1);
            }
            else
            {
                nextCell = gridCells.FirstOrDefault(c => c.x == currentCell.x + 1 && c.y == currentCell.y);
            }

            if (nextCell != null)
            {
                // we need 1->2 of the next cell
                HexSprite nextSprite = _cells[nextCell.x, nextCell.y].GetComponent <HexSprite>();
                vertexList.Add(nextSprite.FindVertex2());
                //gridCells.Remove(nextCell);
                return(DrawFromVertex2(topLeftCell, nextSprite, nextCell, gridCells, vertexList));
            }
            else
            {
                // vertex 3 should not touch the topLeftHex, so draw 3 -> 4 on this cell and continue
                vertexList.Add(currentSprite.FindVertex4());
                return(DrawFromVertex4(topLeftCell, currentSprite, currentCell, gridCells, vertexList));
            }
        }
Example #2
0
        private int DrawFromVertex1(IntVector2 topLeftCell, HexSprite currentSprite, IntVector2 currentCell, List <IntVector2> gridCells, List <Vector3> vertexList)
        {
            // see if there is a node directly above us
            IntVector2 nextCell = gridCells.FirstOrDefault(c => c.x == currentCell.x && c.y == currentCell.y - 1);

            if (nextCell != null)
            {
                // we need 5->6 of the next cell
                var nextSprite = _cells[nextCell.x, nextCell.y].GetComponent <HexSprite>();
                vertexList.Add(nextSprite.FindVertex6());
                //gridCells.Remove(nextCell);
                return(DrawFromVertex6(topLeftCell, nextSprite, nextCell, gridCells, vertexList));
            }
            else
            {
                // see if the topLeftCell is directly above this cell
                if (topLeftCell.x == currentCell.x && topLeftCell.y == currentCell.y - 1)
                {
                    return(5);
                }
                else
                {
                    // draw 1->2 and continue
                    vertexList.Add(currentSprite.FindVertex2());
                    return(DrawFromVertex2(topLeftCell, currentSprite, currentCell, gridCells, vertexList));
                }
            }
        }