Example #1
0
    private void OnEnable()
    {
        iPlayerAttributeState = GameState.Instance.GetEntity <IPlayerAttributeState>();
        GameState.Instance.Registor <IPlayerAttributeState>(IPlayerAttributeStateChanged);
        Type         t            = typeof(IAttributeState);
        PropertyInfo propertyInfo = t.GetProperty(field_Attribute);

        if (propertyInfo != null)
        {
            FieldExplanAttribute fea = FieldExplanAttribute.GetPropertyExplan(propertyInfo);
            if (fea != null)
            {
                showName = fea.GetExplan();
            }
            else
            {
                showName = null;
            }
        }
        else
        {
            showName = null;
        }
        if (!string.IsNullOrEmpty(showName))
        {
            IPlayerAttributeStateChanged(iPlayerAttributeState, propertyInfo.Name);
        }
    }
Example #2
0
    /// <summary>
    /// 获取指定枚举的值
    /// </summary>
    /// <param name="target"></param>
    /// <returns></returns>
    public static string GetEnumExplan(Enum target)
    {
        Type      type      = target.GetType();
        FieldInfo fieldInfo = type.GetFields().Where(temp => temp.Name.Equals(target.ToString())).FirstOrDefault();

        if (fieldInfo != null)
        {
            FieldExplanAttribute attr = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).Select(temp => temp as FieldExplanAttribute).FirstOrDefault();
            if (attr != null)
            {
                return(attr.GetExplan());
            }
        }
        return(target.ToString());
    }
Example #3
0
    private void Awake()
    {
        //重置路径
        dataAllPath = Application.dataPath + @"\Scripts\Data\Resources\Data\Stuff";

        dataDic      = new Dictionary <string, TextAsset>();
        stuffDataDic = new Dictionary <string, GameObject>();

        TextAsset[] allTextAssets = Resources.LoadAll <TextAsset>(StuffData.dataDirectoryPath);
        foreach (TextAsset textAsset in allTextAssets)
        {
            dataDic.Add(textAsset.name, textAsset);
        }
        GameObject[] allPrefabs = Resources.LoadAll <GameObject>(StuffDataInfo.stuffPrefabDirectoryPath);
        foreach (GameObject prefab in allPrefabs)
        {
            stuffDataDic.Add(prefab.name, prefab);
        }
        goodsTypeToNameDic = new Dictionary <int, string>();
        //只放入材料类
        Type goodsType = typeof(EnumGoodsType);

        EnumGoodsType[] enumGoodsTypes = Enum.GetValues(typeof(EnumGoodsType)).OfType <EnumGoodsType>().
                                         Where(temp => temp > EnumGoodsType.MineralBig && temp < EnumGoodsType.IngotCasting).
                                         Where(temp => ((int)temp) % 1000 != 0).ToArray();
        foreach (EnumGoodsType enumGoodsType in enumGoodsTypes)
        {
            FieldInfo fieldInfo = goodsType.GetField(enumGoodsType.ToString());
            if (fieldInfo == null)
            {
                continue;
            }
            FieldExplanAttribute fieldExplanAttribute = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().FirstOrDefault();
            if (fieldExplanAttribute != null)
            {
                string explanName = fieldExplanAttribute.GetExplan();
                if (goodsTypeToNameDic.ContainsKey((int)enumGoodsType))
                {
                    continue;
                }
                goodsTypeToNameDic.Add((int)enumGoodsType, explanName);
            }
        }
    }
Example #4
0
        /// <summary>
        /// 设置TreeView的基础节点
        /// </summary>
        private void InitTreeView()
        {
            TreeView_Main.Nodes.Clear();
            //顶层节点,表示是炼金还是打造
            Type synthesisTypeType = typeof(EnumSynthesisType);

            foreach (FieldInfo synthesisTypeFieldInfo in synthesisTypeType.GetFields())
            {
                if (synthesisTypeFieldInfo.Name.Equals("value__"))
                {
                    continue;
                }
                TreeNode             synthesisTypeNode         = new TreeNode(synthesisTypeFieldInfo.Name);
                FieldExplanAttribute fieldExplanAttribute_Type = synthesisTypeFieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).Select(temp => temp as FieldExplanAttribute).FirstOrDefault();
                if (fieldExplanAttribute_Type != null)
                {
                    synthesisTypeNode.Text = fieldExplanAttribute_Type.GetExplan();
                }
                synthesisTypeNode.Tag  = synthesisTypeFieldInfo.Name;
                synthesisTypeNode.Name = synthesisTypeFieldInfo.Name;
                TreeView_Main.Nodes.Add(synthesisTypeNode);

                //添加子层节点,具体条目,和熟练度相关的类型
                Type synthesisItemType = typeof(EnumSynthesisItem);
                foreach (FieldInfo synthesisItemFieldInfo in synthesisItemType.GetFields())
                {
                    if (synthesisItemFieldInfo.Name.Equals("value__"))
                    {
                        continue;
                    }
                    TreeNode             synthesisItemNode         = new TreeNode(synthesisItemFieldInfo.Name);
                    FieldExplanAttribute fieldExplanAttribute_Item = synthesisItemFieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).Select(temp => temp as FieldExplanAttribute).FirstOrDefault();
                    if (fieldExplanAttribute_Item != null)
                    {
                        synthesisItemNode.Text = fieldExplanAttribute_Item.GetExplan();
                    }
                    synthesisItemNode.Tag  = synthesisItemFieldInfo.Name;
                    synthesisItemNode.Name = synthesisItemFieldInfo.Name;
                    synthesisTypeNode.Nodes.Add(synthesisItemNode);
                }
            }
        }
