Пример #1
0
    void OnEnable()
    {
        string objectPath = EditorPrefs.GetString("UnitDataPath");
        unitPDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(UnitDataList)) as UnitDataList;
           
        string atkPath = EditorPrefs.GetString("AttackDatabasePath");
        atkDataList = AssetDatabase.LoadAssetAtPath(atkPath, typeof(AttackDataList)) as AttackDataList;

    }
    /*****************************************************/

    void OnEnable()
    {   
        string objectPath = EditorPrefs.GetString("AttackDatabasePath");
        atkDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(AttackDataList)) as AttackDataList;
        if(isCardEdit)
            cardDataBase = (CardDatabase)EditorWindow.GetWindow(typeof(CardDatabase));
        else
            unitDataBase = (UnitDatabase)EditorWindow.GetWindow(typeof(UnitDatabase));
    }
Пример #3
0
    void OnEnable()
    {
        //Link to the correct DB on enable. CardDataPath is necessarry for the other links
        string objectPath = EditorPrefs.GetString("CardDataPath");
        cardDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(CardDataList)) as CardDataList;

        string atkPath = EditorPrefs.GetString("AttackDatabasePath");
        atkDataList = AssetDatabase.LoadAssetAtPath(atkPath, typeof(AttackDataList)) as AttackDataList;

        string unitPath = EditorPrefs.GetString("UnitDataPath");
        unitDataList = AssetDatabase.LoadAssetAtPath(unitPath, typeof(UnitDataList)) as UnitDataList;

    }
Пример #4
0
    static Startup()
    {
        //Get all the database paths setup for the editor
        string atkPath = "Assets/AttackList.asset";
        string unitPath = "Assets/UnitList.asset";
        string cardPath = "Assets/CardList.asset";

        //Attacks
        EditorPrefs.SetString("AttackDatabasePath", atkPath);
        attackDataList = AssetDatabase.LoadAssetAtPath(atkPath, typeof(AttackDataList)) as AttackDataList;
        if(attackDataList == null)
        {
            Debug.Log("No attack database, creating empty one.");
            AttackDataList asset = ScriptableObject.CreateInstance<AttackDataList>();
            AssetDatabase.CreateAsset(asset, atkPath);
            AssetDatabase.SaveAssets();
        }

        //Creatures
        EditorPrefs.SetString("UnitDataPath", unitPath);
        unitDataList = AssetDatabase.LoadAssetAtPath(unitPath, typeof(UnitDataList)) as UnitDataList;
        if (unitDataList == null)
        {
            Debug.Log("No unit database, creating empty one.");
            UnitDataList asset = ScriptableObject.CreateInstance<UnitDataList>();
            AssetDatabase.CreateAsset(asset, unitPath);
            AssetDatabase.SaveAssets();
        }

        //Cards
        EditorPrefs.SetString("CardDataPath", cardPath);
        cardDataList = AssetDatabase.LoadAssetAtPath(cardPath, typeof(CardDataList)) as CardDataList;
        if(cardDataList == null)
        {
            Debug.Log("No card database, creating empty one.");
            CardDataList asset = ScriptableObject.CreateInstance<CardDataList>();
            AssetDatabase.CreateAsset(asset, cardPath);
            AssetDatabase.SaveAssets();
        }
    }
