Esempio n. 1
0
        public static Quest CreateNewQuestAssetFromDialog()
        {
            var filePath = EditorUtility.SaveFilePanel("Save Quest As", s_lastDirectory, string.Empty, "asset");

            if (string.IsNullOrEmpty(filePath))
            {
                return(null);
            }
            s_lastDirectory = System.IO.Path.GetDirectoryName(filePath);
            var questWrapperType = QuestEditorUtility.GetWrapperType(typeof(Quest));

            if (questWrapperType == null)
            {
                Debug.LogError("Quest Machine: Internal error. Can't access Quest type!");
                return(null);
            }
            var quest = ScriptableObjectUtility.CreateScriptableObject(questWrapperType) as Quest;

            if (quest == null)
            {
                Debug.LogError("Quest Machine: Internal error. Can't create Quest object!");
                return(null);
            }
            var filename = System.IO.Path.GetFileNameWithoutExtension(filePath);

            quest.id.value    = filename.Replace(" ", string.Empty);
            quest.title.value = filename;
            return(SaveQuestAsAsset(quest, filePath, false));
        }
Esempio n. 2
0
        private void OnAddQuestContentType(object data)
        {
            var isSelectedQuest = m_isAsset;

            if (isSelectedQuest)
            {
                QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject();
            }
            var type    = data as Type;
            var content = ScriptableObjectUtility.CreateScriptableObject(type);

            content.name           = type.Name;
            m_selectedQuestContent = content as QuestContent;
            m_contentEditor        = null;
            if (isSelectedQuest)
            {
                AssetUtility.AddToAsset(content, QuestEditorWindow.selectedQuestSerializedObject.targetObject);
                QuestEditorWindow.UpdateSelectedQuestSerializedObject();
            }
            m_list.serializedProperty.arraySize++;
            m_list.index = m_list.serializedProperty.arraySize - 1;
            m_list.serializedProperty.GetArrayElementAtIndex(m_list.serializedProperty.arraySize - 1).objectReferenceValue = content;
            m_list.serializedProperty.serializedObject.ApplyModifiedProperties();
            m_serializedObject.ApplyModifiedProperties();
            if (isSelectedQuest)
            {
                QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject();
                AssetDatabase.SaveAssets();
            }
            m_needToClearFocus = true;
        }
        private List <QuestContent> CreateContentList()
        {
            var list = new List <QuestContent>();

            if (icon != null)
            {
                var iconContent = ScriptableObjectUtility.CreateScriptableObject <IconQuestContent>();
                iconContent.name  = "Icon";
                iconContent.image = icon;
                list.Add(iconContent);
            }
            if (!StringField.IsNullOrEmpty(m_headingText))
            {
                var headingContent = ScriptableObjectUtility.CreateScriptableObject <HeadingTextQuestContent>();
                headingContent.name         = "Heading";
                headingContent.headingLevel = 1;
                headingContent.headingText  = headingText;
                list.Add(headingContent);
            }
            if (!StringField.IsNullOrEmpty(bodyText))
            {
                var bodyContent = ScriptableObjectUtility.CreateScriptableObject <BodyTextQuestContent>();
                bodyContent.name     = "Body";
                bodyContent.bodyText = bodyText;
                list.Add(bodyContent);
            }
            return(list);
        }
Esempio n. 4
0
        private static LocalizedTextTable CreateLocalizedTextTableInstance()
        {
            var wrapperType = TypeUtility.GetWrapperType(typeof(LocalizedTextTable)) ?? typeof(LocalizedTextTable);
            var table       = ScriptableObjectUtility.CreateScriptableObject(wrapperType) as LocalizedTextTable;

            table.languages = new List <string> {
                "Default"
            };
            return(table);
        }
