示例#1
0
        public int GetFlattenArrayIndexFromAxialCoordinate(int x, int z, MapConfig config)
        {
            if (x > config.GetMap2DArrayWidth() || z > config.GetMap2DArrayHeight())
            {
                throw new ArgumentOutOfRangeException($"{x} or {z} is out of range of the given config: ${config}");
            }

            return(z * config.GetMap2DActualWidth() + x - z % 2 - z / 2);
        }
示例#2
0
        private void InvokeLoadService(ImmutableArray <TData> datas, MapConfig config)
        {
            var service = GetService();

            service.Load(
                datas,
                config.GetMap2DActualWidth(),
                config.GetMap2DActualHeight()
                );
        }
示例#3
0
        public Coordinate GetCoordinateFromFlattenArrayIndex(int index, MapConfig config)
        {
            if (index > config.GetTotalMapSize() || index < 0)
            {
                throw new ArgumentOutOfRangeException($"{index} is out of range of the given config: ${config}");
            }

            var nestedArrayZ = index / config.GetMap2DActualHeight();
            var nestedArrayX = index - nestedArrayZ * config.GetMap2DActualWidth();

            return(GetAxialCoordinateFromNestedArrayIndex(nestedArrayX, nestedArrayZ));
        }
示例#4
0
        private static TileHolder[,] Create2DTileHolders(IReadOnlyList <TileHolder> tileHolders, MapConfig mapConfig)
        {
            var mapXSize = mapConfig.GetMap2DActualWidth();
            var mapZSize = mapConfig.GetMap2DActualHeight();

            var toReturn = new TileHolder[mapXSize + mapZSize / 2, mapZSize];

            for (var i = 0; i < mapZSize; i++)
            {
                for (var j = 0; j < mapXSize; j++)
                {
                    toReturn[j + i % 2 + i / 2, i] = tileHolders[i * mapXSize + j];
                }
            }

            return(toReturn);
        }
示例#5
0
        private static IReadOnlyList <Vector3> CreateData(MapConfig mapConfig, WorldConfig worldConfig, float yPosition)
        {
            var toReturn     = new List <Vector3>();
            var upDistance   = worldConfig.OuterRadius * 1.5f;
            var sideDistance = worldConfig.InnerRadius * 2f;

            for (var i = 0; i < mapConfig.GetMap2DActualHeight(); i++)
            {
                var sideOffset = i % 2 * sideDistance / 2f;
                for (var j = 0; j < mapConfig.GetMap2DActualWidth(); j++)
                {
                    toReturn.Add(
                        new Vector3(
                            j * sideDistance + sideOffset,
                            yPosition,
                            i * upDistance
                            )
                        );
                }
            }
            return(toReturn);
        }