public void LoadWorld(int n) { if (System.IO.File.Exists(GetWorldFilePath(n))) { gameManagerUnity.DestroyWorld(); AvailableConfigurations configurations = GameManagerUnity.LoadConfiguration(); gameManagerUnity.LoadCustomTextures(); byte[] data = System.IO.File.ReadAllBytes(GetWorldFilePath(n)); CubeWorld.Configuration.Config config = new CubeWorld.Configuration.Config(); config.tileDefinitions = configurations.tileDefinitions; config.itemDefinitions = configurations.itemDefinitions; config.avatarDefinitions = configurations.avatarDefinitions; config.extraMaterials = configurations.extraMaterials; gameManagerUnity.extraMaterials = config.extraMaterials; gameManagerUnity.world = new CubeWorld.World.CubeWorld(gameManagerUnity.objectsManagerUnity, gameManagerUnity.fxManagerUnity); gameManagerUnity.world.Load(config, data); worldGeneratorProcess = null; gameManagerUnity.surroundingsUnity.CreateSurroundings(gameManagerUnity.world.configSurroundings); gameManagerUnity.State = GameManagerUnity.GameManagerUnityState.GENERATING; } }
void DrawGenerator() { if (availableConfigurations == null) { availableConfigurations = GameManagerUnity.LoadConfiguration(); currentDayInfoOffset = 0; currentGeneratorOffset = 0; currentSizeOffset = 0; currentGameplayOffset = 0; } MenuSystem.BeginMenu("Random World Generator"); MenuSystem.Button("Gameplay: " + GameplayFactory.AvailableGameplays[currentGameplayOffset].name, delegate() { currentGameplayOffset = (currentGameplayOffset + 1) % GameplayFactory.AvailableGameplays.Length; } ); MenuSystem.Button("World Size: " + availableConfigurations.worldSizes[currentSizeOffset].name, delegate() { currentSizeOffset = (currentSizeOffset + 1) % availableConfigurations.worldSizes.Length; } ); MenuSystem.Button("Day Length: " + availableConfigurations.dayInfos[currentDayInfoOffset].name, delegate() { currentDayInfoOffset = (currentDayInfoOffset + 1) % availableConfigurations.dayInfos.Length; } ); if (GameplayFactory.AvailableGameplays[currentGameplayOffset].hasCustomGenerator == false) { MenuSystem.Button("Generator: " + availableConfigurations.worldGenerators[currentGeneratorOffset].name, delegate() { currentGeneratorOffset = (currentGeneratorOffset + 1) % availableConfigurations.worldGenerators.Length; } ); } #if !UNITY_WEBPLAYER MenuSystem.Button("Host Multiplayer: " + (multiplayer ? "Yes" : "No"), delegate() { multiplayer = !multiplayer; } ); #endif MenuSystem.LastButton("Generate!", delegate() { lastConfig = new CubeWorld.Configuration.Config(); lastConfig.tileDefinitions = availableConfigurations.tileDefinitions; lastConfig.itemDefinitions = availableConfigurations.itemDefinitions; lastConfig.avatarDefinitions = availableConfigurations.avatarDefinitions; lastConfig.dayInfo = availableConfigurations.dayInfos[currentDayInfoOffset]; lastConfig.worldGenerator = availableConfigurations.worldGenerators[currentGeneratorOffset]; lastConfig.worldSize = availableConfigurations.worldSizes[currentSizeOffset]; lastConfig.extraMaterials = availableConfigurations.extraMaterials; lastConfig.gameplay = GameplayFactory.AvailableGameplays[currentGameplayOffset]; #if !UNITY_WEBPLAYER if (multiplayer) { MultiplayerServerGameplay multiplayerServerGameplay = new MultiplayerServerGameplay(lastConfig.gameplay.gameplay, true); GameplayDefinition g = new GameplayDefinition("", "", multiplayerServerGameplay, false); lastConfig.gameplay = g; gameManagerUnity.RegisterInWebServer(); } #endif gameManagerUnity.worldManagerUnity.CreateRandomWorld(lastConfig); availableConfigurations = null; state = MainMenuState.NORMAL; } ); MenuSystem.EndMenu(); }