Esempio n. 5
0
        public static DialogueDatabase CreateDialogueDatabaseInstance()
        {
            Template template    = TemplateTools.LoadFromEditorPrefs();
            var      wrapperType = TypeUtility.GetWrapperType(typeof(DialogueDatabase)) ?? typeof(DialogueDatabase);
            var      database    = ScriptableObjectUtility.CreateScriptableObject(wrapperType) as DialogueDatabase;

            database.actors.Add(template.CreateActor(1, "Player", true));
            database.variables.Add(template.CreateVariable(1, "Alert", string.Empty));
            database.ResetEmphasisSettings();
            return(database);
        }
Esempio n. 6
0
        void OnWizardCreate()
        {
            EditorUtility.DisplayDialog("Note", "Please check that the BG Texture is placed at under a \"Resources/\" folder.", "ok");

            if (!System.IO.Directory.Exists("Assets/Actors"))
            {
                AssetDatabase.CreateFolder("Assets", "Actors");
            }

            ActorInfo actor = ScriptableObjectUtility.CreateScriptableObject("ActorInfo", "Assets/Actors/" + actorName + ".asset") as ActorInfo;

            ActorUtility.SetUpActorInfo(actor, actorName, sizeInPercent, textColor, textures);
            EditorGUIUtility.PingObject(actor);
        }
        public static DialogueDatabase CreateDialogueDatabaseInstance(bool createDefaultAssets = false)
        {
            var template    = Template.FromDefault();
            var wrapperType = RuntimeTypeUtility.GetWrapperType(typeof(DialogueDatabase)) ?? typeof(DialogueDatabase);
            var database    = ScriptableObjectUtility.CreateScriptableObject(wrapperType) as DialogueDatabase;

            database.ResetEmphasisSettings();
            if (createDefaultAssets)
            {
                database.actors.Add(template.CreateActor(1, "Player", true));
                database.variables.Add(template.CreateVariable(1, "Alert", string.Empty));
            }
            return(database);
        }
Esempio n. 8
0
        void OnWizardCreate()
        {
            EditorUtility.DisplayDialog("Note", "Please check that the BG Texture is placed at under a \"Resources/BG/\" folder.", "ok");

            if (!System.IO.Directory.Exists("Assets/Scenes"))
            {
                AssetDatabase.CreateFolder("Assets", "Scenes");
            }

            Scene scene = ScriptableObjectUtility.CreateScriptableObject("Scene", "Assets/Scenes/" + sceneName + ".asset") as Scene;

            ViNoSceneUtil.SetUpSceneInfo(scene, sceneName, "BG/" + texture.name);

            EditorGUIUtility.PingObject(scene);
        }
