Ejemplo n.º 1
0
        private void OnGUI()
        {
            Repaint();

            //! Should probably only run this line if an Item asset was created or deleted.
            var items = ScriptableObjectUtility.GetAllInstances <Item>().OrderBy(i => i.id).ToArray();

            EditorGUILayout.BeginHorizontal();
            selectedItem = DrawItemsSidebar(items);
            DrawSelectedItem();
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Generate ItemDatabase"))
            {
                ItemDatabaseUtility.GenerateItemDatabase();
            }
        }
    private void fillDictionary()
    {
        LocalizedText[] allLocalizedTexts = ScriptableObjectUtility.GetAllInstances <LocalizedText>();
        allLanguages.allLocalizedTexts.Clear();

        Undo.RecordObject(allLanguages, "allLanguages dictionary");

        string key;

        for (int i = 0; i < allLocalizedTexts.Length; i++)
        {
            key = allLocalizedTexts[i].textsGroup.name + "-" + allLocalizedTexts[i].textID;
            allLanguages.allLocalizedTexts.Add(new LocalizedTextData {
                id = key, text = allLocalizedTexts[i]
            });
        }

        EditorUtility.SetDirty(allLanguages);
        AssetDatabase.SaveAssets();

        Debug.Log(allLanguages.allLocalizedTexts.Count + " references added to the dictionary.");
    }
Ejemplo n.º 3
0
        private static ItemDatabase GetItemDatabase()
        {
            var databases = ScriptableObjectUtility.GetAllInstances <ItemDatabase>();

            ItemDatabase itemDB = null;

            if (databases.Length < 1)
            {
                Debug.Log("Creating a new ItemDatabase since none exist.");
                itemDB = ScriptableObjectUtility.CreateAsset <ItemDatabase>();
            }
            else if (databases.Length > 1)
            {
                Debug.LogError("Multiple ItemDatabases exist. Please delete the extra(s) and try again.");
            }
            else
            {
                itemDB = databases[0];
            }

            return(itemDB);
        }
    private static void checkPreviousLanguages()
    {
        // Check if there are already any LocalizableTexts previous to the creation
        // of AllGameLanguages Instance, in positive case, add the languages contained as GameLanguages to it.
        // This is usefull in case that AllGameLanguages may was accidentaly deleted, to avoid
        // losing all the localized Text data when the LocalizedTexts load the config
        // data of the new AllGameLanguages instance in the OnEnable event of their Editor.
        LocalizedText[] projectLocalizedTextList = ScriptableObjectUtility.GetAllInstances <LocalizedText>();

        if (projectLocalizedTextList != null && projectLocalizedTextList.Length > 0)
        {
            LocalizedText locTAux = projectLocalizedTextList[0];

            for (int i = 0; i < locTAux.localizedTextsList.Count; i++)
            {
                if (!AllGameLanguages.Instance.gameLanguagesList.Exists(x => x.gameLanguage.code.Equals(locTAux.localizedTextsList[i].languageInfo.code)))
                {
                    AllGameLanguages.Instance.gameLanguagesList.Add(
                        new GameLanguageItem(locTAux.localizedTextsList[i].languageInfo));
                }
            }
        }
    }
Ejemplo n.º 5
0
        private static List <Item> GetAllItemAssets()
        {
            var result = new List <Item>();

            var instances   = ScriptableObjectUtility.GetAllInstances <Item>();
            var gatheredIDs = new List <int>();

            for (int i = 0; i < instances.Length; i++)
            {
                if (gatheredIDs.Contains(instances[i].id))
                {
                    var sharedID = result[gatheredIDs.IndexOf(instances[i].id)].name;
                    Debug.LogWarning("'" + instances[i].name + "' was excluded from the ItemDatabase because it shares its ID (" + instances[i].id + ") with '" + sharedID + "'.");
                }
                else
                {
                    result.Add(instances[i]);
                    gatheredIDs.Add(instances[i].id);
                }
            }

            result = result.OrderBy(i => i.id).ToList();
            return(result);
        }
Ejemplo n.º 6
0
    private static void RefreshReferences(ScriptableObjectPersistence sop)
    {
        Undo.RecordObject(sop, "Refresh Scriptable Object References");

        var pos = FindFirstAsset <VectorValue>("Player t:VectorValue");

        SetPrivateField(sop, "_playerPosition", pos);

        var health = FindFirstAsset <ConstrainedFloat>("Health t:ConstrainedFloat");

        SetPrivateField(sop, "_health", health);

        var mana = FindFirstAsset <ConstrainedFloat>("Mana t:ConstrainedFloat");

        SetPrivateField(sop, "_mana", mana);

        var lumen = FindFirstAsset <ConstrainedFloat>("Lumen t:ConstrainedFloat");

        SetPrivateField(sop, "_lumen", lumen);

        var xp = FindFirstAsset <XPSystem>("Player t:XPSystem");

        SetPrivateField(sop, "_xpSystem", xp);

        var inv = FindFirstAsset <Inventory>("Player t:Inventory");

        SetPrivateField(sop, "_playerInventory", inv);

        var bools  = ScriptableObjectUtility.GetAllInstances <BoolValue>();
        var chests = new List <BoolValue>();
        var doors  = new List <BoolValue>();
        var bosses = new List <BoolValue>();

        for (int i = 0; i < bools.Length; i++)
        {
            var path = AssetDatabase.GetAssetPath(bools[i]);
            if (path.Contains("Chest"))
            {
                chests.Add(bools[i]);
            }
            else if (path.Contains("Door"))
            {
                doors.Add(bools[i]);
            }
            else if (path.Contains("Bosses"))
            {
                bosses.Add(bools[i]);
            }
        }
        SetPrivateField(sop, "_chests", chests.ToArray());
        SetPrivateField(sop, "_doors", doors.ToArray());
        SetPrivateField(sop, "_bosses", bosses.ToArray());

        var inventories       = ScriptableObjectUtility.GetAllInstances <Inventory>();
        var vendorInventories = new List <Inventory>();

        for (int i = 0; i < inventories.Length; i++)
        {
            var path = AssetDatabase.GetAssetPath(inventories[i]);
            if (path.Contains("Vendor"))
            {
                vendorInventories.Add(inventories[i]);
            }
        }
        SetPrivateField(sop, "_vendorInventories", vendorInventories.ToArray());

        Debug.Log("SOP: Refreshed references.");
    }
Ejemplo n.º 7
0
 protected override void Init()
 {
     targetReaction = target as QuestReaction;
     allQuestsList  = new List <Quest>(ScriptableObjectUtility.GetAllInstances <Quest>());
 }