Esempio n. 1
0
 /// <summary>
 /// Get cell from Cube coordinates
 /// </summary>
 /// <param name="position"></param>
 /// <returns></returns>
 /// <exception cref="ArgumentOutOfRangeException">if there's no cell in the given position</exception>
 public Cell GetCellAt(CubeCoordinate position)
 {
     foreach (var cell in Cells)
     {
         if (cell.Position == position)
         {
             return(cell);
         }
     }
     throw new ArgumentOutOfRangeException("That position is either out of field, or does not contain a cell.", new Exception());
 }
Esempio n. 2
0
        /// <summary>
        /// Get the list of neighboring cells (up to 6)
        /// </summary>
        /// <param name="cell">Cell whose neighbor you want to find.</param>
        /// <returns></returns>
        public List <Cell> FindNeighborsOf(Cell cell)
        {
            var adjacentRelativePositions = CubeCoordinate.AdjacentRelatives();
            var positionToFind            = new List <CubeCoordinate>();
            var cellsToReturn             = new List <Cell>();

            foreach (var relativePosition in adjacentRelativePositions)
            {
                positionToFind.Add(cell.Position + relativePosition);
            }

            foreach (var positionRequested in positionToFind)
            {
                var cellFound = GetCellAt(positionRequested);
                if (cellFound != null)
                {
                    cellsToReturn.Add(cellFound);
                }
            }

            return(cellsToReturn);
        }
Esempio n. 3
0
 /// <summary>
 /// Create cube coordinate from itself
 /// </summary>
 /// <returns>Cube座標オブジェクト</returns>
 public CubeCoordinate ToCube()
 {
     return(CubeCoordinate.FromQr(this));
 }
Esempio n. 4
0
 public Cell(CubeCoordinate position)
 {
     this.Position = position;
 }
Esempio n. 5
0
 /// <summary>
 /// Create QR coordiante from cube coordinate
 /// </summary>
 /// <param name="input">Cube coordinate (as object)</param>
 /// <returns>QR coordinate</returns>
 public static QRCoordinate FromCube(CubeCoordinate input)
 {
     return(FromCube(input.x, input.y, input.z));
 }