Esempio n. 9
0
    static public void CreateANewScenario( )
    {
        ScenarioNode[] scenariosInScene = GameObject.FindObjectsOfType(typeof(ScenarioNode)) as ScenarioNode[];
        if (scenariosInScene.Length > 0)
        {
        }

        for (int i = 0; i < scenariosInScene.Length; i++)
        {
            scenariosInScene[i].gameObject.SetActive(false);
        }


        if (!System.IO.Directory.Exists("Assets/" + ViNoToolbar.m_ScenarioName))
        {
            AssetDatabase.CreateFolder("Assets", ViNoToolbar.m_ScenarioName);
        }

        GameObject scenarioObj = ViNoToolUtil.CreateANewScenario(ViNoToolbar.m_ScenarioName, ViNoToolbar.m_StartAndPlay);
        GameObject startObj    = scenarioObj.transform.Find("START").gameObject;

        EditorGUIUtility.PingObject(startObj);

        Selection.activeObject = startObj;

        ViNoToolbar.m_AddedObject = startObj;
        ViNoToolbar.m_Selected    = 1;                  // Jump to Nodes Tab.

        ViNoToolbar.m_CurrScenarioNode = scenarioObj.GetComponent <ScenarioNode>();
        if (ViNoToolbar.m_CurrScenarioNode == null)
        {
            Debug.Log("CurrScenario NULL");
        }

        string    scenarioFlagDataPath = "Assets/" + ViNoToolbar.m_ScenarioName + "/" + ViNoToolbar.m_ScenarioName + "Flags.asset";
        string    scenarioSaveDataPath = "Assets/" + ViNoToolbar.m_ScenarioName + "/" + ViNoToolbar.m_ScenarioName + "SaveData.asset";
        FlagTable flagTable            = ScriptableObjectUtility.CreateScriptableObject("FlagTable", scenarioFlagDataPath) as FlagTable;

        ScriptableObjectUtility.CreateScriptableObject("ViNoSaveInfo", scenarioSaveDataPath);
        ViNoToolbar.m_CurrScenarioNode.flagTable = flagTable;

        ViNoToolbar.m_CurrScenarioNode.startNode     = startObj.GetComponent <ViNode>();
        ViNoToolbar.m_CurrScenarioNode.m_PlayAtStart = true;        //ViNoToolbar.m_StartAndPlay;
        ViNoToolbar.m_CurrScenarioNode = scenarioObj.GetComponent <ScenarioNode>();
//		DrawViNodesTab.CreateDialogNodeOfMenu();
    }
        private void OnAddQuestActionType(object data)
        {
            QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject();
            var type        = data as Type;
            var questAction = ScriptableObjectUtility.CreateScriptableObject(type);

            questAction.name = type.Name;
            m_selectedAction = questAction as QuestAction;
            m_actionEditor   = null;
            if (QuestEditorWindow.selectedQuest != null)
            {
                AssetUtility.AddToAsset(questAction, QuestEditorWindow.selectedQuest);
                m_selectedAction.SetRuntimeReferences(QuestEditorWindow.selectedQuest, null);
            }
            QuestEditorWindow.UpdateSelectedQuestSerializedObject();
            m_list.serializedProperty.arraySize++;
            m_list.index = m_list.serializedProperty.arraySize - 1;
            m_list.serializedProperty.GetArrayElementAtIndex(m_list.serializedProperty.arraySize - 1).objectReferenceValue = questAction;
            m_list.serializedProperty.serializedObject.ApplyModifiedProperties();
            QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject();
            AssetDatabase.SaveAssets();
        }
 static public Object CreateActorInfo(string createPath)
 {
     return(ScriptableObjectUtility.CreateScriptableObject("ActorInfo", createPath));
 }
    static public void CreateSoundData()
    {
        string path = "Assets/SoundData.asset";

        ScriptableObjectUtility.CreateScriptableObject("ScriptableSoundData", path);
    }
    static public void CreateMetaResource()
    {
        string path = "Assets/A MetaResource.asset";

        ScriptableObjectUtility.CreateScriptableObject("ResourceMetaData", path);
    }
    static public void CreateFlagTableData()
    {
        string path = "Assets/A FlagTableData.asset";

        ScriptableObjectUtility.CreateScriptableObject("FlagTable", path);
    }
