void Awake()
    {
        //重置路径
        dataInterludesFilePath  = Application.dataPath + @"\Scripts\Data\Resources\Data\Interludes\InterludesData.json";
        cameraPathDirectoryPath = Application.dataPath + @"\Scripts\Data\Resources\Data\Interludes\CameraPath";

        interludesShowTimeExplanList = new List <KeyValuePair <InterludesItemStruct.EnumInterludesShowTime, string> >();
        FieldExplanAttribute.SetEnumExplanDic(interludesShowTimeExplanList);

        itemDataTypeToExplanDic = new Dictionary <Type, string>();
        itemDataTypeToExplanDic.Add(typeof(InterludesDataInfo.ItemData), "空");
        itemDataTypeToExplanDic.Add(typeof(InterludesDataInfo.ItemData_Talk), "显示对话");
        itemDataTypeToExplanDic.Add(typeof(InterludesDataInfo.ItemData_CameraPathAnimation), "镜头动画");

        if (!File.Exists(dataInterludesFilePath))
        {
            File.Create(dataInterludesFilePath).Close();
            interludesItemStructList = new List <InterludesItemStruct>();
            string assetStr = SerializeNow(interludesItemStructList);
            File.WriteAllText(dataInterludesFilePath, assetStr, Encoding.UTF8);
        }
        else
        {
            string assetStr = File.ReadAllText(dataInterludesFilePath, Encoding.UTF8);
            interludesItemStructList = DeSerializeNow <List <InterludesItemStruct> >(assetStr);
            if (interludesItemStructList == null)
            {
                interludesItemStructList = new List <InterludesItemStruct>();
            }
        }
    }
Пример #2
0
 public override void SetForcus()
 {
     uiAddNum.gameObject.SetActive(true);
     okRectTrans.gameObject.SetActive(false);
     iPlayerAttributeState = GameState.Instance.GetEntity <IPlayerAttributeState>();
     playerState           = DataCenter.Instance.GetEntity <PlayerState>();
     keyValueList          = new List <KeyValuePair <EnumBaseAttributeType, string> >();
     FieldExplanAttribute.SetEnumExplanDic(keyValueList);
     addPoint = 0;
     UpdateShow();
 }
    private void Awake()
    {
        base.titleContent     = new GUIContent("功能交互编辑器-->附加数据");
        goodsTypeToExplanList = new List <KeyValuePair <EnumGoodsType, string> >();
        FieldExplanAttribute.SetEnumExplanDic(goodsTypeToExplanList, 0, temp => ((int)temp) % 1000 != 0);

        qualityTypeToExplanList = new List <KeyValuePair <EnumQualityType, string> >();
        FieldExplanAttribute.SetEnumExplanDic(qualityTypeToExplanList);

        Type[] tempOtherDataTypes = typeof(ActionInteractiveDataInfoMono).Assembly.GetTypes();
        otherDataTypes = tempOtherDataTypes.Where(temp => temp.IsSubclassOf(typeof(ActionInteractiveDataInfoMono)) && !temp.Equals(typeof(ActionInteractiveDataInfoMono_TreasureBox))).ToList();
    }
    private void OnEnable()
    {
        playerState          = DataCenter.Instance.GetEntity <PlayerState>();
        iPlayerState         = GameState.Instance.GetEntity <IPlayerState>();
        roleOfRaceExplanList = new List <KeyValuePair <RoleOfRace, string> >();
        FieldExplanAttribute.SetEnumExplanDic(roleOfRaceExplanList);
        GameState.Instance.Registor <IPlayerAttributeState>(IPlayerAttributeStateChanged);
        UpdateText();
        UIManager.Instance.KeyPressHandle += Instance_KeyPressHandle;
        UIManager.Instance.KeyUpHandle    += Instance_KeyUpHandle;
        scrollbar.value = 0;
        uiFocusPath     = GetComponent <UIFocusPath>();
        UIFocus[] uiFocusArray = uiFocusPath.NewUIFocusArray;
        foreach (UIFocus uiFocus in uiFocusArray)
        {
            uiFocus.SetForcus();
            uiFocus.LostForcus();
        }
        //给任务系统填入状态
        INowTaskState iNowTaskState = GameState.Instance.GetEntity <INowTaskState>();

        iNowTaskState.CheckNowTask(EnumCheckTaskType.Special, (int)TaskMap.Enums.EnumTaskSpecialCheck.OpenAttributeUI);
    }
    private void Awake()
    {
        base.titleContent = new GUIContent("功能交互编辑器");

        //重置路径
        dataAllPath = Application.dataPath + @"\Scripts\Data\Resources\Data\ActionInteractiveData";

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

        TextAsset[] allTextAssets = Resources.LoadAll <TextAsset>(ActionInteractiveData.dataDirectoryPath);
        foreach (TextAsset textAsset in allTextAssets)
        {
            dataDic.Add(textAsset.name, textAsset);
        }
        GameObject[] allPrefabs = Resources.LoadAll <GameObject>(ActionInteractiveDataInfo.prefabDirectoryPath);
        foreach (GameObject prefab in allPrefabs)
        {
            prefabDataDic.Add(prefab.name, prefab);
        }
        actionInteractiveTypeToNameList = new List <KeyValuePair <EnumActionInteractiveType, string> >();
        FieldExplanAttribute.SetEnumExplanDic(actionInteractiveTypeToNameList);
    }
