Example #1
0
        public static TezHexCubeCoordinate[] neighbors(TezHexCubeCoordinate center)
        {
            TezHexCubeCoordinate[] coordinates = new TezHexCubeCoordinate[6];
            for (int i = 0; i < Directions.Length; i++)
            {
                coordinates[i] = center + Directions[i];
            }

            return(coordinates);
        }
Example #2
0
        /// <summary>
        /// 初始化Block
        /// </summary>
        public void initBlock(TezHexCubeCoordinate coordinate, TezHexGrid.Layout layout, Block block)
        {
            var array_index = this.toArrayIndex(coordinate.toOffset(layout));

            if (array_index.isChunkOutOfRange(m_ChunkXCount, m_ChunkYCount))
            {
                throw new IndexOutOfRangeException("Chunk Out Of Range");
            }

            block.coordinate = coordinate;
            m_ChunkArray[array_index.chunkX, array_index.chunkY].initBlock(array_index.blockX, array_index.blockY, block);
            this.onBlockInited(block);
        }
Example #3
0
        public static List <TezHexCubeCoordinate> ring(TezHexCubeCoordinate center, int radius)
        {
            List <TezHexCubeCoordinate> list = new List <TezHexCubeCoordinate>();

            list.Capacity = 6 * radius;

            var begin = Directions[(int)Direction.Y_ZX];

            begin.scale(radius);
            begin.add(center.x, center.y, center.z);

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < radius; j++)
                {
                    list.Add(begin);
                    begin = neighbor(begin, Directions[i]);
                }
            }

            return(list);
        }
Example #4
0
        /// <summary>
        /// 取得一个范围的块(包含center自己)
        /// </summary>
        public static List <TezHexCubeCoordinate> range(TezHexCubeCoordinate center, int range)
        {
            List <TezHexCubeCoordinate> list = new List <TezHexCubeCoordinate>();

            list.Capacity = (1 + range) * range / 2 * 6 + 1;

            for (int z = -range; z <= range; z++)
            {
                for (int y = -range; y <= range; y++)
                {
                    for (int x = -range; x <= range; x++)
                    {
                        if (x + y + z != 0)
                        {
                            continue;
                        }

                        list.Add(new TezHexCubeCoordinate(center.x + x, center.z + z));
                    }
                }
            }

            return(list);
        }
Example #5
0
 public Vector3 calculatePosition(TezHexCubeCoordinate coordinate)
 {
     return(this.calculatePosition(coordinate.x, coordinate.z));
 }
Example #6
0
 TezHexCubeCoordinate cubeToAxial(TezHexCubeCoordinate cube)
 {
     return(new TezHexCubeCoordinate(cube.x, cube.z));
 }
Example #7
0
 public static bool isNeighbor(TezHexCubeCoordinate center, TezHexCubeCoordinate other)
 {
     return(center.getDistanceFrom(other) == 1);
 }
Example #8
0
 public static TezHexCubeCoordinate neighbor(TezHexCubeCoordinate center, TezHexCubeCoordinate dir)
 {
     return(new TezHexCubeCoordinate(center.x + dir.x, center.z + dir.z));
 }