Пример #1
0
    private IEnumerator LoadCoroutine()
    {
        yield return(null);

        try
        {
            ReadWorldFile.Read(SelectedWorld.GetLoadStream(),
                               null, GetComponent <VoxelArray>(), false);
        }
        catch (MapReadException e)
        {
            var dialog = loadingGUI.gameObject.AddComponent <DialogGUI>();
            dialog.message          = e.FullMessage;
            dialog.yesButtonText    = "Close";
            dialog.yesButtonHandler = () =>
            {
                Close(Scenes.MENU);
            };
            Debug.LogError(e.InnerException);
            yield break;
        }
        finally
        {
            Destroy(loadingGUI);
        }
    }
Пример #2
0
    public List <string> BuildWorld(Transform cameraPivot, VoxelArray voxelArray, bool editor)
    {
        var warnings = ReadWorldFile.Read(Resources.Load <TextAsset>("Templates/indoor"),
                                          cameraPivot, voxelArray, editor);

        foreach (var obj in voxelArray.IterateObjects())
        {
            if (obj is PlayerObject)
            {
                var behavior = new SoundBehavior();
                behavior.SetProperty("dat", data);
                obj.behaviors.Add(behavior);
                break;
            }
        }
        return(warnings);
    }
Пример #3
0
    private IEnumerator LoadCoroutine()
    {
        yield return(null);

        var guiGameObject = loadingGUI.gameObject;

        List <string> warnings;

        try
        {
            warnings = ReadWorldFile.Read(SelectedWorld.GetLoadStream(),
                                          cameraPivot, voxelArray, true);
        }
        catch (MapReadException e)
        {
            var dialog = guiGameObject.AddComponent <DialogGUI>();
            dialog.message          = e.Message;
            dialog.yesButtonText    = "Close";
            dialog.yesButtonHandler = () =>
            {
                voxelArray.unsavedChanges = false;
                Close();
            };
            Destroy(loadingGUI);
            Debug.LogError(e);
            yield break;
        }
        // reading the file creates new voxels which sets the unsavedChanges flag
        // and clears existing voxels which sets the selectionChanged flag
        voxelArray.unsavedChanges   = false;
        voxelArray.selectionChanged = false;

        Destroy(loadingGUI);
        foreach (MonoBehaviour b in enableOnLoad)
        {
            b.enabled = true;
        }

        if (PlayerPrefs.HasKey("last_editScene_version"))
        {
            string lastVersion = PlayerPrefs.GetString("last_editScene_version");
            if (CompareVersions(lastVersion, "1.2.0") == -1)
            {
                var dialog = guiGameObject.AddComponent <DialogGUI>();
                dialog.message          = "N-Space has been updated with the ability to bevel edges! Would you like a tutorial?";
                dialog.yesButtonText    = "Yes";
                dialog.noButtonText     = "No";
                dialog.yesButtonHandler = () =>
                {
                    TutorialGUI.StartTutorial(Tutorials.BEVEL_TUTORIAL, guiGameObject, voxelArray, touchListener);
                };
            }
            else if (CompareVersions(lastVersion, "1.3.0") == -1)
            {
                LargeMessageGUI.ShowLargeMessageDialog(guiGameObject, "<b>Version 1.3.0 update</b>\n\n"
                                                       + "N-Space has been updated with a new behavior for sound effects and music. Try it out!\n\n"
                                                       + "Also, check the main menu for links to video tutorials and a subreddit.");
            }
        }
        PlayerPrefs.SetString("last_editScene_version", Application.version);

        if (warnings.Count > 0)
        {
            // avoids a bug where two dialogs created on the same frame will put the unfocused one on top
            // for some reason it's necessary to wait two frames
            yield return(null);

            yield return(null);

            string message = "There were some issues with reading the world:\n\n  •  " +
                             string.Join("\n  •  ", warnings.ToArray());
            LargeMessageGUI.ShowLargeMessageDialog(guiGameObject, message);
        }
    }