Exemplo n.º 1
0
        public HexAxial Round()
        {
            HexCube cube = ToCube();

            cube = cube.Round();

            return(cube.ToAxial());
        }
Exemplo n.º 2
0
        public HexCube ToCube()
        {
            float x       = Q;
            float z       = R;
            float y       = -x - z;
            var   hexCube = new HexCube(x, y, z);

            return(hexCube);
        }
Exemplo n.º 3
0
        private Cell GetCell(HexAxial axial)
        {
            HexCube cube = axial.ToCube();
            Cell    cell = GetCell(cube);

            if (cell == null)
            {
                cell = new Cell();
                _cells[(int)cube.Z + _size, (int)cube.Y + _size, (int)cube.X + _size] = cell;
            }

            return(cell);
        }
Exemplo n.º 4
0
 private void IterateCells(CellHandler handler)
 {
     for (int cellZ = -_size; cellZ <= _size; cellZ++)
     {
         for (int cellY = -_size; cellY <= _size; cellY++)
         {
             for (int cellX = -_size; cellX <= _size; cellX++)
             {
                 var  cube = new HexCube(cellX, cellY, cellZ);
                 Cell cell = GetCell(cube);
                 if (cell != null)
                 {
                     handler(cube, cell);
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
        public Cell GetCell(HexCube cube)
        {
            Cell cell = _cells[(int)cube.Z + _size, (int)cube.Y + _size, (int)cube.X + _size];

            return(cell);
        }