Пример #5
0
    void OnGUI()
    {
        /***********************************/
        //Header
        /***********************************/

        if (atkDataList == null)
        {
            string objectPath = EditorPrefs.GetString("AttackDatabasePath");
            atkDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(AttackDataList)) as AttackDataList;

        }
        if (unitDataList == null)
        {
            string objectPath = EditorPrefs.GetString("UnitDataPath");
            unitPDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(UnitDataList)) as UnitDataList;
        }

        if(cardDataBase == null)
        {
            cardDataBase = (CardDatabase)EditorWindow.GetWindow(typeof(CardDatabase));
        }

        GUILayout.Label("Unit Data Editor", EditorStyles.boldLabel);
        if (unitDataList.unitList.Count == 0)
        {
            EditorGUILayout.LabelField("No Unit database available, error.");
        }
        else
        {
            if (buttonToggled == null || buttonToggled.Count < unitDataList.unitList.Count)
            {
                buttonToggled = new List<bool>();
                toggledIndex = 0;
                for (int i = 0; i < unitDataList.unitList.Count; i++)
                    buttonToggled.Add(false);
            }

            if (toggledIndex > unitDataList.unitList.Count)
            {
                Debug.Log("Index was out of bounds");
                toggledIndex = unitDataList.unitList.Count - 1;
            }

            /************************************************************/

            /******************************************/
            //Display things
            /******************************************/
            if (unitDataList != null)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Unit List Data", EditorStyles.boldLabel);
                filterType = (UnitTypes)EditorGUILayout.EnumPopup(filterType);

                if (GUILayout.Button("Sort", GUILayout.ExpandWidth(false)))
                {
                    sortByName();
                }

                GUILayout.EndHorizontal();
                if (unitDataList.unitList == null)
                {
                    Debug.Log("Mistakes were made - You should never reach this");
                }

                /****************************************/
                //How the list will look
                /***************************************/

                if (unitDataList.unitList.Count > 0)
                {
                    if (unitDataList.unitList[toggledIndex].uType != filterType)
                    {
                        toggledIndex = 0;
                        findNext();
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.BeginVertical();
                    //----------Show all the buttons-----------
                    showScrollButtons();
                    //-----------------------------------------
                    EditorGUILayout.EndVertical();
                    GUILayout.Space(5);


                    EditorGUILayout.BeginVertical();
                    //---------Current selection info-----------

                    //SHOW UNIT SUMMARY
                    showUnitSummary();

                    /*************************************/
                    //UnitAttack WindowSpawn
                    /************************************/
                    GUILayout.Space(10);
                    EditorGUILayout.LabelField("Unit Attacks");

                    atkScroll = EditorGUILayout.BeginScrollView(atkScroll, GUILayout.Height(120));
                    foreach (string x in unitDataList.unitList[toggledIndex].attacksData.ToList<String>())
                    {
                        AttackData knownAtk = atkDataList.findByID(x);
                        if (knownAtk != null)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.TextField(knownAtk.aName, knownAtk.pattern.ToString());
                            EditorGUILayout.TextField("Damage: " + knownAtk.expectedMin + " - " + knownAtk.expectedMax);
                            EditorGUILayout.TextField("Range: " + knownAtk.range.ToString());
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    EditorGUILayout.EndScrollView();
                    

                    if (GUILayout.Button("Link this unit"))
                    {
                        cardDataBase.assignElement(unitDataList.unitList[toggledIndex].uniqueId);
                        cardDataBase.Repaint();
                    }
                    EditorGUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.Label("This Unit List is Empty.");
                }

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(unitDataList);
                }
            }
        }
    }
    void OnGUI()
    {
        if (atkDataList == null)
        {
            string objectPath = EditorPrefs.GetString("AttackDatabasePath");
            atkDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(AttackDataList)) as AttackDataList;
            
        }

        if(isCardEdit && cardDataBase == null)
        {
            cardDataBase = (CardDatabase)EditorWindow.GetWindow(typeof(CardDatabase));
            unitDataBase = null;
        }
        else if(!isCardEdit && unitDataBase == null)
        {
            unitDataBase = (UnitDatabase)EditorWindow.GetWindow(typeof(UnitDatabase));
            cardDataBase = null;
        }

        if(atkDataList.attackList.Count == 0)
            EditorGUILayout.LabelField("Attack List Data Not Available", EditorStyles.boldLabel);
        else
        {
            if (buttonToggled == null || buttonToggled.Count < atkDataList.attackList.Count)
            {
                buttonToggled = new List<bool>();
                toggledIndex = 0;
                for (int i = 0; i < atkDataList.attackList.Count; i++)
                    buttonToggled.Add(false);
            }

            //Filter list or something
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Attack List Data", EditorStyles.boldLabel);

            filterPattern = (AttackPattern)EditorGUILayout.EnumPopup(filterPattern);
            if (GUILayout.Button("Sort", GUILayout.ExpandWidth(false)))
            {
                sortByName();
            }
            GUILayout.EndHorizontal();

            //Show the list
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical(GUILayout.Width(180));

            showScrollButtons();

            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical();
            showAttackSummary();

            if(isCardEdit)
            {
                if (GUILayout.Button("Link this attack"))
                {
                    cardDataBase.assignElement(atkDataList.attackList[toggledIndex].uniqueId);
                    cardDataBase.Repaint();
                }
            }
            else
            {
                if (GUILayout.Button("Add this attack"))
                {
                    unitDataBase.AddAttack(unitDataBase.toggledIndex, atkDataList.attackList[toggledIndex].uniqueId);
                    unitDataBase.Repaint();
                }
            }      
            EditorGUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
    }