Esempio n. 15
0
    static public void CreateConvScene(string templScenePath)
    {
        GameObject sceneRoot = CreateTemplScene(templScenePath);

        sceneRoot.name = "A Conversation Scene";

        string scenarioName = "A_Conversation";

        if (!System.IO.Directory.Exists("Assets/" + scenarioName))
        {
            AssetDatabase.CreateFolder("Assets", scenarioName);
        }

        GameObject scenarioObj = ViNoToolUtil.CreateANewScenario(scenarioName, true);
        GameObject startObj    = scenarioObj.transform.FindChild("START").gameObject;
//		scenarioObj.transform.parent.transform.parent = sceneRoot.transform;

        GameObject    node0         = new GameObject("0_Scene");
        LoadSceneNode loadSceneNode = node0.AddComponent <LoadSceneNode>();

        loadSceneNode.sceneName  = "Scene1";
        loadSceneNode.method     = LoadSceneNode.Methods.DESTROY_AND_LOAD;
        loadSceneNode.withFadeIn = true;

        loadSceneNode.transform.parent = startObj.transform;

        DialogPartNode dlgNode = ViNoToolUtil.AddDialogPartNode(startObj.transform);

        dlgNode.name = "1_Dialog";
        DialogPartData data0 = dlgNode.AddData("", "");
        DialogPartData data1 = dlgNode.AddData("Sachi", "Hello. I am Sachi.");
        DialogPartData data2 = dlgNode.AddData("", "");
        DialogPartData data3 = dlgNode.AddData("Maiko", "Hi. Sachi.");
        DialogPartData data4 = dlgNode.AddData("Sachi", "Bye Bye !");
        DialogPartData data5 = dlgNode.AddData("Maiko", "Bye Bye !");
        DialogPartData data6 = dlgNode.AddData("", "");

        data0.enterActorEntries              = new DialogPartData.ActorEntry[1];
        data0.enterActorEntries[0]           = new DialogPartData.ActorEntry();
        data0.enterActorEntries[0].actorName = "Sachi";
        data0.actionID = DialogPartNodeActionType.EnterActor;
        data0.enterActorEntries[0].position = ViNoToolkit.SceneEvent.ActorPosition.middle_left;

        data1.isName = true;

        data2.enterActorEntries              = new DialogPartData.ActorEntry[1];
        data2.enterActorEntries[0]           = new DialogPartData.ActorEntry();
        data2.enterActorEntries[0].actorName = "Maiko";
        data2.actionID = DialogPartNodeActionType.EnterActor;
        data2.enterActorEntries[0].position = ViNoToolkit.SceneEvent.ActorPosition.middle_right;
        data3.isName = true;

        data4.isName = true;
        data5.isName = true;

        data6.actionID                      = DialogPartNodeActionType.ExitActor;
        data6.exitActorEntries              = new DialogPartData.ActorEntry[2];
        data6.exitActorEntries[0]           = new DialogPartData.ActorEntry();
        data6.exitActorEntries[1]           = new DialogPartData.ActorEntry();
        data6.exitActorEntries[0].actorName = "Sachi";
        data6.exitActorEntries[1].actorName = "Maiko";

#if false
        GameObject parentObj = GameObject.Find("Panels");

        DrawObjectsTab.CreateBG("BG", parentObj);
        GameObject ch1 = DrawObjectsTab.Create2Layer("Ch1", parentObj);
        GameObject ch2 = DrawObjectsTab.Create2Layer("Ch2", parentObj);

        ch1.transform.localPosition = new Vector3(-120f, 0f, 0f);
        ch2.transform.localPosition = new Vector3(120f, 0f, 0f);

        AssetDatabase.MoveAsset("Assets/BG", "Assets/" + scenarioName + "/BG");
        AssetDatabase.MoveAsset("Assets/Ch1", "Assets/" + scenarioName + "/Ch1");
        AssetDatabase.MoveAsset("Assets/Ch2", "Assets/" + scenarioName + "/Ch2");
#endif

        string       scenarioFlagDataPath = "Assets/" + scenarioName + "/" + scenarioName + "Flags.asset";
        string       scenarioSaveDataPath = "Assets/" + scenarioName + "/" + scenarioName + "SaveData.asset";
        FlagTable    flagTable            = ScriptableObjectUtility.CreateScriptableObject("FlagTable", scenarioFlagDataPath) as FlagTable;
        ViNoSaveInfo saveInfo             = ScriptableObjectUtility.CreateScriptableObject("ViNoSaveInfo", scenarioSaveDataPath) as ViNoSaveInfo;
        ScenarioNode scenarioNode         = scenarioObj.GetComponent <ScenarioNode>();
        scenarioNode.m_PlayAtStart = true;
        scenarioNode.flagTable     = flagTable;
//		scenarioNode.saveInfo = saveInfo;

        ScenarioCtrl scenarioCtrl = GameObject.FindObjectOfType(typeof(ScenarioCtrl)) as ScenarioCtrl;
        scenarioCtrl.quickSaveSlot = saveInfo;
        scenarioCtrl.saveInfo      = saveInfo;

        // Create an ActorLibrary and a SceneLibrary.
        string actorLibPrefabPath = "Assets/" + scenarioName + "/ActorLibrary.prefab";
        string sceneLibPrefabPath = "Assets/" + scenarioName + "/SceneLibrary.prefab";

        ViNoScenarioDataUtil.CreateActorLibrary(actorLibPrefabPath);
        ViNoScenarioDataUtil.CreateSceneLibrary(sceneLibPrefabPath);
        GameObject.DestroyImmediate(GameObject.Find("ActorLibrary"));
        GameObject.DestroyImmediate(GameObject.Find("SceneLibrary"));

//		ViNoToolkit.ActorInfo actor1 = ViNoScenarioDataUtil.CreateActorInfo() as ViNoToolkit.ActorInfo;
        ViNoToolkit.SceneEvent sceneEvt = GameObject.FindObjectOfType(typeof(ViNoToolkit.SceneEvent)) as ViNoToolkit.SceneEvent;

        ViNoToolkit.ActorLibrary actorLib = AssetDatabase.LoadAssetAtPath(actorLibPrefabPath, typeof(ViNoToolkit.ActorLibrary)) as ViNoToolkit.ActorLibrary;
        ViNoToolkit.SceneLibrary sceneLib = AssetDatabase.LoadAssetAtPath(sceneLibPrefabPath, typeof(ViNoToolkit.SceneLibrary)) as ViNoToolkit.SceneLibrary;

/*		actorLib.actorEntries = new ViNoToolkit.ActorInfo[ 1 ];
 *              actorLib.actorEntries[ 0 ] = actor1;
 * //*/
        sceneEvt.actorLib = actorLib;
        sceneEvt.sceneLib = sceneLib;
    }