Пример #6
0
    private void Awake()
    {
        //重置路径
        //Debug.Log(Application.dataPath);
        dataFilePath = Application.dataPath + @"\Scripts\Data\Resources\Data\Entry\Entry.json";
        //
        dataMap = new Map <EntryDataInfo>();
        if (!File.Exists(dataFilePath))
        {
            File.Create(dataFilePath).Close();
            MapElement <EntryDataInfo> root = dataMap.CreateMapElement();
            root.Deep  = -1;
            root.Value = new EntryDataInfo()
            {
                ID = root.ID
            };
            string jsonStr = dataMap.Save();
            File.WriteAllText(dataFilePath, jsonStr, Encoding.UTF8);
        }
        else
        {
            string jsonStr = File.ReadAllText(dataFilePath, Encoding.UTF8);
            dataMap.Load(jsonStr);
        }
        entryValueTypeToExplanList = new List <KeyValuePair <EntryDataInfo.EnumEntryValueType, string> >();
        FieldExplanAttribute.SetEnumExplanDic(entryValueTypeToExplanList);
        entryUnlockTypeToExplanList = new List <KeyValuePair <EntryDataInfo.EnumEntryUnlockType, string> >();
        FieldExplanAttribute.SetEnumExplanDic(entryUnlockTypeToExplanList);
        monsterTypeToExplanList = new List <KeyValuePair <EnumMonsterType, string> >();
        FieldExplanAttribute.SetEnumExplanDic(monsterTypeToExplanList);

        buttonSelectStyle                   = new GUIStyle();
        buttonSelectStyle.fontSize          = 10;                                      //字体大小
        buttonSelectStyle.alignment         = TextAnchor.MiddleCenter;                 //文字位置上下左右居中,
        buttonSelectStyle.normal.background = Resources.Load <Texture2D>("Task/Blue"); //背景.
        buttonSelectStyle.normal.textColor  = Color.yellow;                            //文字颜色。
    }
Пример #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);
    }
    private void Awake()
    {
        //重置路径
        dataFilePath = Application.dataPath + @"\Scripts\Data\Resources\Data\RoleOfRaceData\RoleOfRaceData.json";

        if (!File.Exists(dataFilePath))
        {
            File.Create(dataFilePath).Close();
            roleOfRaceInfoStructArray = new RoleOfRaceInfoStruct[0];
            string valueText = SerializeNow(roleOfRaceInfoStructArray);
            File.WriteAllText(dataFilePath, valueText, Encoding.UTF8);
        }
        else
        {
            string valueText = File.ReadAllText(dataFilePath, Encoding.UTF8);
            roleOfRaceInfoStructArray = DeSerializeNow <RoleOfRaceInfoStruct[]>(valueText);
            if (roleOfRaceInfoStructArray == null)
            {
                roleOfRaceInfoStructArray = new RoleOfRaceInfoStruct[0];
            }
        }
        Type roleOfRaceType = typeof(RoleOfRace);

        FieldInfo[]  fieldInfos  = roleOfRaceType.GetFields(BindingFlags.Public | BindingFlags.Static);
        RoleOfRace[] roleOfRaces = fieldInfos.Select(temp => (int)temp.GetValue(null)).Select(temp => (RoleOfRace)temp).ToArray();
        List <RoleOfRaceInfoStruct> roleOfRaceInfoStructList = new List <RoleOfRaceInfoStruct>(roleOfRaceInfoStructArray);

        foreach (RoleOfRace roleOfRace in roleOfRaces)
        {
            if (roleOfRaceInfoStructList.Count(temp => temp.roleOfRace == roleOfRace) == 0)
            {
                roleOfRaceInfoStructList.Add(new RoleOfRaceInfoStruct()
                {
                    roleOfRace = roleOfRace
                });
            }
        }
        roleOfRaceInfoStructArray = roleOfRaceInfoStructList.ToArray();
        //重构节点显示树
        roleOfRaceShowTree = new Tree <KeyValuePair <RoleOfRace, Rect> >();
        Tree <RoleOfRace> roleOfRaceTree = RoleOfRaceHelper.roleOfRaceTree;

        roleOfRaceShowTree.TopNode = new TreeNode <KeyValuePair <RoleOfRace, Rect> >(new KeyValuePair <RoleOfRace, Rect>(roleOfRaceTree.TopNode.Data, Rect.zero));
        TreeNode <KeyValuePair <RoleOfRace, Rect> > tempShowNode = roleOfRaceShowTree.TopNode;
        TreeNode <RoleOfRace> tempNode = roleOfRaceTree.TopNode;

        //设置显示树的节点
        SetShowTreeChildNode(tempNode, tempShowNode);
        //查找树的最大深度和最大广度
        Dictionary <RoleOfRace, KeyValuePair <int, int> > deepExtentDic = new Dictionary <RoleOfRace, KeyValuePair <int, int> >();

        CheckShowTreeDeepAndExtent(tempNode, 1, 1, deepExtentDic);
        //计算最大的深度和广度
        int maxDeep   = deepExtentDic.Max(temp => temp.Value.Key);
        int maxExtent = deepExtentDic.Max(temp => temp.Value.Value);

        //根据该深度和广度计算总大小
        maxHeight = maxDeep * 150;   //50+100 高50 间距100
        maxWidth  = maxExtent * 110; //100+10 宽100 间距10
        SetShowTreeRect(tempShowNode, deepExtentDic, 100, 50, 10, 100, maxWidth);
        //设置枚举对应的显示文字
        roleOfRaceExplanList = new List <KeyValuePair <RoleOfRace, string> >();
        FieldExplanAttribute.SetEnumExplanDic(roleOfRaceExplanList);
    }
    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();
    }
Пример #10
0
 private void Awake()
 {
     ItemExplanValueList    = new List <GameObject>();
     goodsAbilityExplanList = new List <KeyValuePair <EnumGoodsAbility, string> >();
     FieldExplanAttribute.SetEnumExplanDic(goodsAbilityExplanList);
 }