Beispiel #1
0
        /// <summary>
        /// 获取点的一个螺旋环内所有等高并没有被占用的cell
        /// </summary>
        HexagonsWithCenter GetSpiralRingsWithSameHeight(HexCell centerCell, int ringRadius)
        {
            if (centerCell.isTaken)
            {
                //中心点被占用
                return(null);
            }

            List <HexCell> allResults = centerCell.GetSpiralRings(ringRadius);

            if (allResults.Count != HexCell.GetSpiralRingCount(ringRadius))
            {
                //数量不足
                return(null);
            }

            bool result = true;
            int  height = -1;

            foreach (var tempCell in allResults)
            {
                if (tempCell.isTaken)
                {
                    result = false;
                    break;
                }
                if (height < 0)
                {
                    height = tempCell.height;
                }
                if (height != tempCell.height)
                {
                    //高度不统一
                    result = false;
                    break;
                }
            }

            if (result)
            {
                return(new HexagonsWithCenter(centerCell, allResults));
            }
            else
            {
                return(null);
            }
        }