Esempio n. 16
0
        protected virtual void AddMessageNode()
        {
            var quest = QuestEditorWindow.selectedQuest;

            if (quest == null)
            {
                return;
            }

            // Add a new node:
            var parentNode = GetParentNode(quest);

            if (parentNode == null)
            {
                return;
            }
            var node = new QuestNode(new StringField(hudText), new StringField(), QuestNodeType.Condition);

            quest.nodeList.Add(node);
            node.childIndexList.AddRange(parentNode.childIndexList);
            parentNode.childIndexList.Clear();
            parentNode.childIndexList.Add(quest.nodeList.Count - 1);
            node.canvasRect = new Rect(parentNode.canvasRect.x + QuestNode.DefaultNodeWidth + 20, parentNode.canvasRect.y, QuestNode.DefaultNodeWidth, QuestNode.DefaultNodeHeight);

            // Add success node if specified:
            if (leadsToSuccess)
            {
                AddSuccessNode(quest, node);
            }

            // Set node's counter condition:
            var condition = ScriptableObjectUtility.CreateScriptableObject <MessageQuestCondition>();

            condition.name      = "messageCondition";
            condition.message   = new StringField(message);
            condition.parameter = new StringField(parameter);
            condition.value     = new MessageValue();
            node.conditionSet.conditionList.Add(condition);
            AddAndSaveSubasset(condition);

            // Set node's UI content:
            var stateInfo = node.GetStateInfo(QuestNodeState.Active);

            var hudContentList = stateInfo.GetContentList(QuestContentCategory.HUD);

            hudContentList.Add(CreateBodyContent(hudText));

            var journalContentList = stateInfo.GetContentList(QuestContentCategory.Journal);

            journalContentList.Add(CreateBodyContent(journalText));

            var dialogueContentList = stateInfo.GetContentList(QuestContentCategory.Dialogue);

            dialogueContentList.Add(CreateBodyContent(dialogueText));

            // Add alert action:
            var alertAction = ScriptableObjectUtility.CreateScriptableObject <AlertQuestAction>();

            alertAction.contentList.Add(CreateBodyContent(hudText));
            stateInfo.actionList.Add(alertAction);
            AddAndSaveSubasset(alertAction);

            // Update quest's internal references:
            quest.SetRuntimeReferences();

            // Refresh editor windows:
            QuestEditorWindow.RepaintNow();              // Quest Editor window.
            QuestEditorWindow.RepaintCurrentEditorNow(); // Inspector.
        }
 static public void CreateScene()
 {
     ScriptableObjectUtility.CreateScriptableObject("Scene", "Assets/A Scene Data.asset");
 }
