Ejemplo n.º 1
0
        public static bool TryGetWorldLayerCount(MapBuilderSettings mapBuilderSettings,
                                                 string worldSize, out int worldLayerCount)
        {
            switch (worldSize)
            {
            case SmallLevelFlag:
                worldLayerCount = 4;
                break;

            case LargeLevelFlag:
                worldLayerCount = mapBuilderSettings.LargeWorldLayerCount;
                break;

            default:
                return(int.TryParse(worldSize, out worldLayerCount));
            }

            return(true);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
0
 public MapBuilder(MapBuilderSettings mapBuilderSettings, GameObject gameObject)
 {
     this.mapBuilderSettings = mapBuilderSettings;
     this.gameObject         = gameObject;
 }
Ejemplo n.º 4
0
        public static Vector3 GetWorldDimensions(MapBuilderSettings mapBuilderSettings, int worldLayerCount)
        {
            var dimensions = worldLayerCount * mapBuilderSettings.UnitsPerTile * 2 + mapBuilderSettings.UnitsPerBlock;

            return(new Vector3(dimensions, 100f, dimensions));
        }