示例#1
0
        // Get the world size from the config, and use it to generate the correct-sized level
        public static IEnumerator GenerateMap(
            MapTemplate mapTemplate,
            int mapSize,
            Transform parentTransform,
            string workerType,
            WorkerConnectorBase worker)
        {
            var levelInstance = new GameObject($"FPS-Level_{mapSize}({workerType})");

            levelInstance.transform.position = parentTransform.position;
            levelInstance.transform.rotation = parentTransform.rotation;

            var mapBuilder = new MapBuilder(mapTemplate, levelInstance);

            yield return(mapBuilder.CleanAndBuild(mapSize));

            worker.LevelInstance = levelInstance;
        }
示例#2
0
        // Get the world size from the config, and use it to generate the correct-sized level
        public static IEnumerator GenerateMap(
            MapBuilderSettings mapBuilderSettings,
            Transform workerTransform,
            Connection connection,
            string workerType,
            ILogDispatcher logDispatcher,
            WorkerConnectorBase worker)
        {
            var worldSize = GetWorldSizeFlag(connection);

            if (!TryGetWorldLayerCount(mapBuilderSettings, worldSize, out var worldLayerCount))
            {
                logDispatcher.HandleLog(LogType.Error,
                                        new LogEvent("Invalid world_size worker flag. Make sure that it is either small or large,")
                                        .WithField("world_size", worldSize));
                yield break;
            }

            var levelInstance = worker.LevelInstance = new GameObject();

            levelInstance.name = $"FPS-Level_{worldLayerCount}({workerType})";
            levelInstance.transform.position = workerTransform.position;
            levelInstance.transform.rotation = workerTransform.rotation;

            var mapBuilder = new MapBuilder(mapBuilderSettings, levelInstance);

            var volumesPrefab = mapBuilderSettings.WorldTileVolumes == null
                ? null
                : Object.Instantiate(mapBuilderSettings.WorldTileVolumes);

            yield return(mapBuilder.CleanAndBuild(worldLayerCount));

            if (volumesPrefab != null)
            {
                UnityObjectDestroyer.Destroy(volumesPrefab);
            }
        }