Esempio n. 18
0
        protected virtual void AddCounterAndNode()
        {
            var quest = QuestEditorWindow.selectedQuest;

            if (quest == null)
            {
                return;
            }

            // Add counter:
            var existingCounter = quest.GetCounter(counterName); // Delete existing first.

            if (existingCounter != null)
            {
                quest.counterList.Remove(existingCounter);
            }
            var counter             = new QuestCounter(new StringField(counterName), Mathf.Max(0, min), min, max, QuestCounterUpdateMode.Messages);
            var messageAndParameter = incrementMessage.Split(':');

            counter.messageEventList.Add(new QuestCounterMessageEvent(new StringField(quest.id),
                                                                      new StringField(messageAndParameter[0]), new StringField(messageAndParameter[1]),
                                                                      QuestCounterMessageEvent.Operation.ModifyByLiteralValue, 1));
            quest.counterList.Add(counter);

            // Add a new node:
            var parentNode = GetParentNode(quest);

            if (parentNode == null)
            {
                return;
            }
            var node = new QuestNode(new StringField(string.Format(hudInstructionsText, min.ToString(), max.ToString())), new StringField(), QuestNodeType.Condition);

            quest.nodeList.Add(node);
            node.childIndexList.AddRange(parentNode.childIndexList);
            parentNode.childIndexList.Clear();
            parentNode.childIndexList.Add(quest.nodeList.Count - 1);
            node.canvasRect = new Rect(parentNode.canvasRect.x + QuestNode.DefaultNodeWidth + 20, parentNode.canvasRect.y, QuestNode.DefaultNodeWidth, QuestNode.DefaultNodeHeight);

            // Add success node if specified:
            if (leadsToSuccess)
            {
                AddSuccessNode(quest, node);
            }

            // Set node's counter condition:
            var condition = ScriptableObjectUtility.CreateScriptableObject <CounterQuestCondition>();

            condition.name                 = "counterCondition";
            condition.counterIndex         = quest.GetCounterIndex(counterName);
            condition.counterValueMode     = CounterValueConditionMode.AtLeast;
            condition.requiredCounterValue = new QuestNumber(max);
            node.conditionSet.conditionList.Add(condition);
            AddAndSaveSubasset(condition);

            // Set node's UI content:
            var stateInfo = node.GetStateInfo(QuestNodeState.Active);

            var hudContentList = stateInfo.GetContentList(QuestContentCategory.HUD);

            AddBodyContent(hudContentList, hudInstructionsText);
            AddBodyContent(hudContentList, hudCountText);

            var journalContentList = stateInfo.GetContentList(QuestContentCategory.Journal);

            AddBodyContent(journalContentList, journalText);

            var dialogueContentList = stateInfo.GetContentList(QuestContentCategory.Dialogue);

            AddBodyContent(dialogueContentList, dialogueText);

            // Add alert action:
            if (!string.IsNullOrEmpty(hudInstructionsText))
            {
                var alertAction = ScriptableObjectUtility.CreateScriptableObject <AlertQuestAction>();
                AddBodyContent(alertAction.contentList, hudInstructionsText);
                stateInfo.actionList.Add(alertAction);
                AddAndSaveSubasset(alertAction);
            }

            // Update quest's internal references:
            quest.SetRuntimeReferences();

            // Refresh editor windows:
            QuestEditorWindow.RepaintNow();              // Quest Editor window.
            QuestEditorWindow.RepaintCurrentEditorNow(); // Inspector.
        }
    static public void CreateGameSaveData()
    {
        string path = "Assets/A SaveData.asset";

        ScriptableObjectUtility.CreateScriptableObject("ViNoSaveInfo", path);
    }