private void LoadWorldDescriptor() { _logger.Info("Waiting to load WorldDescriptor..."); WorldDescriptor worldDescriptor = FindObjectOfType <WorldDescriptor>(); if (worldDescriptor == null) { ReturnLoadError("WorldDescriptor not found!"); return; } if (worldDescriptor.PlayerSpawnPoint != null) { PlayerAnchorManager playerAnchorManager = FindObjectOfType <PlayerAnchorManager>(); if (playerAnchorManager == null) { playerAnchorManager = worldDescriptor.PlayerSpawnPoint.gameObject.AddComponent <PlayerAnchorManager>(); } playerAnchorManager.RestartPlayer(); } else { _logger.Error("Player Spawn Point not found in Location Config"); ReturnLoadError("Player Spawn Point not found in Location Config"); } }
private void LoadWorldDescriptor() { _logger.Info("Waiting to load WorldDescriptor..."); WorldDescriptor worldDescriptor = FindObjectOfType <WorldDescriptor>(); if (worldDescriptor == null) { ReturnLoadError("WorldDescriptor not found!"); return; } if (worldDescriptor.PlayerSpawnPoint != null) { if (GameObjects.Instance != null) { PlayerAnchorManager playerAnchorManager = FindObjectOfType <PlayerAnchorManager>(); if (playerAnchorManager == null) { playerAnchorManager = worldDescriptor.PlayerSpawnPoint.gameObject.AddComponent <PlayerAnchorManager>(); } playerAnchorManager.ReloadPlayer(GameObjects.Instance.PlayerRig.GetComponentInChildren <VRTK_SDKSetup>().actualBoundaries); return; } _logger.Info("Player Spawn Point was found! Adding PlayerAnchorManager"); worldDescriptor.PlayerSpawnPoint.gameObject.AddComponent <PlayerAnchorManager>(); } else { _logger.Error("Player Spawn Point not found in Location Config"); ReturnLoadError("Player Spawn Point not found in Location Config"); } }
private void ResetPlayerRigPosition() { if (GameObjects.Instance == null) { return; } WorldDescriptor worldDescriptor = FindObjectOfType <WorldDescriptor>(); if (worldDescriptor == null) { ReturnLoadError("WorldDescriptor not found!"); return; } PlayerAnchorManager playerAnchorManager = FindObjectOfType <PlayerAnchorManager>(); if (playerAnchorManager == null) { playerAnchorManager = worldDescriptor.PlayerSpawnPoint.gameObject.AddComponent <PlayerAnchorManager>(); } playerAnchorManager.SetPlayerPosition(); }
public static void Load(string path) { GD.Print("Loading Level: '", path, "'"); string text = System.IO.File.ReadAllText(path); WorldDescriptor wd = IPOWLib.IO.Loader.Load(text); World w = Loader.LoadWorld(wd); RootNode.GetNode().SetScene(w); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Xml|*.xml"; if (sfd.ShowDialog() == DialogResult.OK) { WorldDescriptor wd = levelControl1.World.GetDescriptor(); string text = Saver.SaveToString(wd); File.WriteAllText(sfd.FileName, text); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Xml|*.xml"; if (ofd.ShowDialog() == DialogResult.OK) { string text = File.ReadAllText(ofd.FileName); WorldDescriptor wd = Loader.Load(text); World w = World.FromDescriptor(wd); levelControl1.SetWorld(w); } }
private void CreateConfig(WorldDescriptor descriptor, string installJsonPath, string configJsonPath) { Debug.Log("Core version is " + VarwinVersionInfo.VarwinVersion); string builtAt = $"{DateTimeOffset.UtcNow:s}Z"; if (DateTimeOffset.TryParse(descriptor.BuiltAt, out DateTimeOffset builtAtDateTimeOffset)) { builtAt = $"{builtAtDateTimeOffset.UtcDateTime:s}Z"; } var installConfig = new CreateSceneTemplateWindow.InstallConfig { Name = descriptor.Name, Guid = descriptor.Guid, RootGuid = descriptor.RootGuid, Author = new CreateSceneTemplateWindow.Author() { Name = descriptor.AuthorName, Email = descriptor.AuthorEmail, Url = descriptor.AuthorUrl, }, BuiltAt = builtAt, License = new CreateSceneTemplateWindow.License() { Code = descriptor.LicenseCode, Version = descriptor.LicenseVersion, }, MobileReady = SdkSettings.MobileFeature.Enabled && descriptor.MobileReady, SdkVersion = VarwinVersionInfo.VersionNumber }; var sceneConfig = new CreateSceneTemplateWindow.SceneConfig { name = descriptor.Name, description = descriptor.Description, image = descriptor.Image, assetBundleLabel = descriptor.AssetBundleLabel, dllNames = new string[0] }; File.WriteAllText(installJsonPath, installConfig.ToJson()); File.WriteAllText(configJsonPath, sceneConfig.ToJson()); }
public WorldDescriptor GetDescriptor() { WorldDescriptor wd = new WorldDescriptor(); wd.Width = this.Width; wd.Height = this.Height; wd.Tiles = new TileDescriptor[Width, Height]; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { string tName = Grid[x, y].Name; TileDescriptor td = TileDescriptor.Create(tName); wd.Tiles[x, y] = td; } } return(wd); }
public static World FromDescriptor(WorldDescriptor wd) { World w = new World(wd.Width, wd.Height); for (int x = 0; x < wd.Width; x++) { for (int y = 0; y < wd.Height; y++) { string tName = wd.Tiles[x, y].TypeName; Tile tile = Tile.GetTile(tName); tile?.SetPos(x, y); if (tile != null) { w.Grid[x, y] = tile; } } } return(w); }
public static World LoadWorld(WorldDescriptor worldDescriptor) { World world = (World)GD.Load <PackedScene>("res://Scenes/World.tscn").Instance(); Grid3D grid = new Grid3D(world, worldDescriptor.Width, worldDescriptor.Height); world.AddChild(grid); for (int y = 0; y < worldDescriptor.Height; y++) { for (int x = 0; x < worldDescriptor.Width; x++) { TileDescriptor tileD = worldDescriptor.Tiles[x, y]; Tile tileT = CreateTile(tileD); grid.SetTile(tileT, x, y, false); } } return(world); }
private static Transform FindOrCreateSpawnPoint(WorldDescriptor worldDescriptor) { if (worldDescriptor.PlayerSpawnPoint == null) { var spawnPoint = new GameObject("[Spawn Point]"); spawnPoint.transform.position = Vector3.zero; spawnPoint.transform.rotation = Quaternion.identity; spawnPoint.transform.localScale = Vector3.one; spawnPoint.transform.SetParent(_worldDescriptor.transform); worldDescriptor.PlayerSpawnPoint = spawnPoint.transform; } else { worldDescriptor.PlayerSpawnPoint.SetParent(_worldDescriptor.transform, true); worldDescriptor.PlayerSpawnPoint.gameObject.name = "[Spawn Point]"; } return(worldDescriptor.PlayerSpawnPoint); }
private void CreateFolders(WorldDescriptor descriptor) { Debug.Log("Bake location " + _bakedDirectory); if (Directory.Exists(_bakedDirectory)) { return; } try { Directory.CreateDirectory(_bakedDirectory); } catch { Debug.LogError("Can not create location directory..."); return; } }
private static void FindOrCreateWorldDescriptor() { _worldDescriptor = SceneUtils.GetObjectsInScene <WorldDescriptor>(true).FirstOrDefault(); if (_worldDescriptor != null) { _worldDescriptor.gameObject.SetActive(true); FindOrCreateSpawnPoint(_worldDescriptor); return; } GameObject worldDescriptorGo = new GameObject("[World Descriptor]"); worldDescriptorGo.transform.position = Vector3.zero; worldDescriptorGo.transform.rotation = Quaternion.identity; worldDescriptorGo.transform.localScale = Vector3.one; _worldDescriptor = worldDescriptorGo.AddComponent <WorldDescriptor>(); FindOrCreateSpawnPoint(_worldDescriptor); }
private void LoadWorlds() { WorldsDescriptors.Clear(); WorldDescriptor wd; wd = new WorldDescriptor() { Id = 1, Name = "The colonies", Levels = new List<KeyValuePair<int, List<int>>>() { new KeyValuePair<int, List<int>>(1, new List<int>() {}), new KeyValuePair<int, List<int>>(2, new List<int>() { 1 }), new KeyValuePair<int, List<int>>(3, new List<int>() { 2 }), new KeyValuePair<int, List<int>>(4, new List<int>() { 3 }), new KeyValuePair<int, List<int>>(5, new List<int>() { 4 }), new KeyValuePair<int, List<int>>(6, new List<int>() { 5 }), new KeyValuePair<int, List<int>>(7, new List<int>() { 6 }), new KeyValuePair<int, List<int>>(8, new List<int>() { 7 }), new KeyValuePair<int, List<int>>(9, new List<int>() { 8 }), new KeyValuePair<int, List<int>>(10, new List<int>() { 9 }), new KeyValuePair<int, List<int>>(11, new List<int>() { 10 }), new KeyValuePair<int, List<int>>(12, new List<int>() { 11 }), new KeyValuePair<int, List<int>>(13, new List<int>() { 12 }), new KeyValuePair<int, List<int>>(14, new List<int>() { 13 }), new KeyValuePair<int, List<int>>(15, new List<int>() { 14 }) }, Warps = new List<KeyValuePair<int, string>>() { new KeyValuePair<int, string>(2001, GetWorldStringId(2)) }, Layout = 1001, UnlockedCondition = new List<int>(), WarpBlockedMessage = "You're not Commander\n\nenough to ascend to\n\na higher level.", LastLevelId = 15, Music = "Galaxy1Music" }; WorldsDescriptors.Add(wd.Id, wd); wd = new WorldDescriptor() { Id = 2, Name = "The invasion", Levels = new List<KeyValuePair<int, List<int>>>() { new KeyValuePair<int, List<int>>(16, new List<int>() { 15 }), new KeyValuePair<int, List<int>>(17, new List<int>() { 16 }), new KeyValuePair<int, List<int>>(18, new List<int>() { 17 }), new KeyValuePair<int, List<int>>(19, new List<int>() { 18 }), new KeyValuePair<int, List<int>>(20, new List<int>() { 19 }), new KeyValuePair<int, List<int>>(21, new List<int>() { 20 }), new KeyValuePair<int, List<int>>(22, new List<int>() { 21 }), new KeyValuePair<int, List<int>>(23, new List<int>() { 22 }), new KeyValuePair<int, List<int>>(24, new List<int>() { 23 }), new KeyValuePair<int, List<int>>(25, new List<int>() { 24 }), new KeyValuePair<int, List<int>>(26, new List<int>() { 25 }), new KeyValuePair<int, List<int>>(27, new List<int>() { 26 }), new KeyValuePair<int, List<int>>(28, new List<int>() { 27 }), new KeyValuePair<int, List<int>>(29, new List<int>() { 28 }), new KeyValuePair<int, List<int>>(30, new List<int>() { 29 }) }, Warps = new List<KeyValuePair<int, string>>() { new KeyValuePair<int, string>(2002, GetWorldStringId(3)), new KeyValuePair<int, string>(2003, GetWorldStringId(1)) }, Layout = 1002, UnlockedCondition = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, WarpBlockedMessage = "Only a true Commander\n\nmay enjoy a better world.", LastLevelId = 30, Music = "Galaxy1Music" }; WorldsDescriptors.Add(wd.Id, wd); wd = new WorldDescriptor() { Id = 3, Name = "Battle for Earth", Levels = new List<KeyValuePair<int, List<int>>>() { new KeyValuePair<int, List<int>>(31, new List<int>() { 30 }), new KeyValuePair<int, List<int>>(32, new List<int>() { 31 }), new KeyValuePair<int, List<int>>(33, new List<int>() { 32 }), new KeyValuePair<int, List<int>>(34, new List<int>() { 33 }), new KeyValuePair<int, List<int>>(35, new List<int>() { 34 }), new KeyValuePair<int, List<int>>(36, new List<int>() { 35 }), new KeyValuePair<int, List<int>>(37, new List<int>() { 36 }), new KeyValuePair<int, List<int>>(38, new List<int>() { 37 }), new KeyValuePair<int, List<int>>(39, new List<int>() { 38 }), new KeyValuePair<int, List<int>>(40, new List<int>() { 39 }) }, Warps = new List<KeyValuePair<int, string>>() { new KeyValuePair<int, string>(2004, GetWorldStringId(3)) }, Layout = 1003, UnlockedCondition = new List<int>() { -1 }, WarpBlockedMessage = "", LastLevelId = 40, Music = "Galaxy1Music" }; WorldsDescriptors.Add(wd.Id, wd); }
internal void Initialize() { World = worldLoader.Load(worldLoader.Maps.FirstOrDefault()); WorldDescriptor = new WorldDescriptor(World); }
public string BuildAndShow(WorldDescriptor descriptor, byte[] icon) { #if VRMAKER SaveCurrentScene(); UnityEngine.SceneManagement.Scene scene = SceneManager.GetActiveScene(); Debug.Log(scene.path); _bakedDirectory = Application.dataPath.Replace("Assets", "BakedSceneTemplates"); if (!Directory.Exists(_bakedDirectory)) { try { Directory.CreateDirectory(_bakedDirectory); } catch { Debug.LogError("Can't create directory \"" + _bakedDirectory + "\""); EditorUtility.DisplayDialog("Can't create directory", "Can't create directory \"" + _bakedDirectory + "\"", "OK"); throw; } } _bundleDirectory = Application.dataPath.Replace("Assets", "AssetBundles"); if (!Directory.Exists(_bundleDirectory)) { try { Directory.CreateDirectory(_bundleDirectory); } catch { Debug.LogError("Can't create directory \"" + _bundleDirectory + "\""); EditorUtility.DisplayDialog("Can't create directory", "Can't create directory \"" + _bundleDirectory + "\"", "OK"); throw; } } _objectName = descriptor.Name; _prefabPath = scene.path; _zipFilePath = _bakedDirectory + $"/{_objectName}.vwst"; _mobileReady = SdkSettings.MobileFeature.Enabled && descriptor.MobileReady; BuildAssetBundles(); CreateFolders(descriptor); string bundleFile = _bundleDirectory + "/" + _objectName; string tempBundlePath = _bakedDirectory + "/bundle"; string tempBundleManifest = tempBundlePath + ".manifest"; CopyBundles(bundleFile, tempBundlePath, tempBundleManifest); var androidBundleFile = _bundleDirectory + "/android_" + _objectName; var tempAndroidBundlePath = _bakedDirectory + "/android_bundle"; var tempAndroidBundleManifest = tempAndroidBundlePath + ".manifest"; if (_mobileReady) { CopyBundles(androidBundleFile, tempAndroidBundlePath, tempAndroidBundleManifest); } string tempInstallJsonFile = _bakedDirectory + "/install.json"; string tempBundleJsonFile = _bakedDirectory + "/bundle.json"; CreateConfig(descriptor, tempInstallJsonFile, tempBundleJsonFile); string tempBundleIconFile = _bakedDirectory + "/bundle.png"; CreateIcon(tempBundleIconFile, icon); List <string> filesToZip = new string[] { tempBundlePath, tempBundleManifest, tempBundleJsonFile, tempInstallJsonFile, tempBundleIconFile }.ToList(); if (_mobileReady) { filesToZip.Add(tempAndroidBundlePath); filesToZip.Add(tempAndroidBundleManifest); } return(ZipFiles(filesToZip)); #endif }