Exemplo n.º 1
0
    void LoadDatabase()
    {
        itemdb    = ScriptableObject.CreateInstance <ItemDatabase>();
        conddb    = ScriptableObject.CreateInstance <AuraDatabase>();
        perkdb    = ScriptableObject.CreateInstance <PerkDatabase>();
        skilldb   = ScriptableObject.CreateInstance <SkillDatabase>();
        npcdb     = ScriptableObject.CreateInstance <NPCDatabase>();
        factiondb = ScriptableObject.CreateInstance <FactionDatabase>();

        itemdb.ReloadDatabase();
        conddb.ReloadDatabase();
        perkdb.ReloadDatabase();
        skilldb.ReloadDatabase();
        npcdb.ReloadDatabase();
        factiondb.ReloadDatabase();
    }
Exemplo n.º 2
0
    void OnGUI()
    {
        /*
         * Editor toolbar
         */
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Create New NPC", GUILayout.Width(300)))
        {
            editorState = EditorState.Create;
            ResetDialogFields();
            ResetInventoryFields();
            npcDialog = new List <NPCDialog>();
            return;
        }
        if (GUILayout.Button("Reload Database", GUILayout.Width(300)))
        {
            npcDatabase.ReloadDatabase();
            return;
        }
        if (GUILayout.Button("Save to JSON", GUILayout.Width(300)))
        {
            // Delete this item from the database.
            npcDatabase.SaveDatabase();
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
        EditorGUILayout.EndHorizontal();

        if (npcDatabase == null || npcDatabase.NPCs == null)
        {
            EditorGUILayout.LabelField("The database may need reloading.");
            return;
        }

        EditorGUILayout.BeginHorizontal();
        // List all of the items on the left hand side.
        listScrollPos = EditorGUILayout.BeginScrollView(listScrollPos, false, false, GUILayout.Width(450), GUILayout.MinHeight(550));
        foreach (NPC i in npcDatabase.NPCs)
        {
            // Horizontal group per condition.
            EditorGUILayout.BeginHorizontal(GUILayout.Width(400.0f));

            if (GUILayout.Button("X", GUILayout.Width(50.0f)))
            {
                // Delete this item from the database.
                npcDatabase.RemoveNPC(i);
                EditorUtility.SetDirty(npcDatabase);
                AssetDatabase.SaveAssets();
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = npcDatabase;
                return;
            }

            if (GUILayout.Button("C", GUILayout.Width(50.0f)))
            {
                // Duplicate this item.
                npcDatabase.DuplicateNPC(i);
                EditorUtility.SetDirty(npcDatabase);
                AssetDatabase.SaveAssets();
                EditorUtility.FocusProjectWindow();
                Selection.activeObject = npcDatabase;
                return;
            }

            if (GUILayout.Button(i.NPCName.ToString(), GUILayout.Width(300)))
            {
                if (editorState == EditorState.Edit)
                {
                    SaveExistingNPC();
                }
                else if (editorState == EditorState.Create)
                {
                    SaveNewNPC();
                }

                //Get the new item and its associated data.
                selectedNPC = i;
                GetNPCData();

                EditorUtility.FocusProjectWindow();
                Selection.activeObject = npcDatabase;

                editorState = EditorState.Edit;

                return;
            }

            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();

        if (editorState == EditorState.Create || editorState == EditorState.Edit)
        {
            ShowCreateWindow();
        }

        EditorGUILayout.EndHorizontal();
    }