Example #5
0
    private void OnGUI()
    {
        if (Target == null)
        {
            EditorGUILayout.LabelField("该编辑器是辅助编辑,请通过其他编辑器打开");
            return;
        }
        scrolls = EditorGUILayout.BeginScrollView(scrolls);
        Type attributeType = typeof(IAttributeState);

        PropertyInfo[] propertyInfos = attributeType.GetProperties();
        foreach (PropertyInfo propertyInfo in propertyInfos)
        {
            if (!Type.Equals(propertyInfo.PropertyType, typeof(float)))
            {
                continue;
            }
            FieldExplanAttribute fieldExplanAttribute = propertyInfo.GetCustomAttributes(typeof(FieldExplanAttribute), true).OfType <FieldExplanAttribute>().FirstOrDefault();
            if (fieldExplanAttribute == null)
            {
                continue;
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(fieldExplanAttribute.GetExplan());
            MethodInfo getMethod = propertyInfo.GetGetMethod();
            float      value     = 0;
            if (getMethod != null)
            {
                value = (float)getMethod.Invoke(Target, null);
            }
            value = EditorGUILayout.FloatField(value);
            MethodInfo setMethod = propertyInfo.GetSetMethod();
            if (setMethod != null)
            {
                setMethod.Invoke(Target, new object[] { value });
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();
    }
Example #6
0
    /// <summary>
    /// 设置枚举说明到键值对集合中
    /// </summary>
    /// <typeparam name="T">类型</typeparam>
    /// <param name="targetList">要添加的键值对字典集合</param>
    /// <param name="selectIndex">选择下标</param>
    /// <param name="CallBackCheck">选择回调</param>
    public static void SetEnumExplanDic <T>(List <KeyValuePair <T, string> > targetList, int selectIndex = 0, Func <T, bool> CallBackCheck = null)
    {
        Type EnumType = typeof(T);

        if (EnumType.IsEnum)
        {
            IEnumerable <T> enumTaskTypes = Enum.GetValues(typeof(T)).OfType <T>();
            foreach (T enumTarget in enumTaskTypes)
            {
                FieldInfo fieldInfo = EnumType.GetField(enumTarget.ToString());
                if (fieldInfo != null)
                {
                    FieldExplanAttribute fieldExplan = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().FirstOrDefault();
                    if (fieldExplan != null)
                    {
                        if (CallBackCheck == null || CallBackCheck(enumTarget))
                        {
                            targetList.Add(new KeyValuePair <T, string>(enumTarget, fieldExplan.GetExplan(selectIndex)));
                        }
                    }
                }
            }
        }
    }
Example #7
0
    private void Awake()
    {
        //重置路径
        dataDirectoryPath = Application.dataPath + @"\Scripts\Data\Resources\Data\Monster";

        if (!Directory.Exists(dataDirectoryPath))
        {
            Directory.CreateDirectory(dataDirectoryPath);
        }
        if (!File.Exists(dataDirectoryPath + "/Monster.txt"))
        {
            File.Create(dataDirectoryPath + "/Monster.txt").Close();
            monsterDataInfoCollections = new MonsterDataInfoCollection[0];
            string valueText = SerializeNow(monsterDataInfoCollections);
            File.WriteAllText(dataDirectoryPath + "/Monster.txt", valueText, Encoding.UTF8);
        }
        else
        {
            string valueText = File.ReadAllText(dataDirectoryPath + "/Monster.txt", Encoding.UTF8);
            monsterDataInfoCollections = DeSerializeNow <MonsterDataInfoCollection[]>(valueText);
            if (monsterDataInfoCollections == null)
            {
                monsterDataInfoCollections = new MonsterDataInfoCollection[0];
            }
        }
        //加载预设提
        monsterPrefabDic = new Dictionary <string, GameObject>();
        GameObject[] allPrefabs = Resources.LoadAll <GameObject>(MonsterDataInfo.monsterPrefabDirectoryPath);
        foreach (GameObject prefab in allPrefabs)
        {
            monsterPrefabDic.Add(prefab.name, prefab);
        }
        //怪物类型名字典
        monsterTypeToFieldNameDic = new Dictionary <EnumMonsterType, string>();
        Type monsterTypeType = typeof(EnumMonsterType);

        EnumMonsterType[] monsterTypeArray = Enum.GetValues(typeof(EnumMonsterType)).OfType <EnumMonsterType>().ToArray();
        foreach (EnumMonsterType monsterType in monsterTypeArray)
        {
            FieldInfo fieldInfo = monsterTypeType.GetField(monsterType.ToString());
            if (fieldInfo == null)
            {
                continue;
            }
            FieldExplanAttribute fieldExplanAttribute = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().FirstOrDefault();
            if (fieldExplanAttribute == null)
            {
                continue;
            }
            monsterTypeToFieldNameDic.Add(monsterType, fieldExplanAttribute.GetExplan());
        }
        //物品类型名字典
        goodsTypeToFieldNameDic = new Dictionary <EnumGoodsType, string>();
        Type goodsTypeType = typeof(EnumGoodsType);

        EnumGoodsType[] goodsTypeArray = Enum.GetValues(typeof(EnumGoodsType)).OfType <EnumGoodsType>().ToArray();
        foreach (EnumGoodsType goodsType in goodsTypeArray)
        {
            int goodsTypeID = (int)goodsType;
            int temp1       = goodsTypeID % 1000;
            if (temp1 == 0)
            {
                continue;
            }
            FieldInfo fieldInfo = goodsTypeType.GetField(goodsType.ToString());
            if (fieldInfo == null)
            {
                continue;
            }
            FieldExplanAttribute fieldExplanAttribute = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().FirstOrDefault();
            if (fieldExplanAttribute == null)
            {
                continue;
            }
            goodsTypeToFieldNameDic.Add(goodsType, fieldExplanAttribute.GetExplan());
        }
        //怪物ai类型名字典
        monsterAITypeToFieldNameDic = new Dictionary <EnumMonsterAIType, string>();
        Type monsterAITypeType = typeof(EnumMonsterAIType);

        EnumMonsterAIType[] monsterAITypeArray = Enum.GetValues(typeof(EnumMonsterAIType)).OfType <EnumMonsterAIType>().ToArray();
        foreach (EnumMonsterAIType monsterAIType in monsterAITypeArray)
        {
            FieldInfo fieldInfo = monsterAITypeType.GetField(monsterAIType.ToString());
            if (fieldInfo == null)
            {
                continue;
            }
            FieldExplanAttribute fieldExplanAttribute = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().FirstOrDefault();
            if (fieldExplanAttribute == null)
            {
                continue;
            }
            monsterAITypeToFieldNameDic.Add(monsterAIType, fieldExplanAttribute.GetExplan());
        }

        //表示范围的游戏对象
        rangeObj = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
        Shader   shader   = Shader.Find("Legacy Shaders/Transparent/Diffuse");
        Material material = new Material(shader);

        material.SetColor("_Color", new Color(1, 0, 0, 0.35f));
        rangeObj.GetComponent <MeshRenderer>().material = material;
        rangeObj.name = "中心以及区域";

        roleOfRaceToFieldNameDic = new List <KeyValuePair <RoleOfRace, string> >();
        FieldExplanAttribute.SetEnumExplanDic(roleOfRaceToFieldNameDic, 0);
        taskProgressToFieldNameDic = new List <KeyValuePair <TaskMap.Enums.EnumTaskProgress, string> >();
        FieldExplanAttribute.SetEnumExplanDic(taskProgressToFieldNameDic);
    }
Example #8
0
    void OnGUI()
    {
        if (monsterDataInfoCollections == null || monsterTypeToFieldNameDic == null || monsterAITypeToFieldNameDic == null)
        {
            return;
        }
        //获取当前场景对象
        MonsterDataInfoCollection monsterDataInfoCollection = monsterDataInfoCollections.FirstOrDefault(temp => string.Equals(temp.sceneName, selectScene));

        EditorGUILayout.BeginHorizontal();
        #region 保存 场景 等按钮
        EditorGUILayout.BeginVertical(GUILayout.Width(200));
        if (GUILayout.Button("保存", GUILayout.Width(100)))
        {
            string valueText = SerializeNow(monsterDataInfoCollections);
            File.WriteAllText(dataDirectoryPath + "/Monster.txt", valueText, Encoding.UTF8);
            EditorUtility.DisplayDialog("提示!", "保存成功", "确认");
        }
        if (monsterDataInfoCollection == null && GUILayout.Button("添加本场景", GUILayout.Width(100)))
        {
            monsterDataInfoCollection = new MonsterDataInfoCollection()
            {
                sceneName = selectScene
            };
            MonsterDataInfoCollection[] tempArray = new MonsterDataInfoCollection[monsterDataInfoCollections.Length + 1];
            Array.Copy(monsterDataInfoCollections, tempArray, monsterDataInfoCollections.Length);
            tempArray[tempArray.Length - 1] = monsterDataInfoCollection;
            monsterDataInfoCollections      = tempArray;
        }
        saveSceneScrollPostion = EditorGUILayout.BeginScrollView(saveSceneScrollPostion);
        #region  显示所有的场景按钮
        bool changedScene = false;
        List <MonsterDataInfoCollection> monsterDataInfoCollectionList = new List <MonsterDataInfoCollection>(monsterDataInfoCollections);
        for (int i = 0; i < monsterDataInfoCollections.Length; i++)
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("删除", GUILayout.Width(35)))
            {
                if (EditorUtility.DisplayDialog("警告!", "请再次确认是否删除该场景的怪物配置信息?", "确认删除", "取消删除"))
                {
                    monsterDataInfoCollectionList.Remove(monsterDataInfoCollections[i]);
                    changedScene = true;
                }
            }
            if (monsterDataInfoCollections[i] == monsterDataInfoCollection)
            {
                EditorGUILayout.Toggle(true, GUILayout.Width(20));
            }
            GUILayout.Button(monsterDataInfoCollections[i].sceneName);
            EditorGUILayout.EndHorizontal();
        }
        if (changedScene)
        {
            monsterDataInfoCollections = monsterDataInfoCollectionList.ToArray();
            if (!monsterDataInfoCollectionList.Contains(monsterDataInfoCollection))
            {
                monsterDataInfoCollection = null;
                selectMonsterID           = -1;
            }
        }
        #endregion
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
        #endregion
        #region  择删除添加怪物id
        EditorGUILayout.BeginVertical(GUILayout.Width(175));
        if (monsterDataInfoCollection != null)
        {
            if (GUILayout.Button("添加新策略", GUILayout.Width(75)))
            {
                int id = 0;
                if (monsterDataInfoCollection.MonsterDataInofs.Count > 0)
                {
                    id = monsterDataInfoCollection.MonsterDataInofs.Max(temp => temp.ID) + 1;
                }
                monsterDataInfoCollection.MonsterDataInofs.Add(new MonsterDataInfo()
                {
                    ID = id, Briefly = "空"
                });
            }
            monsterIDScrollPostion = EditorGUILayout.BeginScrollView(monsterIDScrollPostion, GUILayout.Width(170));
            List <MonsterDataInfo> tempMonsterDataInfos = new List <MonsterDataInfo>(monsterDataInfoCollection.MonsterDataInofs);
            foreach (MonsterDataInfo monsterDataInfo in tempMonsterDataInfos)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("删除", GUILayout.Width(35)))
                {
                    if (EditorUtility.DisplayDialog("警告!", "请再次确认是否删除怪物配置信息?", "确认删除", "取消删除"))
                    {
                        monsterDataInfoCollection.MonsterDataInofs.Remove(monsterDataInfo);
                    }
                }
                if (monsterDataInfo.ID == selectMonsterID)
                {
                    EditorGUILayout.Toggle(true, GUILayout.Width(20));
                }
                if (GUILayout.Button(monsterDataInfo.Briefly))
                {
                    selectMonsterID = monsterDataInfo.ID;
                    //在这里重新赋值区域位置
                    if (rangeObj != null)
                    {
                        rangeObj.transform.position   = monsterDataInfo.Center;
                        rangeObj.transform.localScale = new Vector3(monsterDataInfo.Range * 2, monsterDataInfo.Range * 2, monsterDataInfo.Range * 2);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndScrollView();
        }
        EditorGUILayout.EndVertical();
        #endregion
        //集合不等于0 选择的id大于等于0 并且存在该id
        if (monsterDataInfoCollection != null && selectMonsterID >= 0 && monsterDataInfoCollection.MonsterDataInofs.Count(temp => temp.ID == selectMonsterID) > 0)
        {
            MonsterDataInfo monsterDataInfo = monsterDataInfoCollection.MonsterDataInofs.FirstOrDefault(temp => temp.ID == selectMonsterID);
            #region 怪物的基本信息
            EditorGUILayout.BeginVertical(GUILayout.Width(350));
            baseDataScrollPostion   = EditorGUILayout.BeginScrollView(baseDataScrollPostion);
            monsterDataInfo.Briefly = EditorGUILayout.TextField("配置:", monsterDataInfo.Briefly);
            monsterDataInfo.Explane = EditorGUILayout.TextField("说明:", monsterDataInfo.Explane, GUILayout.Width(300), GUILayout.Height(150));
            string[] monsterTypeExplans = monsterTypeToFieldNameDic.Values.ToArray();
            int[]    monsterTypeValues  = monsterTypeToFieldNameDic.Keys.Select(temp => (int)temp).ToArray();
            int      monsterTypeValue   = EditorGUILayout.IntPopup("怪物类型:", (int)monsterDataInfo.MonsterType, monsterTypeExplans, monsterTypeValues);
            monsterDataInfo.MonsterType = (EnumMonsterType)monsterTypeValue;
            if (rangeObj != null)
            {
                rangeObj.transform.forward = Vector3.forward;
                monsterDataInfo.Center     = rangeObj.transform.position;
                Vector3 scale    = rangeObj.transform.localScale;
                float   minRange = scale.x;
                minRange = scale.y < minRange ? scale.y : minRange;
                minRange = scale.z < minRange ? scale.z : minRange;
                monsterDataInfo.Range = minRange / 2;
            }
            monsterDataInfo.Center = EditorGUILayout.Vector3Field("区域中心:", monsterDataInfo.Center);
            monsterDataInfo.Range  = EditorGUILayout.FloatField("区域范围:", monsterDataInfo.Range);
            if (rangeObj != null)
            {
                rangeObj.transform.position   = monsterDataInfo.Center;
                rangeObj.transform.localScale = new Vector3(monsterDataInfo.Range * 2, monsterDataInfo.Range * 2, monsterDataInfo.Range * 2);
            }
            monsterDataInfo.Offset     = EditorGUILayout.FloatField("高度偏差值:", monsterDataInfo.Offset);
            monsterDataInfo.Experience = EditorGUILayout.IntField("经验值:", monsterDataInfo.Experience);
            GameObject monsterPrefab = EditorGUILayout.ObjectField("怪物预设体:", monsterDataInfo.MonsterPrefab, typeof(GameObject), false) as GameObject;
            if (monsterPrefab == null)
            {
                monsterDataInfo.monsterPrefabName = "";
            }
            else if (!string.Equals(monsterPrefab.name, monsterDataInfo.monsterPrefabName))
            {
                string monsterPrefabName = monsterPrefab.name;
                if (monsterPrefabDic.ContainsKey(monsterPrefabName))
                {
                    monsterDataInfo.monsterPrefabName = monsterPrefabName;
                }
            }
            //设置属性
            EditorGUILayout.BeginHorizontal();
            if (monsterDataInfo.MonsterBaseAttribute == null)
            {
                monsterDataInfo.MonsterBaseAttribute = new AttributeStateAdditional();
            }
            if (GUILayout.Button("设置属性"))
            {
                AttributeStateAdditionalEditor attributeStateAdditionalEditor = EditorWindow.GetWindow <AttributeStateAdditionalEditor>();
                attributeStateAdditionalEditor.Show();
                attributeStateAdditionalEditor.Target = monsterDataInfo.MonsterBaseAttribute;
            }
            if (GUILayout.Button("复制", GUILayout.Width(35)))
            {
                AttributeStateAdditional_Copy = monsterDataInfo.MonsterBaseAttribute.Clone();
            }
            if (AttributeStateAdditional_Copy != null && GUILayout.Button("粘贴", GUILayout.Width(35)) && EditorUtility.DisplayDialog("请再次确认!", "是否覆盖当前数据?", "是", "否"))
            {
                monsterDataInfo.MonsterBaseAttribute = AttributeStateAdditional_Copy.Clone();
            }
            EditorGUILayout.EndHorizontal();
            //设置种族
            List <RoleOfRace> roleOfRaceValues  = roleOfRaceToFieldNameDic.Select(temp => temp.Key).ToList();
            string[]          roleOfRaceExplans = roleOfRaceToFieldNameDic.Select(temp => temp.Value).ToArray();
            int roleOfRaceIndex = roleOfRaceValues.IndexOf(monsterDataInfo.roleOfRace);
            roleOfRaceIndex = EditorGUILayout.Popup("种族:", roleOfRaceIndex, roleOfRaceExplans);
            if (roleOfRaceIndex > -1)
            {
                monsterDataInfo.roleOfRace = roleOfRaceValues[roleOfRaceIndex];
            }
            //设置显示和隐藏条件
            List <TaskMap.Enums.EnumTaskProgress> taskProgressValues = taskProgressToFieldNameDic.Select(temp => temp.Key).ToList();
            string[] taskProgressExplans = taskProgressToFieldNameDic.Select(temp => temp.Value).ToArray();
            Action <List <KeyValuePair <int, TaskMap.Enums.EnumTaskProgress> > > ShowHideTaskAction = (targetList) =>
            {
                for (int i = 0; i < targetList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("×", GUILayout.Width(20)) && EditorUtility.DisplayDialog("请再次确认!", "是否删除该条件?", "确认删除", "取消"))
                    {
                        targetList.RemoveAt(i);
                        EditorGUILayout.EndHorizontal();
                        break;
                    }
                    KeyValuePair <int, TaskMap.Enums.EnumTaskProgress> tempValue = targetList[i];
                    EditorGUILayout.LabelField("任务ID:", GUILayout.Width(40));
                    int tempKey = EditorGUILayout.IntField(tempValue.Key, GUILayout.Width(30));
                    EditorGUILayout.LabelField("任务状态:", GUILayout.Width(50));
                    int index = taskProgressValues.IndexOf(tempValue.Value);
                    index = EditorGUILayout.Popup(index, taskProgressExplans, GUILayout.Width(50));
                    TaskMap.Enums.EnumTaskProgress tempTaskProgress = tempValue.Value;
                    if (index >= 0)
                    {
                        tempTaskProgress = taskProgressValues[index];
                    }
                    targetList[i] = new KeyValuePair <int, TaskMap.Enums.EnumTaskProgress>(tempKey, tempTaskProgress);
                    EditorGUILayout.EndHorizontal();
                }
            };
            //显示条件
            if (monsterDataInfo.TaskToShowList == null)
            {
                monsterDataInfo.TaskToShowList = new List <KeyValuePair <int, TaskMap.Enums.EnumTaskProgress> >();
            }
            if (GUILayout.Button("添加显示条件"))
            {
                monsterDataInfo.TaskToShowList.Add(new KeyValuePair <int, TaskMap.Enums.EnumTaskProgress>());
            }
            ShowHideTaskAction(monsterDataInfo.TaskToShowList);
            //隐藏条件
            if (monsterDataInfo.TaskToHideList == null)
            {
                monsterDataInfo.TaskToHideList = new List <KeyValuePair <int, TaskMap.Enums.EnumTaskProgress> >();
            }
            if (GUILayout.Button("添加隐藏条件"))
            {
                monsterDataInfo.TaskToHideList.Add(new KeyValuePair <int, TaskMap.Enums.EnumTaskProgress>());
            }
            ShowHideTaskAction(monsterDataInfo.TaskToHideList);
            //物品掉落
            if (monsterDataInfo.ItemDropRates == null)
            {
                monsterDataInfo.ItemDropRates = new float[0];
            }
            if (monsterDataInfo.ItemDropTypes == null)
            {
                monsterDataInfo.ItemDropTypes = new EnumGoodsType[0];
            }
            int dropCount    = monsterDataInfo.ItemDropRates.Length > monsterDataInfo.ItemDropTypes.Length ? monsterDataInfo.ItemDropTypes.Length : monsterDataInfo.ItemDropRates.Length;
            int nowDropCount = EditorGUILayout.IntField("掉落物品种类数量(类型->概率):", dropCount);
            if (dropCount != nowDropCount)
            {
                monsterDataInfo.ItemDropRates = ChangedArrayLength(monsterDataInfo.ItemDropRates, nowDropCount);
                monsterDataInfo.ItemDropTypes = ChangedArrayLength(monsterDataInfo.ItemDropTypes, nowDropCount);
            }
            string[] goodsTypeExplans = goodsTypeToFieldNameDic.Values.ToArray();
            int[]    goodsTypeValues  = goodsTypeToFieldNameDic.Keys.Select(temp => (int)temp).ToArray();
            for (int i = 0; i < nowDropCount; i++)
            {
                EditorGUILayout.BeginHorizontal();
                int goodsTypeValue = EditorGUILayout.IntPopup("物品类型", (int)monsterDataInfo.ItemDropTypes[i], goodsTypeExplans, goodsTypeValues);
                monsterDataInfo.ItemDropTypes[i] = (EnumGoodsType)goodsTypeValue;
                float rate = EditorGUILayout.FloatField(monsterDataInfo.ItemDropRates[i]);
                rate = Mathf.Clamp(rate, 0, 1);
                monsterDataInfo.ItemDropRates[i] = rate;
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            #endregion
            #region 怪物的AI信息
            EditorGUILayout.BeginVertical(GUILayout.Width(350));
            string[] monsterAITypeExplans = monsterAITypeToFieldNameDic.Values.ToArray();
            int[]    monsterAITypeValues  = monsterAITypeToFieldNameDic.Keys.Select(temp => (int)temp).ToArray();
            int      monsterAITypeValue   = EditorGUILayout.IntPopup("怪物AI类型:", (int)monsterDataInfo.AIType, monsterAITypeExplans, monsterAITypeValues);
            if ((int)monsterDataInfo.AIType != monsterAITypeValue || monsterDataInfo.AIData == null)
            {
                monsterDataInfo.AIType = (EnumMonsterAIType)monsterAITypeValue;
                MonsterAIDataStruct monsterAIDataStruct = monsterDataInfo.AIData;
                try
                {
                    monsterDataInfo.AIData = (MonsterAIDataStruct)Activator.CreateInstance(typeof(MonsterAIDataStruct).Assembly.GetType("MonsterAIData_" + monsterDataInfo.AIType.ToString()));
                }
                catch { }
                if (monsterAIDataStruct != null && monsterDataInfo.AIData != null)
                {
                    monsterDataInfo.AIData.FollowDistance = monsterAIDataStruct.FollowDistance;
                    monsterDataInfo.AIData.UpdateTime     = monsterAIDataStruct.UpdateTime;
                }
            }
            aiDataScrollPostion = EditorGUILayout.BeginScrollView(aiDataScrollPostion);
            if (monsterDataInfo.AIData != null)
            {
                monsterDataInfo.AIData.UpdateTime     = EditorGUILayout.FloatField("怪物刷新时间:", monsterDataInfo.AIData.UpdateTime);
                monsterDataInfo.AIData.FollowDistance = EditorGUILayout.FloatField("跟随的最远距离:", monsterDataInfo.AIData.FollowDistance);
                //反射出不同类型的数据
                Type        thisAIDataType = typeof(MonsterAIDataStruct).Assembly.GetType("MonsterAIData_" + monsterDataInfo.AIType.ToString());
                FieldInfo[] fieldInfos     = thisAIDataType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
                foreach (FieldInfo fieldInfo in fieldInfos)
                {
                    FieldExplanAttribute fieldExplan = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().FirstOrDefault();
                    if (fieldExplan != null)
                    {
                        if (fieldInfo.FieldType.Equals(typeof(float)))
                        {
                            float value = EditorGUILayout.FloatField(fieldExplan.GetExplan(), (float)fieldInfo.GetValue(monsterDataInfo.AIData));
                            fieldInfo.SetValue(monsterDataInfo.AIData, value);
                        }
                        else if (fieldInfo.FieldType.Equals(typeof(int)))
                        {
                            int value = EditorGUILayout.IntField(fieldExplan.GetExplan(), (int)fieldInfo.GetValue(monsterDataInfo.AIData));
                            fieldInfo.SetValue(monsterDataInfo.AIData, value);
                        }
                        else if (fieldInfo.FieldType.Equals(typeof(bool)))
                        {
                            bool value = EditorGUILayout.Toggle(fieldExplan.GetExplan(), (bool)fieldInfo.GetValue(monsterDataInfo.AIData));
                            fieldInfo.SetValue(monsterDataInfo.AIData, value);
                        }
                        //还有其他的在后面添加.....
                    }
                }
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            #endregion
        }
        EditorGUILayout.EndHorizontal();
    }
    private void OnGUI()
    {
        if (skillTypeToParticalNameDic == null)
        {
            return;
        }
        EditorGUILayout.BeginHorizontal();
        //左侧的选择配置项按钮面板
        EditorGUILayout.BeginVertical(GUILayout.Width(250));
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("保存", GUILayout.Width(35)))
        {
            string valueText = SerializeNow(skillTypeToParticalNameDic);
            File.WriteAllText(dataDirecotryPath + "/CombinePartical.txt", valueText, Encoding.UTF8);
            EditorUtility.DisplayDialog("保存数据", "保存成功!", "确认");
        }
        GUILayout.Space(100);
        if (GUILayout.Button("增量加载资源", GUILayout.Width(100)))
        {
            ParticalManager.IncrementalLoad();
        }
        EditorGUILayout.EndHorizontal();
        if (GUILayout.Button("添加", GUILayout.Width(35)))
        {
            if (!skillTypeToParticalNameDic.ContainsKey(-1))
            {
                skillTypeToParticalNameDic.Add(-1, "None");
            }
            else
            {
                EditorUtility.DisplayDialog("提示", "请先编辑之前添加的数据!", "确认");
            }
        }
        leftScroll = EditorGUILayout.BeginScrollView(leftScroll);
        KeyValuePair <int, string>[] tempValues = skillTypeToParticalNameDic.ToArray();
        Type enumType = typeof(EnumSkillType);

        foreach (KeyValuePair <int, string> tempValue in tempValues)
        {
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("×", GUILayout.Width(15)))
            {
                if (EditorUtility.DisplayDialog("警告!", "将会减去该数据!", "确认", "取消"))
                {
                    skillTypeToParticalNameDic.Remove(tempValue.Key);
                }
            }
            if (object.Equals(tempValue.Key, selectKey))
            {
                GUILayout.Space(30);
            }
            string[]        showNames     = new string[0];
            EnumSkillType[] thisSkillTyps = SkillCombineStaticTools.GetCombineSkills(tempValue.Key);
            if (thisSkillTyps != null)
            {
                showNames = thisSkillTyps.Select <EnumSkillType, string>(temp =>
                {
                    FieldInfo fieldInfo = enumType.GetField(temp.ToString());
                    if (fieldInfo == null)
                    {
                        return("");
                    }
                    FieldExplanAttribute fieldExplanAttribute = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).Select(innerTemp => innerTemp as FieldExplanAttribute).Where(innerTemp => innerTemp != null).FirstOrDefault();
                    if (fieldExplanAttribute == null)
                    {
                        return("");
                    }
                    return(fieldExplanAttribute.GetExplan());
                }).Where(temp => !string.IsNullOrEmpty(temp)).ToArray();
            }
            string showName = showNames.Length > 0 ? string.Join("+", showNames) : "None";
            if (GUILayout.Button(showName))
            {
                if (object.Equals(tempValue.Key, selectKey))
                {
                    selectKey = 0;
                }
                else
                {
                    selectKey          = tempValue.Key;
                    nowSelectSkillTyps = thisSkillTyps;
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();

        //第一个技能
        EditorGUILayout.BeginVertical();
        if (nowSelectSkillTyps == null || nowSelectSkillTyps.Length < 1)
        {
            nowSelectSkillTyps = new EnumSkillType[] { EnumSkillType.None }
        }
        ;
        var enumSkillTypes_First = allSkillTypes.Select(temp =>
        {
            FieldInfo fieldInfo = enumType.GetField(temp.ToString());
            if (fieldInfo == null)
            {
                return new { type = temp, str = "" }
            }
            ;
            FieldExplanAttribute fieldExplanAttriubte = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().Where(innerTemp => innerTemp != null).FirstOrDefault();
            if (fieldExplanAttriubte == null)
            {
                return new { type = temp, str = "" }
            }
            ;
            return(new { type = temp, str = fieldExplanAttriubte.GetExplan() });
        }).Where(temp => !string.IsNullOrEmpty(temp.str)).Where(temp => temp.type < EnumSkillType.MagicCombinedLevel1End).Reverse();
        int index_First    = enumSkillTypes_First.Select(temp => temp.type).ToList().IndexOf(nowSelectSkillTyps[0]);
        int nowIndex_First = EditorGUILayout.Popup(index_First, enumSkillTypes_First.Select(temp => temp.str).ToArray());

        if (nowIndex_First > -1 && nowIndex_First < enumSkillTypes_First.Count())
        {
            EnumSkillType selectEnumSkillType = enumSkillTypes_First.ToArray()[nowIndex_First].type;
            nowSelectSkillTyps[0] = selectEnumSkillType;
        }
        if (nowSelectSkillTyps[0] < EnumSkillType.MagicCombinedLevel1Start)
        {
            EnumSkillType[] tempArray = nowSelectSkillTyps;
            nowSelectSkillTyps = new EnumSkillType[1];
            Array.Copy(tempArray, nowSelectSkillTyps, 1);
        }
        //第二个技能
        if (nowSelectSkillTyps.Length > 0 && nowSelectSkillTyps[0] > EnumSkillType.MagicCombinedLevel1Start)
        {
            if (nowSelectSkillTyps.Length < 2)
            {
                EnumSkillType[] tempArray = nowSelectSkillTyps;
                nowSelectSkillTyps = new EnumSkillType[2];
                Array.Copy(tempArray, nowSelectSkillTyps, 1);
            }
            var enumSkillTypes_Second = allSkillTypes.Select(temp =>
            {
                FieldInfo fieldInfo = enumType.GetField(temp.ToString());

                if (fieldInfo == null)
                {
                    return new { type = temp, str = "" }
                }
                ;
                FieldExplanAttribute fieldExplanAttriubte = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().Where(innerTemp => innerTemp != null).FirstOrDefault();
                if (fieldExplanAttriubte == null)
                {
                    return new { type = temp, str = "" }
                }
                ;
                return(new { type = temp, str = fieldExplanAttriubte.GetExplan() });
            }).Where(temp => !string.IsNullOrEmpty(temp.str)).Where(temp => temp.type <EnumSkillType.MagicCombinedLevel2End && temp.type> EnumSkillType.MagicCombinedLevel2Start);
            int index_Second    = enumSkillTypes_Second.Select(temp => temp.type).ToList().IndexOf(nowSelectSkillTyps[1]);
            int nowIndex_Second = EditorGUILayout.Popup(index_Second, enumSkillTypes_Second.Select(temp => temp.str).ToArray());
            if (nowIndex_Second > -1 && nowIndex_Second < enumSkillTypes_Second.Count())
            {
                EnumSkillType selectEnumSkillType = enumSkillTypes_Second.ToArray()[nowIndex_Second].type;
                nowSelectSkillTyps[1] = selectEnumSkillType;
            }
        }
        //第三个技能
        if (nowSelectSkillTyps.Length > 1 && nowSelectSkillTyps[1] > EnumSkillType.MagicCombinedLevel2Start)
        {
            if (nowSelectSkillTyps.Length < 3)
            {
                EnumSkillType[] tempArray = nowSelectSkillTyps;
                nowSelectSkillTyps = new EnumSkillType[3];
                Array.Copy(tempArray, nowSelectSkillTyps, 2);
            }
            var enumSkillTypes_Third = allSkillTypes.Select(temp =>
            {
                FieldInfo fieldInfo = enumType.GetField(temp.ToString());
                if (fieldInfo == null)
                {
                    return new { type = temp, str = "" }
                }
                ;
                FieldExplanAttribute fieldExplanAttriubte = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().Where(innerTemp => innerTemp != null).FirstOrDefault();
                if (fieldExplanAttriubte == null)
                {
                    return new { type = temp, str = "" }
                }
                ;
                return(new { type = temp, str = fieldExplanAttriubte.GetExplan() });
            }).Where(temp => !string.IsNullOrEmpty(temp.str)).Where(temp => temp.type <EnumSkillType.MagicCombinedLevel3End && temp.type> EnumSkillType.MagicCombinedLevel3Start);
            int index_Third    = enumSkillTypes_Third.Select(temp => temp.type).ToList().IndexOf(nowSelectSkillTyps[2]);
            int nowIndex_Third = EditorGUILayout.Popup(index_Third, enumSkillTypes_Third.Select(temp => temp.str).ToArray());
            if (nowIndex_Third > -1 && nowIndex_Third < enumSkillTypes_Third.Count())
            {
                EnumSkillType selectEnumSkillType = enumSkillTypes_Third.ToArray()[nowIndex_Third].type;
                nowSelectSkillTyps[2] = selectEnumSkillType;
            }
        }
        //第四个技能
        if (nowSelectSkillTyps.Length > 2 && nowSelectSkillTyps[2] > EnumSkillType.MagicCombinedLevel3Start)
        {
            if (nowSelectSkillTyps.Length < 4)
            {
                EnumSkillType[] tempArray = nowSelectSkillTyps;
                nowSelectSkillTyps = new EnumSkillType[4];
                Array.Copy(tempArray, nowSelectSkillTyps, 3);
            }
            var enumSkillTypes_Fourth = allSkillTypes.Select(temp =>
            {
                FieldInfo fieldInfo = enumType.GetField(temp.ToString());
                if (fieldInfo == null)
                {
                    return new { type = temp, str = "" }
                }
                ;
                FieldExplanAttribute fieldExplanAttriubte = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().Where(innerTemp => innerTemp != null).FirstOrDefault();
                if (fieldExplanAttriubte == null)
                {
                    return new { type = temp, str = "" }
                }
                ;
                return(new { type = temp, str = fieldExplanAttriubte.GetExplan() });
            }).Where(temp => !string.IsNullOrEmpty(temp.str)).Where(temp => temp.type <EnumSkillType.MagicCombinedLevel4End && temp.type> EnumSkillType.MagicCombinedLevel4Start);
            int index_Fourth    = enumSkillTypes_Fourth.Select(temp => temp.type).ToList().IndexOf(nowSelectSkillTyps[3]);
            int nowIndex_Fourth = EditorGUILayout.Popup(index_Fourth, enumSkillTypes_Fourth.Select(temp => temp.str).ToArray());
            if (nowIndex_Fourth > -1 && nowIndex_Fourth < enumSkillTypes_Fourth.Count())
            {
                EnumSkillType selectEnumSkillType = enumSkillTypes_Fourth.ToArray()[nowIndex_Fourth].type;
                nowSelectSkillTyps[3] = selectEnumSkillType;
            }
        }
        //技能粒子对象
        if (skillTypeToParticalNameDic.ContainsKey(selectKey))
        {
            GameObject particalObj = (GameObject)EditorGUILayout.ObjectField(ParticalManager.GetPartical(skillTypeToParticalNameDic[selectKey]), typeof(GameObject), true);
            skillTypeToParticalNameDic[selectKey] = ParticalManager.GetName(particalObj);
        }
        if (GUILayout.Button("保存", GUILayout.Width(35)))
        {
            int key = SkillCombineStaticTools.GetCombineSkillKey(nowSelectSkillTyps);
            if (key == 0 || (key != selectKey && skillTypeToParticalNameDic.ContainsKey(key)))
            {
                EditorUtility.DisplayDialog("提示", "无法保存该数据!", "确认");
            }
            else
            {
                string particalName = "";
                if (skillTypeToParticalNameDic.ContainsKey(selectKey))
                {
                    particalName = skillTypeToParticalNameDic[selectKey];
                    skillTypeToParticalNameDic.Remove(selectKey);
                }
                skillTypeToParticalNameDic.Add(key, particalName);
                selectKey = key;
            }
        }

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
    }
}
    /// <summary>
    /// 从文件读取技能结构数据
    /// </summary>
    /// <param name="must">是否必须读取</param>
    public void ReadSkillStructData(bool must = false)
    {
        if (skillBaseStructs == null || must)
        {
            TextAsset skillPathTextAsset = Resources.Load <TextAsset>("Data/Skill/Skills");
            if (skillPathTextAsset == null)
            {
                skillBaseStructs = new SkillBaseStruct[0];
            }
            else
            {
                //获取其他类型的宏定义
                Type        edfineType  = typeof(SkillStructConstString);
                FieldInfo[] edfineInfos = edfineType.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
                Dictionary <string, string> edfineNameToValueDic = edfineInfos.ToDictionary(
                    temp => temp.Name,
                    temp => (string)temp.GetValue(null));
                string[] otherSplit = new string[] { "***" };//截取其他数据时所用的分隔符

                string[] splits     = new string[] { "^^^" };
                string[] skillPaths = skillPathTextAsset.text.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries)
                                      .Select(temp => temp.Split(splits, StringSplitOptions.RemoveEmptyEntries))
                                      .Where(temp => temp != null && temp.Length == 3)
                                      .Select(temp => temp[2]).ToArray();
                string[] skillValues = skillPaths
                                       .Select(temp => Resources.Load <TextAsset>("Data/Skill/" + temp))
                                       .Where(temp => temp != null)
                                       .Select(temp => temp.text)
                                       .ToArray();
                skillAnalysisData.AnalysisData(skillValues);
                string[] ids = skillAnalysisData.GetIDArray();
                skillBaseStructs = new SkillBaseStruct[ids.Length];
                for (int i = 0; i < ids.Length; i++)
                {
                    string          id              = ids[i];
                    EnumSkillType   enumSkillType   = skillAnalysisData.GetEnum <EnumSkillType>(id, "skillType");
                    SkillBaseStruct skillBaseStruct = null;
                    Type            newType         = null;
                    //尝试使用该类型构造一个新的类
                    try
                    {
                        newType         = Type.GetType("SkillStruct_" + enumSkillType.ToString());
                        skillBaseStruct = Activator.CreateInstance(newType) as SkillBaseStruct;
                    }
                    catch { }
                    if (skillBaseStruct == null)
                    {
                        skillBaseStruct = new SkillBaseStruct();
                    }
                    //加载其他属性
                    if (newType != null)
                    {
                        FieldInfo[] otherFieldInfos = newType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
                        foreach (FieldInfo otherFieldInfo in otherFieldInfos)
                        {
                            string otherFieldName = otherFieldInfo.Name;
                            if (edfineNameToValueDic.ContainsKey(otherFieldName))
                            {
                                string otherFieldKey    = edfineNameToValueDic[otherFieldName];
                                int[]  otherFieldValues = skillAnalysisData.GetValues <int>(id, otherFieldKey);
                                if (otherFieldValues != null && otherFieldValues.Length > 0)
                                {
                                    otherFieldInfo.SetValue(skillBaseStruct, otherFieldValues[0]);
                                }
                            }
                        }
                    }
                    //加载常规属性
                    skillBaseStructs[i]        = skillBaseStruct;
                    skillBaseStruct.id         = id;
                    skillBaseStruct.name       = skillAnalysisData.GetValue <string>(id, "skillName");
                    skillBaseStruct.skillType  = enumSkillType;
                    skillBaseStruct.skillMode  = skillAnalysisData.GetEnum <EnumReleaseMode>(id, "releaseMode");
                    skillBaseStruct.skillZones = skillAnalysisData.GetEnums <EnumSkillZone>(id, "correlationZone").Where(temp => temp != EnumSkillZone.None).ToArray();
                    //加载技能图标
                    skillBaseStruct.skillSprite         = SkillSpriteData.GetSprite(skillBaseStruct.skillType);
                    skillBaseStruct.skillSprite_Combine = SkillSpriteData.GetSpriteCombine(skillBaseStruct.skillType);
                    //计算技能名(现在暂定使用元名字)
                    skillBaseStruct.skillName = skillBaseStruct.name;
                    //完成加载特殊效果
                    skillBaseStruct.skillBelief = skillAnalysisData.GetEnum <EnumSkillBelief>(id, "skillBelief");
                    string[] skillStatusEffectStrs = skillAnalysisData.GetValues <string>(id, "skillStatusEffect").Where(temp => !string.IsNullOrEmpty(temp)).ToArray();
                    skillBaseStruct.skillStatusEffect = new EnumStatusEffect[skillStatusEffectStrs.Length];
                    for (int j = 0; j < skillStatusEffectStrs.Length; j++)
                    {
                        skillBaseStruct.skillStatusEffect[j] = (EnumStatusEffect)Enum.Parse(typeof(EnumStatusEffect), skillStatusEffectStrs[j]);
                    }
                    //技能前置
                    skillBaseStruct.skillPrecondition = new SkillPrecondition();
                    skillBaseStruct.skillPrecondition.mustSkillZonePointDic = new Dictionary <EnumSkillZone, int>();
                    skillBaseStruct.skillPrecondition.mustSkillPointDic     = new Dictionary <EnumSkillType, int>();
                    EnumSkillZone[] preconditionSkillZones     = skillAnalysisData.GetEnums <EnumSkillZone>(id, "correlationBeforeZone"); //前置技能组数组
                    int[]           preconditionSkillZoneNums  = skillAnalysisData.GetValues <int>(id, "correlationBeforeZoneCount");     //前置技能组加点
                    int             preconditionSkillZoneCount = preconditionSkillZones.Length < preconditionSkillZoneNums.Length ? preconditionSkillZones.Length : preconditionSkillZoneNums.Length;
                    for (int j = 0; j < preconditionSkillZoneCount; j++)
                    {
                        if (preconditionSkillZones[j] != EnumSkillZone.None)
                        {
                            skillBaseStruct.skillPrecondition.mustSkillZonePointDic.Add(preconditionSkillZones[j], preconditionSkillZoneNums[j]);
                        }
                    }
                    EnumSkillType[] preconditionSkills     = skillAnalysisData.GetEnums <EnumSkillType>(id, "correlationBeforeSkill"); //前置技能数组
                    int[]           preconditionSkillNums  = skillAnalysisData.GetValues <int>(id, "correlationBeforeSkillCount");     //前置技能加点
                    int             preconditionSkillCount = preconditionSkillZones.Length < preconditionSkillNums.Length ? preconditionSkillZones.Length : preconditionSkillNums.Length;
                    for (int j = 0; j < preconditionSkillCount; j++)
                    {
                        if (preconditionSkills[j] != EnumSkillType.None)
                        {
                            skillBaseStruct.skillPrecondition.mustSkillPointDic.Add(preconditionSkills[j], preconditionSkillNums[j]);
                        }
                    }
                    //技能的技能等级以及属性
                    skillBaseStruct.maxLevel = skillAnalysisData.GetValue <int>(id, "skillLevel");
                    skillBaseStruct.skillAttributeStructs = new SkillAttributeStruct[skillBaseStruct.maxLevel];
                    Dictionary <string, Array> skillAttributeStructDic = new Dictionary <string, Array>();
                    Type        skillAttributeStructType       = typeof(SkillAttributeStruct);
                    FieldInfo[] skillAttributeStructFieldInfos = skillAttributeStructType.GetFields();
                    foreach (FieldInfo fieldInfo in skillAttributeStructFieldInfos)
                    {
                        FieldExplanAttribute fieldExplan = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().FirstOrDefault();
                        if (fieldExplan == null)
                        {
                            continue;
                        }
                        object[] skillAttributeStructValue = skillAnalysisData.GetValues(fieldInfo.FieldType, id, fieldExplan.GetExplan(1));//explan的第一个下标表示说明
                        if (skillAttributeStructValue.Length == skillBaseStruct.maxLevel)
                        {
                            skillAttributeStructDic.Add(fieldInfo.Name, skillAttributeStructValue);
                        }
                    }
                    for (int j = 0; j < skillBaseStruct.maxLevel; j++)
                    {
                        SkillAttributeStruct skillAttributeStruct = new SkillAttributeStruct();
                        foreach (FieldInfo fieldInfo in skillAttributeStructFieldInfos)
                        {
                            if (skillAttributeStructDic.ContainsKey(fieldInfo.Name))
                            {
                                if (skillAttributeStructDic[fieldInfo.Name].GetValue(j) == null)
                                {
                                    if (j > 0)
                                    {
                                        skillAttributeStructDic[fieldInfo.Name].SetValue(skillAttributeStructDic[fieldInfo.Name].GetValue(j - 1), j);
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                                fieldInfo.SetValue(skillAttributeStruct, skillAttributeStructDic[fieldInfo.Name].GetValue(j));
                            }
                        }
                        skillBaseStruct.skillAttributeStructs[j] = skillAttributeStruct;
                    }
                }
            }
        }
    }
    private void OnGUI()
    {
        if (restart)
        {
            EditorGUILayout.LabelField("出现错误请重新打开");
            return;
        }
        try
        {
            EditorGUILayout.BeginHorizontal();
            //左侧的选择状态类型与保存面板
            EditorGUILayout.BeginVertical(GUILayout.Width(100));
            if (GUILayout.Button("保存", GUILayout.Width(95)))
            {
                string valueText = SerializeNow(dataDic);
                File.WriteAllText(dataDirecotryPath + "/Status.txt", valueText, Encoding.UTF8);
                EditorUtility.DisplayDialog("保存数据", "保存成功!", "确认");
            }
            EditorGUILayout.LabelField("状态类型");
            selectEnumStatusEffect = (EnumStatusEffect)EditorGUILayout.EnumPopup(selectEnumStatusEffect, GUILayout.Width(95));
            FieldInfo            fieldInfo    = typeof(EnumStatusEffect).GetField(selectEnumStatusEffect.ToString());
            FieldExplanAttribute fieldExplane = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().FirstOrDefault();
            if (fieldExplane != null)
            {
                EditorGUILayout.LabelField(fieldExplane.GetExplan(), GUILayout.Width(95));
            }
            EditorGUILayout.EndVertical();

            //右侧显示详细信息面板
            EditorGUILayout.BeginVertical();
            rightScroll = EditorGUILayout.BeginScrollView(rightScroll);
            if (dataDic.ContainsKey(selectEnumStatusEffect))
            {
                StatusDataInfo statusDataInfo = dataDic[selectEnumStatusEffect];
                ReflectUnit <StatusDataInfo> statusDataInfoUnit = Entry.On(statusDataInfo);
                EditorGUILayout.BeginHorizontal();
                //说明
                EditorGUILayout.BeginVertical();
                EditorGUILayout.LabelField("状态简要说明");
                string statusExplane = EditorGUILayout.TextArea(statusDataInfo.StatusExplane, GUILayout.Width(200), GUILayout.Height(100));
                if (!string.Equals(statusExplane, statusDataInfo.StatusExplane))
                {
                    statusDataInfoUnit.Field("statusExplane", statusExplane);
                }
                EditorGUILayout.EndVertical();
                //图片
                EditorGUILayout.BeginVertical();
                EditorGUILayout.LabelField("状态的图标");
                statusDataInfo.Load();
                Sprite statusSprite = (Sprite)EditorGUILayout.ObjectField(statusDataInfo.StatusSprite, typeof(Sprite), true, GUILayout.Width(100), GUILayout.Height(100));
                if (!Sprite.Equals(statusSprite, statusDataInfo.StatusSprite) && statusSprite != null)
                {
                    string statusSpriteID = SpriteManager.GetName(statusSprite);
                    statusDataInfoUnit.Field("statusSpriteID", statusSpriteID).End();
                    statusDataInfoUnit.Field("statusSprite", null);
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.EndHorizontal();
                //不同等级的具体状态
                Dictionary <int, StatusDataInfo.StatusLevelDataInfo> levelToDataDic = statusDataInfoUnit.Field <Dictionary <int, StatusDataInfo.StatusLevelDataInfo> >("levelToDataDic").Element;
                //等级
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("最大等级:" + (levelToDataDic.Count - 1), GUILayout.Width(70));
                if (levelToDataDic.Count > 0 && GUILayout.Button("-", GUILayout.Width(20)))
                {
                    if (EditorUtility.DisplayDialog("警告!", "将会减去最后一个等级的数据!", "确认", "取消"))
                    {
                        levelToDataDic.Remove(levelToDataDic.Count - 1);
                    }
                }
                if (GUILayout.Button("+", GUILayout.Width(20)))
                {
                    levelToDataDic.Add(levelToDataDic.Count, new StatusDataInfo.StatusLevelDataInfo());
                }
                EditorGUILayout.LabelField("当前选择:" + selectLevel, GUILayout.Width(70));
                if (selectLevel > 0 && GUILayout.Button("-", GUILayout.Width(20)))
                {
                    selectLevel--;
                }
                if (selectLevel < levelToDataDic.Count - 1 && GUILayout.Button("+", GUILayout.Width(20)))
                {
                    selectLevel++;
                }
                selectLevel = Mathf.Clamp(selectLevel, 0, levelToDataDic.Count - 1);
                EditorGUILayout.EndHorizontal();
                //具体状态
                if (selectLevel >= 0 && selectLevel < levelToDataDic.Count)
                {
                    StatusDataInfo.StatusLevelDataInfo statusLeveDataInfo = levelToDataDic[selectLevel];
                    EditorGUILayout.LabelField("具体说明");
                    statusLeveDataInfo.LevelExplane = EditorGUILayout.TextArea(statusLeveDataInfo.LevelExplane, GUILayout.Height(60));
                    //该等级的耗魔对应基础持续时间曲线
                    EditorGUILayout.LabelField("持续时间曲线设置:");
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("最小魔力:", GUILayout.Width(75));
                    statusLeveDataInfo.MinMana       = EditorGUILayout.IntField(statusLeveDataInfo.MinMana, GUILayout.Width(75));
                    statusLeveDataInfo.DurationCuvre = EditorGUILayout.CurveField(statusLeveDataInfo.DurationCuvre, GUILayout.Width(150));
                    EditorGUILayout.LabelField("最大魔力:", GUILayout.Width(75));
                    statusLeveDataInfo.MaxMana = EditorGUILayout.IntField(statusLeveDataInfo.MaxMana, GUILayout.Width(75));
                    EditorGUILayout.EndHorizontal();
                    //设置具体的数据
                    EditorGUILayout.LabelField("具体数据设置:");
                    StatusActionAttribute statusAction = fieldInfo.GetCustomAttributes(typeof(StatusActionAttribute), false).OfType <StatusActionAttribute>().FirstOrDefault();
                    if (statusAction != null)
                    {
                        EnumStatusAction[] enumStatusActions = statusAction.GetStatusActions();
                        //如果不存在该项则添加
                        foreach (EnumStatusAction enumStatusAction in enumStatusActions)
                        {
                            if (!statusLeveDataInfo.StatusActionDataInfoDic.ContainsKey(enumStatusAction))
                            {
                                Type t = assembly.GetType("StatusActionDataInfo_" + enumStatusAction.ToString());
                                if (t != null)
                                {
                                    StatusActionDataInfo_Base sb = Activator.CreateInstance(t) as StatusActionDataInfo_Base;
                                    statusLeveDataInfo.StatusActionDataInfoDic.Add(enumStatusAction, sb);
                                }
                            }
                        }
                        //如果多余则删除
                        IEnumerable <EnumStatusAction> checkEnumStatusActions = statusLeveDataInfo.StatusActionDataInfoDic.Keys.OfType <EnumStatusAction>();
                        foreach (EnumStatusAction item in checkEnumStatusActions)
                        {
                            if (!enumStatusActions.Contains(item))
                            {
                                statusLeveDataInfo.StatusActionDataInfoDic.Remove(item);
                            }
                        }
                        //循环
                        Type enumStatusActionType = typeof(EnumStatusAction);
                        foreach (KeyValuePair <EnumStatusAction, StatusActionDataInfo_Base> item in statusLeveDataInfo.StatusActionDataInfoDic)
                        {
                            FieldExplanAttribute fieldExplanAttribute = enumStatusActionType.GetField(item.Key.ToString()).GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().First();
                            if (fieldExplanAttribute != null)
                            {
                                EditorGUILayout.Space();
                                EditorGUILayout.LabelField(fieldExplanAttribute.GetExplan()); //显示该状态效果的名字
                                Type statusActionDataInfoBaseType = item.Value.GetType();     // assembly.GetType("StatusActionDataInfo_" + item.Key.ToString());
                                if (statusActionDataInfoBaseType != null)
                                {
                                    FieldInfo[] statusActionDataInfoBaseInfos = statusActionDataInfoBaseType.GetFields();
                                    //便利该效果对应的数据对象并显示
                                    foreach (FieldInfo statusActionDataInfoBaseInfo in statusActionDataInfoBaseInfos)
                                    {
                                        object innerValueData = statusActionDataInfoBaseInfo.GetValue(item.Value);
                                        FieldExplanAttribute innerAttribute = statusActionDataInfoBaseInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().FirstOrDefault();
                                        if (innerAttribute != null)
                                        {
                                            EditorGUILayout.BeginHorizontal();
                                            EditorGUILayout.LabelField(innerAttribute.GetExplan());
                                            if (statusActionDataInfoBaseInfo.FieldType.Equals(typeof(int)))
                                            {
                                                int innerValue = EditorGUILayout.IntField((int)innerValueData);
                                                statusActionDataInfoBaseInfo.SetValue(item.Value, innerValue);
                                            }
                                            else if (statusActionDataInfoBaseInfo.FieldType.Equals(typeof(float)))
                                            {
                                                float innerValue = EditorGUILayout.FloatField((float)innerValueData);
                                                statusActionDataInfoBaseInfo.SetValue(item.Value, innerValue);
                                            }
                                            else if (statusActionDataInfoBaseInfo.FieldType.Equals(typeof(string)))
                                            {
                                                string innerValue = EditorGUILayout.TextField((string)innerValueData);
                                                statusActionDataInfoBaseInfo.SetValue(item.Value, innerValue);
                                            }
                                            else if (statusActionDataInfoBaseInfo.FieldType.Equals(typeof(bool)))
                                            {
                                                bool innerValue = EditorGUILayout.Toggle((bool)innerValueData);
                                                statusActionDataInfoBaseInfo.SetValue(item.Value, innerValue);
                                            }
                                            EditorGUILayout.EndHorizontal();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }
        catch
        {
            restart = false;
        }
    }
    private void Awake()
    {
        //重置路径
        dataDirectoryPath = Application.dataPath + @"\Scripts\Data\Resources\Data\SkillSprite";

        skillTypeToSpriteShowDic    = new Dictionary <EnumSkillType, Sprite>();
        skillTypeToSpriteCombineDic = new Dictionary <EnumSkillType, Sprite>();
        skillTypeToExplanDic        = new Dictionary <EnumSkillType, string>();
        if (!Directory.Exists(dataDirectoryPath))
        {
            Directory.CreateDirectory(dataDirectoryPath);
        }
        //用于显示
        if (!File.Exists(dataDirectoryPath + "/SkillSprite.txt"))
        {
            File.Create(dataDirectoryPath + "/SkillSprite.txt").Close();
            skillTypeToSpriteIDShowDic = new Dictionary <EnumSkillType, string>();
            File.WriteAllText(dataDirectoryPath + "/SkillSprite.txt", "{}", Encoding.UTF8);
        }
        else
        {
            string assetText = File.ReadAllText(dataDirectoryPath + "/SkillSprite.txt", Encoding.UTF8);
            skillTypeToSpriteIDShowDic = DeSerializeNow <Dictionary <EnumSkillType, string> >(assetText);
        }
        //用于组合
        if (!File.Exists(dataDirectoryPath + "/SkillSprite_Combine.txt"))
        {
            File.Create(dataDirectoryPath + "/SkillSprite_Combine.txt").Close();
            skillTypeToSpriteIDCombineDic = new Dictionary <EnumSkillType, string>();
            File.WriteAllText(dataDirectoryPath + "/SkillSprite_Combine.txt", "{}", Encoding.UTF8);
        }
        else
        {
            string assetText = File.ReadAllText(dataDirectoryPath + "/SkillSprite_Combine.txt", Encoding.UTF8);
            skillTypeToSpriteIDCombineDic = DeSerializeNow <Dictionary <EnumSkillType, string> >(assetText);
        }
        //检测是否增加或减少
        EnumSkillType[] defaultEnumSKillTypes = Enum.GetValues(typeof(EnumSkillType)).OfType <EnumSkillType>().ToArray();
        //增加二阶技能的枚举
        EnumSkillType[] combineEnumSkillTypes = SkillCombineStaticTools.GetCombineSkillByCombineSkillIndex(2);
        defaultEnumSKillTypes = defaultEnumSKillTypes.Concat(combineEnumSkillTypes).Distinct().ToArray();
        foreach (EnumSkillType enumSkillType in defaultEnumSKillTypes)//检测增加量
        {
            if (!skillTypeToSpriteIDShowDic.ContainsKey(enumSkillType))
            {
                skillTypeToSpriteIDShowDic.Add(enumSkillType, "");
            }
            if (!skillTypeToSpriteIDCombineDic.ContainsKey(enumSkillType))
            {
                skillTypeToSpriteIDCombineDic.Add(enumSkillType, "");
            }
        }
        //显示
        EnumSkillType[] nowShowDicEnumSkillTypes = skillTypeToSpriteIDShowDic.Keys.OfType <EnumSkillType>().ToArray();
        foreach (EnumSkillType enumSkillType in nowShowDicEnumSkillTypes)//检测减少量
        {
            if (!defaultEnumSKillTypes.Contains(enumSkillType))
            {
                skillTypeToSpriteIDShowDic.Remove(enumSkillType);
            }
        }
        //组合
        EnumSkillType[] nowCombineDicEnumSkillTypes = skillTypeToSpriteIDCombineDic.Keys.OfType <EnumSkillType>().ToArray();
        foreach (EnumSkillType enumSkillType in nowCombineDicEnumSkillTypes)//检测减少量
        {
            if (!defaultEnumSKillTypes.Contains(enumSkillType))
            {
                skillTypeToSpriteIDCombineDic.Remove(enumSkillType);
            }
        }
        //根据当前id字典构建sprite字典(显示)
        foreach (KeyValuePair <EnumSkillType, string> item in skillTypeToSpriteIDShowDic)
        {
            Sprite sprite = SpriteManager.GetSrpite(item.Value);
            skillTypeToSpriteShowDic.Add(item.Key, sprite);
        }
        //根据当前id字典构建sprite字典(组合)
        foreach (KeyValuePair <EnumSkillType, string> item in skillTypeToSpriteIDCombineDic)
        {
            Sprite sprite = SpriteManager.GetSrpite(item.Value);
            skillTypeToSpriteCombineDic.Add(item.Key, sprite);
        }
        //构建技能类型对应说明字典
        Type enumType = typeof(EnumSkillType);
        Func <EnumSkillType, string> GetSkillNameFunc = (skillType) =>
        {
            FieldInfo fieldInfo = enumType.GetField(skillType.ToString());
            if (fieldInfo != null)
            {
                FieldExplanAttribute fieldExplanAttribute = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().FirstOrDefault();
                if (fieldExplanAttribute != null)
                {
                    return(fieldExplanAttribute.GetExplan());
                }
            }
            return(null);
        };

        foreach (EnumSkillType enumSkillType in defaultEnumSKillTypes)
        {
            string skillName = GetSkillNameFunc(enumSkillType);
            if (skillName != null)
            {
                skillTypeToExplanDic.Add(enumSkillType, skillName);
            }
            else//这可能是组合技能
            {
                int key = (int)enumSkillType;
                if (key <= (int)EnumSkillType.MagicCombinedStart || key >= (int)EnumSkillType.EndMagic)//这不是组合技能
                {
                    continue;
                }
                EnumSkillType[] childSkills = SkillCombineStaticTools.GetCombineSkills(key);
                if (childSkills != null && childSkills.Length > 0)
                {
                    string names = "组合:";
                    childSkills.ToList().ForEach(temp => names += GetSkillNameFunc(temp) + "--");
                    skillTypeToExplanDic.Add(enumSkillType, names);
                }
                else
                {
                    skillTypeToExplanDic.Add(enumSkillType, "获取命名失败");
                }
            }
        }
    }