Esempio n. 1
0
    /// <summary>
    /// 是否可以显示该怪物
    /// </summary>
    /// <param name="GetTaskProgressFunc">通过id获取任务状态</param>
    /// <returns></returns>
    public bool CanShowThis(Func <int, TaskMap.Enums.EnumTaskProgress> GetTaskProgressFunc)
    {
        if (GetTaskProgressFunc == null)
        {
            return(false);
        }
        bool mustHide = false;//必须隐藏

        if (TaskToHideList != null)
        {
            foreach (var item in TaskToHideList)
            {
                TaskMap.Enums.EnumTaskProgress nowState = GetTaskProgressFunc(item.Key);
                if (item.Value == nowState)
                {
                    mustHide = true;
                    break;
                }
            }
        }
        bool canShow = true;//可以显示

        if (TaskToShowList != null)
        {
            foreach (var item in TaskToShowList)
            {
                TaskMap.Enums.EnumTaskProgress nowState = GetTaskProgressFunc(item.Key);
                if (item.Value != nowState)
                {
                    canShow = false;
                }
            }
        }
        if (mustHide)
        {
            return(false);
        }
        else
        {
            if (canShow)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
    }
Esempio n. 2
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 (npcDataDic == null)
        {
            return;
        }
        if (tempNPCDataInfo == null)
        {
            tempNPCDataInfo = new NPCDataInfo();
            if (nowIDList.Count > 0)
            {
                tempNPCDataInfo.NPCID = nowIDList.Max() + 1;
            }
            else
            {
                tempNPCDataInfo.NPCID = 0;
            }
            tempNPCDataInfo.NPCName       = "Name";
            tempNPCDataInfo.npcPrefabName = "";
            tempNPCDataInfo.NPCType       = EnumNPCType.Normal;
        }
        EditorGUILayout.BeginVertical();

        scroll = EditorGUILayout.BeginScrollView(scroll);

        List <string> names = npcDataDic.Keys.OfType <string>().ToList();
        int           index = names.IndexOf(tempNPCDataInfo.npcPrefabName);

        if (tempNPCDataInfo.NPCObj)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(tempNPCDataInfo.npcPrefabName);
            if (GUILayout.Button("×", GUILayout.Width(25)))
            {
                if (EditorUtility.DisplayDialog("警告!", "是否重新选择预设提?", "是", "否"))
                {
                    tempNPCDataInfo.npcPrefabName = "";
                    tempNPCDataInfo.InitNPCObjPrefab();
                    GameObject.DestroyImmediate(tempNPCDataInfo.NPCObj);
                    tempNPCDataInfo.NPCObj = null;
                    index    = -1;
                    isCreate = false;
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        else
        {
            index = EditorGUILayout.Popup(index, names.ToArray());
            if (index >= 0)
            {
                tempNPCDataInfo.npcPrefabName = names[index];
            }
        }

        if (index >= 0)
        {
            EditorGUILayout.ObjectField(npcDataDic[tempNPCDataInfo.npcPrefabName], typeof(GameObject), true);
        }
        int id = EditorGUILayout.IntField("NPC ID:", tempNPCDataInfo.NPCID);

        if (!nowIDList.Contains(id))
        {
            tempNPCDataInfo.NPCID = id;
        }
        tempNPCDataInfo.NPCName = EditorGUILayout.TextField("NPC Name:", tempNPCDataInfo.NPCName);
        if (npcTypeToExplanList == null)
        {
            npcTypeToExplanList = new List <KeyValuePair <EnumNPCType, string> >();
            FieldExplanAttribute.SetEnumExplanDic(npcTypeToExplanList);
        }
        List <EnumNPCType> npcTypeValues = npcTypeToExplanList.Select(temp => temp.Key).ToList();

        string[] npcTypeExplans = npcTypeToExplanList.Select(temp => temp.Value).ToArray();
        int      npcTypeIndex   = npcTypeValues.IndexOf(tempNPCDataInfo.NPCType);

        npcTypeIndex = EditorGUILayout.Popup("NPC Type:", npcTypeIndex, npcTypeExplans);
        if (npcTypeIndex >= 0)
        {
            tempNPCDataInfo.NPCType = npcTypeValues[npcTypeIndex];
        }
        tempNPCDataInfo.OtherValue = EditorGUILayout.TextField("Other Data:", tempNPCDataInfo.OtherValue);
        if (isCreate)
        {
            EditorGUILayout.ObjectField("NPC Object:", tempNPCDataInfo.NPCObj, typeof(GameObject), true);
        }
        if (((!isCreate && index >= 0) || (tempNPCDataInfo.NPCObj == null && index >= 0)) &&
            GUILayout.Button("Create NPC GameObject"))
        {
            GameObject createObj = GameObject.Instantiate <GameObject>(npcDataDic[tempNPCDataInfo.npcPrefabName]);
            tempNPCDataInfo.NPCObj = createObj;
            isCreate = true;
        }
        if (tempNPCDataInfo.NPCObj != null)
        {
            Selection.activeGameObject = tempNPCDataInfo.NPCObj;
            if (tempNPCDataInfo.NPCObj.GetComponent <TalkShowPosition>() == null)
            {
                tempNPCDataInfo.NPCObj.AddComponent <TalkShowPosition>();
            }
            tempNPCDataInfo.NPCObj.GetComponent <TalkShowPosition>().tempNPCDataInfo = tempNPCDataInfo;
            tempNPCDataInfo.TalkShowOffset = EditorGUILayout.Vector3Field("Talk Show Offset:", tempNPCDataInfo.TalkShowOffset);
            Vector3 talkShowWorldVec = tempNPCDataInfo.TalkShowOffset + tempNPCDataInfo.NPCObj.transform.position;
        }
        Sprite tempSprite = (Sprite)EditorGUILayout.ObjectField("NPC Sprite:", tempNPCDataInfo.NPCSprite, typeof(Sprite), false);

        if (tempSprite != tempNPCDataInfo.NPCSprite && tempSprite != null)
        {
            tempNPCDataInfo.npcSpriteID = SpriteManager.GetName(tempSprite);
            tempNPCDataInfo.NPCSprite   = tempSprite;
        }
        EditorGUILayout.LabelField("------------------显示条件------------------");
        if (tempNPCDataInfo.NPCShowCondition == null && GUILayout.Button("创建显示条件"))
        {
            tempNPCDataInfo.NPCShowCondition = new NPCShowCondition();
        }
        if (tempNPCDataInfo.NPCShowCondition != null)
        {
            if (GUILayout.Button("删除显示条件"))
            {
                if (EditorUtility.DisplayDialog("请再次确认!", "是否要删除显示条件?", "删除", "取消"))
                {
                    tempNPCDataInfo.NPCShowCondition = null;
                }
            }
        }
        if (tempNPCDataInfo.NPCShowCondition != null)
        {
            if (taskStateTypeToExplanList == null)
            {
                taskStateTypeToExplanList = new List <KeyValuePair <TaskMap.Enums.EnumTaskProgress, string> >();
                FieldExplanAttribute.SetEnumExplanDic(taskStateTypeToExplanList);
            }
            List <TaskMap.Enums.EnumTaskProgress> taskProgressValueList = taskStateTypeToExplanList.Select(temp => temp.Key).ToList();
            string[] taskProgressExplanArray = taskStateTypeToExplanList.Select(temp => temp.Value).ToArray();
            //显示与任务条件相关的函数
            Func <NPCShowCondition.TaskCondition[], NPCShowCondition.TaskCondition[]> ShowAbourtTaskConditionFunc = (source) =>
            {
                if (source == null)
                {
                    source = new NPCShowCondition.TaskCondition[0];
                }
                if (GUILayout.Button("添加", GUILayout.Width(50)))
                {
                    NPCShowCondition.TaskCondition[] tempSource = new NPCShowCondition.TaskCondition[source.Length + 1];
                    Array.Copy(source, tempSource, source.Length);
                    tempSource[source.Length] = new NPCShowCondition.TaskCondition();
                    source = tempSource;
                }
                List <NPCShowCondition.TaskCondition> removeList = new List <NPCShowCondition.TaskCondition>();//需要移除的列表
                foreach (NPCShowCondition.TaskCondition taskCondition in source)
                {
                    if (taskCondition == null)
                    {
                        continue;
                    }
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("×", GUILayout.Width(20)))//删除
                    {
                        if (EditorUtility.DisplayDialog("请再次确认!", "是否删除该条数据?", "删除", "取消"))
                        {
                            removeList.Add(taskCondition);
                        }
                    }
                    EditorGUILayout.LabelField("任务ID:", GUILayout.Width(50));
                    taskCondition.TaskID = EditorGUILayout.IntField(taskCondition.TaskID, GUILayout.Width(20));

                    EditorGUILayout.LabelField("任务状态:", GUILayout.Width(60));
                    int taskStateIndex = taskProgressValueList.IndexOf(taskCondition.TaskState);
                    taskStateIndex = EditorGUILayout.Popup(taskStateIndex, taskProgressExplanArray, GUILayout.Width(100));
                    if (taskStateIndex > -1)
                    {
                        TaskMap.Enums.EnumTaskProgress tskProgress = taskProgressValueList[taskStateIndex];
                        taskCondition.TaskState = tskProgress;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (removeList.Count > 0)
                {
                    List <NPCShowCondition.TaskCondition> tempSource = new List <NPCShowCondition.TaskCondition>(source);
                    foreach (NPCShowCondition.TaskCondition taskCondition in removeList)
                    {
                        tempSource.Remove(taskCondition);
                    }
                    source = tempSource.ToArray();
                }
                return(source);
            };
            tempNPCDataInfo.NPCShowCondition.TimeRange = EditorGUILayout.Vector2Field("在该时间范围内显示(都为0表示不受该项影响)", tempNPCDataInfo.NPCShowCondition.TimeRange);
            EditorGUILayout.LabelField("NPC的隐藏条件(满足任何一条则必须隐藏):");
            tempNPCDataInfo.NPCShowCondition.TaskConditionsHide = ShowAbourtTaskConditionFunc(tempNPCDataInfo.NPCShowCondition.TaskConditionsHide);
            EditorGUILayout.LabelField("NPC的显示条件(满足任何一条则允许显示):");
            tempNPCDataInfo.NPCShowCondition.TaskConditionShow = ShowAbourtTaskConditionFunc(tempNPCDataInfo.NPCShowCondition.TaskConditionShow);
        }
        EditorGUILayout.LabelField("------------------其他数据------------------");
        switch (tempNPCDataInfo.NPCType)
        {
        case EnumNPCType.Businessman:    //如果是商人,则otherValue的数据是BusinessmanDataInfo类型的数据
            if (businessmanDataInfo == null)
            {
                businessmanDataInfo = BusinessmanDataInfo.DeSerializeNow <BusinessmanDataInfo>(tempNPCDataInfo.OtherValue);
                if (businessmanDataInfo == null)
                {
                    businessmanDataInfo = new BusinessmanDataInfo();
                }
            }
            if (goodsMetaInfoMations == null)
            {
                goodsMetaInfoMations = new GoodsMetaInfoMations();
                goodsMetaInfoMations.Load();
            }
            if (goodsTypeToExplanList == null)
            {
                goodsTypeToExplanList = new List <KeyValuePair <EnumGoodsType, string> >();
                FieldExplanAttribute.SetEnumExplanDic(goodsTypeToExplanList, 0, temp => ((int)temp) % 1000 != 0);
            }
            if (goodsQualityTypeToExplanList == null)
            {
                goodsQualityTypeToExplanList = new List <KeyValuePair <EnumQualityType, string> >();
                FieldExplanAttribute.SetEnumExplanDic(goodsQualityTypeToExplanList, 0);
            }
            //显示商人应该显示的列表
            businessmanScroll = EditorGUILayout.BeginScrollView(businessmanScroll);
            {
                List <EnumGoodsType> enumGoodsTypes   = goodsTypeToExplanList.Select(temp => temp.Key).ToList();
                string[]             enumGoodsExplans = goodsTypeToExplanList.Select(temp => temp.Value).ToArray();
                EditorGUILayout.BeginHorizontal();
                goodsTypeIndex = EditorGUILayout.Popup(goodsTypeIndex, enumGoodsExplans);
                if (GUILayout.Button("添加该物品"))
                {
                    if (goodsTypeIndex > -1 &&
                        goodsTypeIndex < enumGoodsExplans.Length &&
                        !businessmanDataInfo.GoodsDic.ContainsKey(enumGoodsTypes[goodsTypeIndex]))
                    {
                        businessmanDataInfo.GoodsDic.Add(enumGoodsTypes[goodsTypeIndex], new BusinessmanDataInfo.GoodsDataInfoInner());
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("提示!", "添加失败!", "确定");
                    }
                }
                EditorGUILayout.EndHorizontal();
                List <EnumQualityType> qualityTypes   = goodsQualityTypeToExplanList.Select(temp => temp.Key).ToList();
                string[]             qualityExplans   = goodsQualityTypeToExplanList.Select(temp => temp.Value).ToArray();
                List <EnumGoodsType> removeGoodsTypes = new List <EnumGoodsType>();
                foreach (KeyValuePair <EnumGoodsType, BusinessmanDataInfo.GoodsDataInfoInner> item in businessmanDataInfo.GoodsDic)
                {
                    EditorGUILayout.BeginHorizontal();
                    int goodsTypeIndex = enumGoodsTypes.IndexOf(item.Key);
                    if (goodsTypeIndex > -1)
                    {
                        EditorGUILayout.LabelField(enumGoodsExplans[goodsTypeIndex], GUILayout.Width(150));
                        int _qualityIndex_min = qualityTypes.IndexOf(item.Value.MinQualityType);
                        int qualityIndex_min  = EditorGUILayout.Popup(_qualityIndex_min, qualityExplans, GUILayout.Width(150));
                        if (_qualityIndex_min != qualityIndex_min && qualityIndex_min > -1)
                        {
                            item.Value.MinQualityType = qualityTypes[qualityIndex_min];
                        }
                        int _qualityIndex_Max = qualityTypes.IndexOf(item.Value.MaxQualityType);
                        int qualityIndex_max  = EditorGUILayout.Popup(_qualityIndex_Max, qualityExplans, GUILayout.Width(150));
                        if (_qualityIndex_Max != qualityIndex_max && qualityIndex_max > -1)
                        {
                            item.Value.MaxQualityType = qualityTypes[qualityIndex_max];
                        }
                        if (GUILayout.Button("×", GUILayout.Width(25)))
                        {
                            if (EditorUtility.DisplayDialog("请再次确认!", "是否删除?", "确定", "取消"))
                            {
                                removeGoodsTypes.Add(item.Key);
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
                removeGoodsTypes.ForEach(temp => businessmanDataInfo.GoodsDic.Remove(temp));
            }
            EditorGUILayout.EndScrollView();
            break;
        }

        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }