public ActionResult CropInfoDelete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CropInformation cropInformation = db.CropInformations.Find(id);

            if (cropInformation == null)
            {
                return(HttpNotFound());
            }
            return(View(cropInformation));
        }
Пример #2
0
    public void FinishPreview()
    {
        if (preview)
        {
            Destroy(preview.gameObject);
        }
        preview     = null;
        currentInfo = null;
        WindowsManager.HideAll(false);
        IsPreviewing = false;
#if UNITY_ANDROID
        ZetanUtility.SetActive(CancelArea, false);
#endif
    }
Пример #3
0
    private void OnEnable()
    {
        lineHeight      = EditorGUIUtility.singleLineHeight;
        lineHeightSpace = lineHeight + 5;

        crop = target as CropInformation;

        _ID         = serializedObject.FindProperty("_ID");
        _name       = serializedObject.FindProperty("_name");
        cropType    = serializedObject.FindProperty("cropType");
        plantSeason = serializedObject.FindProperty("plantSeason");
        stages      = serializedObject.FindProperty("stages");
        HandlingStageList();
    }
Пример #4
0
    public void ShowDescription(SeedItem seed)
    {
        if (!seed)
        {
            HideDescription();
            return;
        }

        descriptionWindow.alpha = 1;
        nameText.text           = seed.Crop.Name;
        int amount = BackpackManager.Instance.GetAmount(seed);

        icon.SetItem(seed, amount > 0 ? amount.ToString() : null);
        StringBuilder str = new StringBuilder("占用田地空间:");

        str.Append(seed.Crop.Size);
        str.Append("\n");
        str.Append(CropInformation.CropSeasonString(seed.Crop.PlantSeason));
        str.Append("\n");
        str.Append("生长阶段:");
        str.Append("\n");
        for (int i = 0; i < seed.Crop.Stages.Count; i++)
        {
            CropStage stage = seed.Crop.Stages[i];
            str.Append(ZetanUtility.ColorText(CropStage.CropStageName(stage.Stage), Color.yellow));
            str.Append("持续");
            str.Append(ZetanUtility.ColorText(stage.LastingDays.ToString(), Color.green));
            str.Append("天");
            if (stage.HarvestAble)
            {
                if (stage.RepeatTimes > 0)
                {
                    str.Append(",可收割");
                    str.Append(ZetanUtility.ColorText(stage.RepeatTimes.ToString(), Color.green));
                    str.Append("次");
                }
                else if (stage.RepeatTimes < 0)
                {
                    str.Append(",可无限收割");
                }
            }
            if (i != seed.Crop.Stages.Count - 1)
            {
                str.Append("\n");
            }
        }
        description.text = str.ToString();
    }
Пример #5
0
    public CropData PlantCrop(CropInformation crop)
    {
        if (!crop)
        {
            return(null);
        }

        if (spaceOccup < crop.Size)
        {
            return(null);
        }

        CropData cropData = new CropData(crop, this);

        Crops.Add(cropData);
        return(cropData);
    }
Пример #6
0
    private void OnEnable()
    {
        lineHeight      = EditorGUIUtility.singleLineHeight;
        lineHeightSpace = lineHeight + 2;

        crop = target as CropInformation;

        _ID           = serializedObject.FindProperty("_ID");
        _name         = serializedObject.FindProperty("_name");
        cropType      = serializedObject.FindProperty("cropType");
        temperature   = serializedObject.FindProperty("temperature");
        humidity      = serializedObject.FindProperty("humidity");
        size          = serializedObject.FindProperty("size");
        prefab        = serializedObject.FindProperty("prefab");
        previewPrefab = serializedObject.FindProperty("previewPrefab");
        plantSeason   = serializedObject.FindProperty("plantSeason");
        stages        = serializedObject.FindProperty("stages");
        HandlingStageList();
    }
Пример #7
0
    public void CreatPreview(CropInformation info)
    {
        if (!PlayerManager.Instance.CheckIsNormalWithAlert())
        {
            return;
        }
        if (info == null)
        {
            return;
        }
        HideDescription();
        HideBuiltList();
        currentInfo = info;
        preview     = Instantiate(currentInfo.PreviewPrefab);
        WindowsManager.HideAll(true);
        IsPreviewing = true;
#if UNITY_ANDROID
        ZetanUtility.SetActive(CancelArea, true);
#endif
        ShowAndMovePreview();
    }
Пример #8
0
    public void PlantCrop(CropInformation crop, Vector3 position)
    {
        if (!crop)
        {
            return;
        }

        if (FData.spaceOccup < crop.Size)
        {
            MessageManager.Instance.New("空间不足");
            return;
        }

        CropData cropData = FData.PlantCrop(crop);

        if (cropData)
        {
            Crop entity = ObjectPool.Get(crop.Prefab, transform);
            entity.Init(cropData, this, position);
            NotifyCenter.PostNotify(FieldManager.FieldCropPlanted, this, cropData);
        }
    }
Пример #9
0
 public void Plant(CropInformation info, Field parent = null)
 {
     Clear();
     Info            = info;
     HarvestAble     = false;
     Parent          = parent;
     totalGrowthDays = 1;
     TimeManager.Instance.OnDayPassed += UpdateDay;
     GameManager.Crops.TryGetValue(Info, out var crops);
     if (crops != null)
     {
         RuntimeID = Info.ID + "I" + crops.Count.ToString().PadLeft(4);
         crops.Add(this);
     }
     else
     {
         RuntimeID = Info.ID + "I0000";
         GameManager.Crops.Add(Info, new List <Crop>()
         {
             this
         });
     }
 }
Пример #10
0
        private static void TestParsing(string value)
        {
            var cropInformation = CropInformation.Parse(value);

            Assert.AreEqual(value, cropInformation.ToString());
        }
        public override void CreateDefaultConfiguration()
        {
            Crops = new Dictionary <int, string>
            {
                { 745, "2 1 3 3 3/spring/36/400/4/0/true 1 1 5 .02/false/false" },
                { 792, "2 2 3 3 3/spring/41/378/-1/0/true 2 4 8 .2/false/false" },
                { 793, "3 3 3 3 3/summer/42/380/-1/0/true 2 4 8 .2/false/false" },
                { 794, "4 4 4 4 4/fall/43/380/-1/0/true 2 4 8 .2/false/false" },
                { 795, "2 2 2 2 2/spring summer/63/382/-1/0/true 2 4 8 .2/false/false" },
                { 796, "5 5 5 5 5/winter/44/386/-1/0/true 2 4 8 .2/false/false" },
                { 811, "2 3 3 4/spring/45/809/-1/0/true 1 2 8 .2/false/false" },
                { 814, "1 1 1 1/summer/47/813/-1/0/true 1 3 8 .2/false/false" },
                { 816, "2 2 2 2 2/fall/48/815/10/0/true 1 3 8 .2/false/false" },
                { 821, "3 3 3 3 2/fall/49/820/14/0/true 1 3 8 .2/false/false" },
                { 823, "2 2 2 2 3/spring/50/822/11/0/true 1 3 8 .2/false/false" },
                { 831, "2 2 3 3 3/fall/56/826/13/0/true 2 3 8 .2/false/false" },
                { 833, "1 1 2 2 2/spring/52/832/8/0/true 2 3 8 .2/false/false" },
                { 835, "2 2 2 2 3/spring/53/834/11/0/true 1 2 8 .2/false/false" },
                { 837, "1 1 1 1 2/summer fall/54/836/6/0/true 1 3 8 .2/false/false" },
                { 838, "1 1 1 1 1/spring summer/62/839/10/0/true 10 25 8 .2/false/false" },
                { 845, "1 1 2 2 2/fall/59/844/-1/0/true 1 3 8 .5/false/false" },
                { 846, "1 1 1 1 1/winter/64/245/-1/0/true 1 3 8 .2/false/false" },
                { 847, "1 1 1 1 1/winter/65/246/-1/0/true 1 3 8 .2/false/false" },
                { 848, "1 1 1 1 1/winter/57/247/-1/0/true 1 3 8 .2/false/false" },
                { 849, "1 1 1 1 1/winter/58/419/-1/0/true 1 3 8 .2/false/false" },
                { 858, "1 1 1 2 2/summer/55/830/-1/0/true 1 2 8 .6/false/false" },
                { 859, "2 2 2 2/fall/51/824/-1/0/true 1 3 8 .2/false/false" },
                { 860, "1 1 1 1 2/fall/40/811/-1/0/true 1 3 8 .2/false/false" },
                { 863, "1 1 2 2/spring/60/861/-1/0/true 1 2 8 .2/false/false" },
                { 866, "1 2 2 2/summer/61/864/-1/0/true 1 2 8 .2/false/false" },
                { 867, "1 1 1 1 1/spring summer/46/802/5/0/true 2 3 8 .2/false/false" },
                { 871, "2 2 2 2 2/summer/67/870/-1/0/true 2 3 8 .2/false/false" },
                { 872, "1 1 2 2 2/spring/66/869/8/0/true 1 3 8 .2/false/false" },
                { 874, "1 1 2 2/fall/68/873/6/0/true 1 3 8 .2/false/false" },
            }.Select(kv => CropInformation.Parse(kv.Value, kv.Key)).ToList();
            Crops.ForEach(c =>
            {
                if (c.TextureIndex >= 40)
                {
                    c.ResourceIndex = c.TextureIndex - 40;
                }
            });

            Items = new Dictionary <int, string>
            {
                { 792, "Copper Seeds/20/-300/Seeds -74/Plant these to grow copper ore.Grows only in spring. Ore in 13 days." },
                { 793, "Iron Seeds/30/-300/Seeds -74/Plant these to grow iron ore. Grows only in summer. Ore in 15 days." },
                { 794, "Gold Seeds/40/-300/Seeds -74/Plant these to grow gold ore. Grows only in fall. Ore in 20 days." },
                { 795, "Coal Seeds/10/-300/Seeds -74/Plant these to grow coal ore. Grows in spring and summer. Ore in 10 days." },
                { 796, "Iridium Seeds/100/-300/Seeds -74/Plant these to grow iridium ore. Grows only inside the greenhouse. Ore in 25 days." },
                { 797, "Copper Sapling/500/-300/Basic -74/Takes 28 days to produce a copper tree. Bears ore in the spring. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 798, "Iron Sapling/600/-300/Basic -74/Takes 28 days to produce a iron tree. Bears ore in the summer. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 799, "Gold Sapling/800/-300/Basic -74/Takes 28 days to produce a gold tree. Bears ore in the fall. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 800, "Coal Sapling/500/-300/Basic -74/Takes 28 days to produce a coal tree. Bears ore in the spring. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 801, "Iridium Sapling/500/-300/Basic -74/Takes 28 days to produce a iridium tree. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 802, "Beef/80/-300/Seeds -74/Not a good idea to eat it raw. Plant it or cook it!(problably in hot weather)." },
                { 803, "Bacon/70/10/Basic -5/BACON! Maybe it's magical, maybe you should cook it." },
                { 804, "Cooked Beef/150/64/Cooking -7/No vegans allowed./food/0 0 0 0 0 0 0 40 0 1 0/300" },
                { 805, "Cooked Bacon/200/64/Cooking -7/To hell with eating healthy./food/0 0 0 0 0 0 0 40 0 1 0/300" },
                { 806, "Bacon Sapling/60/-300/Basic -74/Takes 28 days to grow into a bacon tree. Yeah a BACON TREE!! Bears BACON in the summer. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 807, "Cocoa Sapling/30/-300/Basic -74/Takes 28 days to produce a cocoa tree. Bears fruit in the spring. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 808, "Cocoa/145/-300/Basic -75/Beans used to make famous treads." },
                { 809, "Violet /70/-300/Basic -16/Beautiful purple thing, better not eat it." },
                { 811, "Violet Seeds/10/-300/Seeds -74/Seeds to grow vioet flower. Grows in spring. Takes 8 days to produce flowers." },
                { 812, "Olive/250/-300/Basic -79/Find some good cheese and a nice beer to eat these." },
                { 813, "Lettuce /65/-300/Basic -75/Its round, its green.It is lettuce!." },
                { 814, "Lettuce Seed/5/-300/Seeds -74/Grows in summer, 4 days." },
                { 815, "Bell Pepper/90/-300/Basic -79/Not as spicy, still really delicious!" },
                { 816, "Red Pepper Seeds/10/-300/Seeds -74/Plant these to grow red pepper. Grows only in fall. Pepper in 10 days." },
                { 817, "Lemon/200/-300/Basic -79/The most sour of the sour fruits." },
                { 818, "Papaya/183/-300/Basic -79/Sweet fruit used most to make deserts. Very healthy too!." },
                { 819, "Papaya Sapling/12/-300/Basic -74/Takes 28 days to produce a papaya tree. Bears fruit in the summer. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 820, "Watermelon/175/-300/Basic -79/Man, this is heavier than I tought!" },
                { 821, "Watermelon Seed/20/-300/Seeds -74/Grows in fall.Takes 14 days to produce." },
                { 822, "Cannary Melon/120/-300/Basic -79/It's not that heavy..." },
                { 823, "Cannary Melon Seed/6/-300/Seeds -74/Grows in spring.Takes 11 days to produce." },
                { 824, "Onion/117/-300/Basic -79/Here comes the bad breath! Grows in fall,8 days" },
                { 825, "Banana/245/-300/Basic -79/If you happen to find a monkey you can feed him this!" },
                { 826, "Money/100/-300/Basic/Money makes the world spin." },
                { 827, "Olive Sapling/15/-300/Basic -74/Takes 28 days to produce a olive tree. Bears fruit in the spring. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 828, "Lemon Sapling/15/-300/Basic -74/Takes 28 days to produce a lemon tree. Bears fruit in the spring. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 829, "Banana Sapling/15/-300/Basic -74/Takes 28 days to produce a banana tree. Bears fruit in the summer. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 830, "Cassava/80/-300/Basic -79/Grows in summer, 7 days. Not that famous, but still delicious when fried!" },
                { 831, "Money Seeds/10/-300/Seeds -74/Plant these in fall. Takes 13 days to mature. Have you ever dreamed about doing this??" },
                { 832, "Pineaple/83/-300/Basic -79/The king of the fruits!." },
                { 833, "Pineaple Seeds/20/-300/Seeds -74/Plant these in spring. Takes 8 days to mature." },
                { 834, "Cucumber /98/-300/Basic -75/ Don't you even think about doing it!" },
                { 835, "Cucumber Seeds/5/-300/Seeds -74/Plant these in spring. Takes 11 days to mature." },
                { 836, "Cotton/64/-300/Basic/Plant these soldier!" },
                { 837, "Cotton Seeds/30/-300/Seeds -74/Plant these in summer and fall. Takes 6 days to produce." },
                { 838, "Rice Seeds/8/-300/Seeds -74/Plant these in spring and summer. Takes 5 days to produce." },
                { 839, "Rice/7/-300/Basic -75/It is rainning rice!" },
                { 840, "Dragonfruit/160/-300/Basic -79/A fruit that looks like a dragon egg" },
                { 841, "Dragonfruit Sapling/12/-300/Basic -74/Takes 28 days to produce a dragonfruit tree. Bears fruit in the summer. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 842, "Avocado/170/-300/Basic -79/Bear Grills said this is the best fruit..." },
                { 843, "Avocado Sapling/14/-300/Basic -74/Takes 28 days to produce an avocado tree. Bears fruit in the summer. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 844, "Purple Sweet Potato/86/-300/Basic -79/Eat this with chicken to become a bodybuilder!" },
                { 845, "Purple Sweet Potato Seeds/16/-300/Seeds -74/Plant these in fall. Takes 8 days to mature." },
                { 846, "Sugar Seeds/11/-300/Seeds -74/Plant these in greenhouse. Takes 5 days to mature. Confusing but sweet..." },
                { 847, "Flour Seeds/11/-300/Seeds -74/Plant these in the greenhouse. Takes 5 days to mature." },
                { 848, "Oil Seeds/11/-300/Seeds -74/Plant these in the greenhouse. Takes 5 days to mature." },
                { 849, "Vinegar Seeds/11/-300/Seeds -74/Plant these in the greenhouse. Takes 5 days to mature." },
                { 850, "Fig/154/-300/Basic -79/A really swwet fruit." },
                { 851, "Fig Sapling/35/-300/Basic -74/Takes 28 days to produce a fig tree. Bears fruit in the winter. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 852, "Pear/178/-300/Basic -79/The sexy fruit." },
                { 853, "Pear Sapling/35/-300/Basic -74/Takes 28 days to produce a pear tree. Bears fruit in the winter. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 854, "Persimmon/166/-300/Basic -79/Not the same as tomato." },
                { 855, "Persimmon Sapling/35/-300/Basic -74/Takes 28 days to produce a persimmon tree. Bears fruit in the winter. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 856, "Lime Sapling/35/-300/Basic -74/Takes 28 days to produce a lime tree. Bears fruit in the spring. Only grows if the 8 surrounding \"tiles\" are empty." },
                { 857, "Lime/160/-300/Basic -79/A different colored lemon." },
                { 858, "Cassava Seed/20/-300/Seeds -74/Grows in summer.Takes 7 days to mature." },
                { 859, "Onion Seed/6/-300/Seeds -74/Grows in fall.Takes 8 days to produce." },
                { 860, "Carrot Seed/6/-300/Seeds -74/Grows in fall.Takes 6 days to produce." },
                { 861, "Pink Cat /100/-300/Basic -16/A plant native to the far off Mineral Town. It is known for its minty scent." },
                { 863, "Pink Cat Seed/6/-300/Seeds -74/Grows in spring.Takes 6 days to produce." },
                { 864, "Blue Mist /160/-300/Basic -16/Often a popular present for young ladies, these star-shaped blossoms bloom on the hillsides." },
                { 866, "Blue Mist Seed/6/-300/Seeds -74/Grows in ssummer.Takes 7 days to produce." },
                { 867, "Beef Seeds/3/-300/Seeds -74/Plant these to grow beef crop. Grows in summer and spring. Meat in 5 days." },
                { 868, "Carrot/60/-300/Basic -79/Grows in fall, 6 days. Maybe you could try to feed it to a rabbit..." },
                { 869, "Coffee Grains /75/-300/Basic -16/Need. To. Stay. Awoken." },
                { 870, "Sugar Cane /100/-300/Basic -75/ Eat all the sugar!!" },
                { 871, "Sugar Cane Seeds/11/-300/Seeds -74/Plant these in the summer. Takes 10 days to mature." },
                { 872, "Coffee Seeds/11/-300/Seeds -74/Plant these in the spring. Takes 8 days to mature." },
                { 873, "Peanut /60/-300/Basic -75/ Hard shell, delicious inside!" },
                { 874, "Peanut Seeds/11/-300/Seeds -74/Plant these in the fall. Takes 6 days to mature." },
            }.Select(kv => ItemInformation.Parse(kv.Value, kv.Key)).ToList();
            Items.ForEach(c =>
            {
                if (c.ID >= 792)
                {
                    c.ResourceIndex = c.ID - 792;
                }
            });

            Trees = new Dictionary <int, string>
            {
                { 797, "1/spring/378/3000" },
                { 798, "2/summer/380/3000" },
                { 799, "3/fall/384/3000" },
                { 800, "4/spring/382/3000" },
                { 801, "0/winter/386/3000" },
                { 806, "1/summer/803/3000" },
                { 807, "2/spring/808/3000" },
                { 819, "3/summer/818/3000" },
                { 827, "4/spring/812/3000" },
                { 828, "5/spring/817/3000" },
                { 829, "6/summer/825/3000" },
                { 841, "0/summer/840/3000" },
                { 843, "1/winter/842/3000" },
                { 851, "2/summer/850/3000" },
                { 853, "3/winter/852/3000" },
                { 855, "4/winter/854/3000" },
                { 856, "0/spring/857/3000" },
            }.Select(kv => TreeInformation.Parse(kv.Value, kv.Key)).ToList();
        }
Пример #12
0
    void HandlingStageList()
    {
        stageList = new ReorderableList(serializedObject, stages, false, true, true, true);

        stageList.drawElementCallback = (rect, index, isActive, isFocused) =>
        {
            serializedObject.Update();
            EditorGUI.BeginChangeCheck();
            SerializedProperty cropStage        = stages.GetArrayElementAtIndex(index);
            SerializedProperty lastingDays      = cropStage.FindPropertyRelative("lastingDays");
            SerializedProperty repeatTimes      = cropStage.FindPropertyRelative("repeatTimes");
            SerializedProperty indexToReturn    = cropStage.FindPropertyRelative("indexToReturn");
            SerializedProperty gatherType       = cropStage.FindPropertyRelative("gatherType");
            SerializedProperty gatherTime       = cropStage.FindPropertyRelative("gatherTime");
            SerializedProperty lootPrefab       = cropStage.FindPropertyRelative("lootPrefab");
            SerializedProperty productItems     = cropStage.FindPropertyRelative("productItems");
            SerializedProperty graph            = cropStage.FindPropertyRelative("graph");
            ReorderableList    productItemsList = null;
            string             name             = "[阶段" + index + "]";
            switch (crop.Stages[index].Stage)
            {
            case CropStages.Seed:
                name += "种子期";
                break;

            case CropStages.Seedling:
                name += "幼苗期";
                break;

            case CropStages.Growing:
                name += "成长期";
                break;

            case CropStages.Flowering:
                name += "开花期";
                break;

            case CropStages.Bearing:
                name += "结果期";
                break;

            case CropStages.Maturity:
                name += "成熟期";
                break;

            case CropStages.OverMature:
                name += "过熟期";
                break;

            case CropStages.Harvested:
                name += "收割期";
                break;

            case CropStages.Withered:
                name += "枯萎期";
                break;

            case CropStages.Decay:
                name += "腐朽期";
                break;
            }
            EditorGUI.PropertyField(new Rect(rect.x + 8, rect.y, rect.width / 4 - 8, lineHeight), cropStage, new GUIContent(name));
            EditorGUI.LabelField(new Rect(rect.x + rect.width - 166, rect.y, 30, lineHeight), "持续");
            EditorGUI.PropertyField(new Rect(rect.x + rect.width - 138, rect.y, 26, lineHeight), lastingDays, new GUIContent(string.Empty));
            if (lastingDays.intValue < 1)
            {
                lastingDays.intValue = 1;
            }
            EditorGUI.LabelField(new Rect(rect.x + rect.width - 110, rect.y, 16, lineHeight), "天");
            EditorGUI.LabelField(new Rect(rect.x + rect.width - 86, rect.y, 40, lineHeight), "可收割");
            EditorGUI.PropertyField(new Rect(rect.x + rect.width - 46, rect.y, 26, lineHeight), repeatTimes, new GUIContent(string.Empty));
            if (repeatTimes.intValue < 0)
            {
                repeatTimes.intValue = 0;
            }
            EditorGUI.LabelField(new Rect(rect.x + rect.width - 18, rect.y, 16, lineHeight), "次");
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            int lineCount = 1;
            graph.objectReferenceValue = EditorGUI.ObjectField(new Rect(rect.x - rect.width + lineHeight * 4.5f, rect.y + lineHeightSpace * lineCount, rect.width - 8, lineHeight * 3.5f),
                                                               string.Empty, graph.objectReferenceValue as Sprite, typeof(Sprite), false);
            if (repeatTimes.intValue > 0)
            {
                EditorGUI.PropertyField(new Rect(rect.x - 4 + lineHeight * 4.5f, rect.y + lineHeightSpace * lineCount, rect.width - lineHeight * 4f, lineHeight), gatherType, new GUIContent("采集方式"));
                lineCount++;
                EditorGUI.PropertyField(new Rect(rect.x - 4 + lineHeight * 4.5f, rect.y + lineHeightSpace * lineCount, rect.width - lineHeight * 4f, lineHeight), gatherTime, new GUIContent("采集耗时(秒)"));
                lineCount++;
                EditorGUI.PropertyField(new Rect(rect.x - 4 + lineHeight * 4.5f, rect.y + lineHeightSpace * lineCount, rect.width - lineHeight * 4f, lineHeight), lootPrefab, new GUIContent("掉落物预制件"));
                lineCount++;
            }
            if (cropStage.isExpanded)
            {
                serializedObject.Update();
                EditorGUI.BeginChangeCheck();
                if (repeatTimes.intValue > 1 && index > 0)
                {
                    EditorGUI.IntSlider(new Rect(rect.x + 8, rect.y + lineHeightSpace * lineCount, rect.width - 8, lineHeight),
                                        indexToReturn, 0, index - 1, new GUIContent("收割后返回阶段"));
                    lineCount++;
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
                if (repeatTimes.intValue > 0)
                {
                    serializedObject.Update();
                    EditorGUI.BeginChangeCheck();
                    EditorGUI.PropertyField(new Rect(rect.x + 16, rect.y + lineHeightSpace * lineCount, rect.width - 16, lineHeight), productItems,
                                            new GUIContent("产出道具" + (productItems.isExpanded ? string.Empty : ("\t\t" + (productItems.arraySize < 1 ? "无" : "数量:" + productItems.arraySize)))));
                    lineCount++;
                    if (EditorGUI.EndChangeCheck())
                    {
                        serializedObject.ApplyModifiedProperties();
                    }
                    if (productItems.isExpanded)
                    {
                        productItemsLists.TryGetValue(crop.Stages[index], out productItemsList);
                        if (productItemsList == null)
                        {
                            productItemsList = new ReorderableList(cropStage.serializedObject, productItems, true, true, true, true);
                            productItemsLists.Add(crop.Stages[index], productItemsList);

                            productItemsList.drawElementCallback = (_rect, _index, _isActive, _isForcus) =>
                            {
                                cropStage.serializedObject.Update();
                                SerializedProperty itemInfo = productItems.GetArrayElementAtIndex(_index);
                                var productItem             = crop.Stages[index].ProductItems[_index];
                                if (productItem != null && productItem.Item != null)
                                {
                                    EditorGUI.PropertyField(new Rect(_rect.x + 8, _rect.y, _rect.width / 2, lineHeight), itemInfo, new GUIContent(productItem.ItemName));
                                }
                                else
                                {
                                    EditorGUI.PropertyField(new Rect(_rect.x + 8, _rect.y, _rect.width / 2, lineHeight), itemInfo, new GUIContent("(空)"));
                                }
                                EditorGUI.BeginChangeCheck();
                                SerializedProperty item             = itemInfo.FindPropertyRelative("item");
                                SerializedProperty amount           = itemInfo.FindPropertyRelative("amount");
                                SerializedProperty dropRate         = itemInfo.FindPropertyRelative("dropRate");
                                SerializedProperty onlyDropForQuest = itemInfo.FindPropertyRelative("onlyDropForQuest");
                                SerializedProperty binedQuest       = itemInfo.FindPropertyRelative("bindedQuest");
                                EditorGUI.PropertyField(new Rect(_rect.x + _rect.width / 2f, _rect.y, _rect.width / 2f, lineHeight),
                                                        item, new GUIContent(string.Empty));
                                if (itemInfo.isExpanded)
                                {
                                    int _lineCount = 1;
                                    EditorGUI.PropertyField(new Rect(_rect.x, _rect.y + lineHeightSpace * _lineCount, _rect.width, lineHeight),
                                                            amount, new GUIContent("最大掉落数量"));
                                    if (amount.intValue < 1)
                                    {
                                        amount.intValue = 1;
                                    }
                                    _lineCount++;
                                    EditorGUI.PropertyField(new Rect(_rect.x, _rect.y + lineHeightSpace * _lineCount, _rect.width, lineHeight),
                                                            dropRate, new GUIContent("掉落概率百分比"));
                                    if (dropRate.floatValue < 0)
                                    {
                                        dropRate.floatValue = 0.0f;
                                    }
                                    _lineCount++;
                                    EditorGUI.PropertyField(new Rect(_rect.x, _rect.y + lineHeightSpace * _lineCount, _rect.width, lineHeight),
                                                            onlyDropForQuest, new GUIContent("只在进行任务时产出"));
                                    _lineCount++;
                                    if (onlyDropForQuest.boolValue)
                                    {
                                        EditorGUI.PropertyField(new Rect(_rect.x, _rect.y + lineHeightSpace * _lineCount, _rect.width, lineHeight),
                                                                binedQuest, new GUIContent("相关任务"));
                                        _lineCount++;
                                        if (binedQuest.objectReferenceValue)
                                        {
                                            EditorGUI.LabelField(new Rect(_rect.x, _rect.y + lineHeightSpace * _lineCount, _rect.width, lineHeight), "任务名称",
                                                                 (binedQuest.objectReferenceValue as Quest).Title);
                                            _lineCount++;
                                        }
                                    }
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    cropStage.serializedObject.ApplyModifiedProperties();
                                }
                            };

                            productItemsList.elementHeightCallback = (int _index) =>
                            {
                                int _lineCount = 1;
                                if (productItems.GetArrayElementAtIndex(_index).isExpanded)
                                {
                                    _lineCount += 3;//数量、百分比、只在
                                    if (crop.Stages[index].ProductItems[_index].OnlyDropForQuest)
                                    {
                                        _lineCount++;//任务
                                        if (crop.Stages[index].ProductItems[_index].BindedQuest)
                                        {
                                            _lineCount++;//任务标题
                                        }
                                    }
                                }
                                return(_lineCount * lineHeightSpace);
                            };

                            productItemsList.onAddCallback = (_list) =>
                            {
                                cropStage.serializedObject.Update();
                                EditorGUI.BeginChangeCheck();
                                crop.Stages[index].ProductItems.Add(new DropItemInfo()
                                {
                                    Amount = 1, DropRate = 100.0f
                                });
                                if (EditorGUI.EndChangeCheck())
                                {
                                    cropStage.serializedObject.ApplyModifiedProperties();
                                }
                            };

                            productItemsList.onRemoveCallback = (_list) =>
                            {
                                cropStage.serializedObject.Update();
                                EditorGUI.BeginChangeCheck();
                                if (EditorUtility.DisplayDialog("删除", "确定删除这个产出道具吗?", "确定", "取消"))
                                {
                                    crop.Stages[index].ProductItems.RemoveAt(_list.index);
                                }
                                if (EditorGUI.EndChangeCheck())
                                {
                                    cropStage.serializedObject.ApplyModifiedProperties();
                                }
                            };

                            productItemsList.drawHeaderCallback = (_rect) =>
                            {
                                int notCmpltCount = crop.Stages[index].ProductItems.FindAll(x => !x.Item).Count;
                                EditorGUI.LabelField(_rect, "产出道具列表", "数量:" + crop.Stages[index].ProductItems.Count + (notCmpltCount > 0 ? "未补全:" + notCmpltCount : string.Empty));
                            };

                            productItemsList.drawNoneElementCallback = (_rect) =>
                            {
                                EditorGUI.LabelField(_rect, "空列表");
                            };
                        }
                        cropStage.serializedObject.Update();
                        productItemsList.DoList(new Rect(rect.x + 8, rect.y + lineHeightSpace * lineCount, rect.width - 8, lineHeight * (productItems.arraySize + 1)));
                        cropStage.serializedObject.ApplyModifiedProperties();
                    }
                }
            }
        };

        stageList.elementHeightCallback = (index) =>
        {
            int   lineCount                 = 1;
            float listHeight                = 0;
            SerializedProperty cropStage    = stages.GetArrayElementAtIndex(index);
            SerializedProperty productItems = cropStage.FindPropertyRelative("productItems");
            lineCount += 3;
            if (cropStage.isExpanded)
            {
                if (cropStage.FindPropertyRelative("repeatTimes").intValue > 1 && index > 0)
                {
                    lineCount++;
                }
                if (cropStage.FindPropertyRelative("repeatTimes").intValue > 0)
                {
                    lineCount += 1;
                    if (productItems.isExpanded)
                    {
                        if (productItemsLists.TryGetValue(crop.Stages[index], out var productItemList))
                        {
                            listHeight += productItemList.GetHeight();
                        }
                    }
                }
            }
            return(lineHeightSpace * lineCount + listHeight);
        };

        stageList.onRemoveCallback = (list) =>
        {
            if (crop.Stages.Count < 10)
            {
                serializedObject.Update();
                EditorGUI.BeginChangeCheck();
                if (EditorUtility.DisplayDialog("删除", "确定删除这个阶段吗?", "确定", "取消"))
                {
                    serializedObject.FindProperty("stages").DeleteArrayElementAtIndex(list.index);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }
        };

        stageList.onAddDropdownCallback = (_rect, _list) =>
        {
            GenericMenu menu = new GenericMenu();
            if (!crop.Stages.Exists(s => s.Stage == CropStages.Seed))
            {
                menu.AddItem(new GUIContent("种子期"), false, OnAddOption, CropStages.Seed);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStages.Seedling))
            {
                menu.AddItem(new GUIContent("幼苗期"), false, OnAddOption, CropStages.Seedling);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStages.Growing))
            {
                menu.AddItem(new GUIContent("成长期"), false, OnAddOption, CropStages.Growing);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStages.Flowering))
            {
                menu.AddItem(new GUIContent("开花期"), false, OnAddOption, CropStages.Flowering);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStages.Bearing))
            {
                menu.AddItem(new GUIContent("结果期"), false, OnAddOption, CropStages.Bearing);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStages.Maturity))
            {
                menu.AddItem(new GUIContent("成熟期"), false, OnAddOption, CropStages.Maturity);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStages.OverMature))
            {
                menu.AddItem(new GUIContent("过熟期"), false, OnAddOption, CropStages.OverMature);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStages.Harvested))
            {
                menu.AddItem(new GUIContent("收割期"), false, OnAddOption, CropStages.Harvested);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStages.Withered))
            {
                menu.AddItem(new GUIContent("枯萎期"), false, OnAddOption, CropStages.Withered);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStages.Decay))
            {
                menu.AddItem(new GUIContent("腐朽期"), false, OnAddOption, CropStages.Decay);
            }
            menu.DropDown(_rect);

            void OnAddOption(object data)
            {
                var cropStage = (CropStages)data;

                crop.Stages.Add(new CropStage(1, cropStage));
                Dictionary <CropStage, CropStage> returnStages = new Dictionary <CropStage, CropStage>();

                for (int i = 0; i < crop.Stages.Count; i++)
                {
                    returnStages.Add(crop.Stages[i], crop.Stages[crop.Stages[i].IndexToReturn]);
                }
                crop.Stages.Sort((x, y) =>
                {
                    if (x.Stage < y.Stage)
                    {
                        return(-1);
                    }
                    else if (x.Stage > y.Stage)
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                });
                serializedObject.Update();
                EditorGUI.BeginChangeCheck();
                foreach (var returnStage in returnStages)
                {
                    SerializedProperty stage = stages.GetArrayElementAtIndex(crop.Stages.IndexOf(returnStage.Key));
                    stage.FindPropertyRelative("indexToReturn").intValue = crop.Stages.IndexOf(returnStage.Value);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }
        };

        stageList.drawHeaderCallback = (rect) =>
        {
            EditorGUI.LabelField(rect, "阶段列表");
        };

        stageList.drawNoneElementCallback = (rect) =>
        {
            EditorGUI.LabelField(rect, "空列表");
        };
    }

    string GetAutoID()
    {
        string newID = string.Empty;

        CropInformation[] crops = Resources.LoadAll <CropInformation>("");
        for (int i = 1; i < 1000; i++)
        {
            newID = "CROP" + i.ToString().PadLeft(3, '0');
            if (!Array.Exists(crops, x => x.ID == newID))
            {
                break;
            }
        }
        return(newID);
    }

    bool ExistsID()
    {
        CropInformation[] crops = Resources.LoadAll <CropInformation>("");

        CropInformation find = Array.Find(crops, x => x.ID == _ID.stringValue);

        if (!find)
        {
            return(false);      //若没有找到,则ID可用
        }
        //找到的对象不是原对象 或者 找到的对象是原对象且同ID超过一个 时为true
        return(find != crop || (find == crop && Array.FindAll(crops, x => x.ID == _ID.stringValue).Length > 1));
    }
}
Пример #13
0
    void HandlingStageList()
    {
        stageList = new ReorderableList(serializedObject, stages, false, true, true, true);

        stageList.drawElementCallback = (rect, index, isActive, isFocused) =>
        {
            serializedObject.UpdateIfRequiredOrScript();
            EditorGUI.BeginChangeCheck();
            SerializedProperty cropStage     = stages.GetArrayElementAtIndex(index);
            SerializedProperty lastingDays   = cropStage.FindPropertyRelative("lastingDays");
            SerializedProperty repeatTimes   = cropStage.FindPropertyRelative("repeatTimes");
            SerializedProperty indexToReturn = cropStage.FindPropertyRelative("indexToReturn");
            SerializedProperty gatherInfo    = cropStage.FindPropertyRelative("gatherInfo");
            SerializedProperty graph         = cropStage.FindPropertyRelative("graph");
            string             name          = "[阶段" + index + "]";
            switch (crop.Stages[index].Stage)
            {
            case CropStageType.Seed:
                name += "种子期";
                break;

            case CropStageType.Seedling:
                name += "幼苗期";
                break;

            case CropStageType.Growing:
                name += "成长期";
                break;

            case CropStageType.Flowering:
                name += "开花期";
                break;

            case CropStageType.Bearing:
                name += "结果期";
                break;

            case CropStageType.Maturity:
                name += "成熟期";
                break;

            case CropStageType.OverMature:
                name += "过熟期";
                break;

            case CropStageType.Harvested:
                name += "收割期";
                break;

            case CropStageType.Withered:
                name += "枯萎期";
                break;

            case CropStageType.Decay:
                name += "腐朽期";
                break;
            }
            EditorGUI.PropertyField(new Rect(rect.x + 8, rect.y, rect.width / 4 - 8, lineHeight), cropStage, new GUIContent(name));
            EditorGUI.LabelField(new Rect(rect.x + rect.width - 166, rect.y, 30, lineHeight), "持续");
            EditorGUI.PropertyField(new Rect(rect.x + rect.width - 138, rect.y, 26, lineHeight), lastingDays, new GUIContent(string.Empty));
            if (lastingDays.intValue < 1)
            {
                if (index == stages.arraySize - 1)
                {
                    lastingDays.intValue = -1;
                }
                else
                {
                    lastingDays.intValue = 1;
                }
            }
            EditorGUI.LabelField(new Rect(rect.x + rect.width - 110, rect.y, 16, lineHeight), "天");
            EditorGUI.LabelField(new Rect(rect.x + rect.width - 86, rect.y, 40, lineHeight), "可收割");
            EditorGUI.PropertyField(new Rect(rect.x + rect.width - 46, rect.y, 26, lineHeight), repeatTimes, new GUIContent(string.Empty));
            if (repeatTimes.intValue < 0)
            {
                repeatTimes.intValue = -1;
            }
            EditorGUI.LabelField(new Rect(rect.x + rect.width - 18, rect.y, 16, lineHeight), "次");
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
            if (cropStage.isExpanded)
            {
                int lineCount = 1;
                serializedObject.UpdateIfRequiredOrScript();
                EditorGUI.BeginChangeCheck();
                graph.objectReferenceValue = EditorGUI.ObjectField(new Rect(rect.x - rect.width + lineHeight * 4.2f, rect.y + lineHeightSpace * lineCount, rect.width - 8, lineHeight * 3.2f),
                                                                   string.Empty, graph.objectReferenceValue, typeof(Sprite), false);
                if (repeatTimes.intValue != 0)
                {
                    if (!gatherInfo.objectReferenceValue || gatherInfo.objectReferenceValue && !AssetDatabase.IsSubAsset(gatherInfo.objectReferenceValue))
                    {
                        EditorGUI.PropertyField(new Rect(rect.x - 4 + lineHeight * 4.5f, rect.y + lineHeightSpace * lineCount, rect.width - lineHeight * 4f, lineHeight), gatherInfo, new GUIContent("对应采集物信息"));
                        lineCount++;
                    }
                    else if (AssetDatabase.IsSubAsset(gatherInfo.objectReferenceValue))
                    {
                        EditorGUI.LabelField(new Rect(rect.x - 4 + lineHeight * 4.5f, rect.y + lineHeightSpace * lineCount, rect.width - lineHeight * 4f, lineHeight),
                                             $"对应采集物信息{((gatherInfo.objectReferenceValue as ResourceInformation).IsValid ? string.Empty : "(未补全)")}");
                        lineCount++;
                    }
                    if (gatherInfo.objectReferenceValue)
                    {
                        if (GUI.Button(new Rect(rect.x - 4 + lineHeight * 4.5f, rect.y + lineHeightSpace * lineCount, rect.width - lineHeight * 4f, lineHeight), "编辑"))
                        {
                            EditorUtility.OpenPropertyEditor(gatherInfo.objectReferenceValue);
                        }
                        lineCount++;
                        if (AssetDatabase.IsSubAsset(gatherInfo.objectReferenceValue))
                        {
                            if (GUI.Button(new Rect(rect.x - 4 + lineHeight * 4.5f, rect.y + lineHeightSpace * lineCount, rect.width - lineHeight * 4f, lineHeight), "删除"))
                            {
                                AssetDatabase.RemoveObjectFromAsset(gatherInfo.objectReferenceValue);
                                gatherInfo.objectReferenceValue = null;
                            }
                            lineCount++;
                        }
                    }
                    else if (GUI.Button(new Rect(rect.x - 4 + lineHeight * 4.5f, rect.y + lineHeightSpace * lineCount, rect.width - lineHeight * 4f, lineHeight), "新建"))
                    {
                        ResourceInformation infoInstance = CreateInstance <ResourceInformation>();
                        infoInstance.SetBaseName("resource info");
                        AssetDatabase.AddObjectToAsset(infoInstance, target);

                        gatherInfo.objectReferenceValue = infoInstance;
                        SerializedObject   gInfoObj = new SerializedObject(gatherInfo.objectReferenceValue);
                        SerializedProperty _ID      = gInfoObj.FindProperty("_ID");
                        SerializedProperty _name    = gInfoObj.FindProperty("_name");
                        _ID.stringValue   = this._ID.stringValue + "S" + index;
                        _name.stringValue = this._name.stringValue;
                        gInfoObj.ApplyModifiedProperties();

                        EditorUtility.OpenPropertyEditor(infoInstance);
                    }
                    lineCount++;
                }
                if ((repeatTimes.intValue < 0 || repeatTimes.intValue > 1) && index > 0)
                {
                    lineCount = 4;
                    EditorGUI.IntSlider(new Rect(rect.x + 8, rect.y + lineHeightSpace * lineCount, rect.width - 8, lineHeight),
                                        indexToReturn, 0, index - 1, new GUIContent("收割后返回阶段"));
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }
        };

        stageList.elementHeightCallback = (index) =>
        {
            int   lineCount                = 1;
            float listHeight               = 0;
            SerializedProperty cropStage   = stages.GetArrayElementAtIndex(index);
            SerializedProperty gatherInfo  = cropStage.FindPropertyRelative("gatherInfo");
            SerializedProperty repeatTimes = cropStage.FindPropertyRelative("repeatTimes");
            if (cropStage.isExpanded)
            {
                lineCount += 3;//空白
                if ((repeatTimes.intValue < 0 || repeatTimes.intValue > 1) && index > 0)
                {
                    lineCount++;
                }
            }
            return(lineHeightSpace * lineCount + listHeight);
        };

        stageList.onRemoveCallback = (list) =>
        {
            if (crop.Stages.Count < 10)
            {
                serializedObject.UpdateIfRequiredOrScript();
                EditorGUI.BeginChangeCheck();
                if (EditorUtility.DisplayDialog("删除", "确定删除这个阶段吗?", "确定", "取消"))
                {
                    serializedObject.FindProperty("stages").DeleteArrayElementAtIndex(list.index);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }
        };

        stageList.onAddDropdownCallback = (_rect, _list) =>
        {
            GenericMenu menu = new GenericMenu();
            if (!crop.Stages.Exists(s => s.Stage == CropStageType.Seed))
            {
                menu.AddItem(new GUIContent("种子期"), false, OnAddOption, CropStageType.Seed);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStageType.Seedling))
            {
                menu.AddItem(new GUIContent("幼苗期"), false, OnAddOption, CropStageType.Seedling);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStageType.Growing))
            {
                menu.AddItem(new GUIContent("成长期"), false, OnAddOption, CropStageType.Growing);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStageType.Flowering))
            {
                menu.AddItem(new GUIContent("开花期"), false, OnAddOption, CropStageType.Flowering);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStageType.Bearing))
            {
                menu.AddItem(new GUIContent("结果期"), false, OnAddOption, CropStageType.Bearing);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStageType.Maturity))
            {
                menu.AddItem(new GUIContent("成熟期"), false, OnAddOption, CropStageType.Maturity);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStageType.OverMature))
            {
                menu.AddItem(new GUIContent("过熟期"), false, OnAddOption, CropStageType.OverMature);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStageType.Harvested))
            {
                menu.AddItem(new GUIContent("收割期"), false, OnAddOption, CropStageType.Harvested);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStageType.Withered))
            {
                menu.AddItem(new GUIContent("枯萎期"), false, OnAddOption, CropStageType.Withered);
            }
            if (!crop.Stages.Exists(s => s.Stage == CropStageType.Decay))
            {
                menu.AddItem(new GUIContent("腐朽期"), false, OnAddOption, CropStageType.Decay);
            }
            menu.DropDown(_rect);

            void OnAddOption(object data)
            {
                var cropStage = (CropStageType)data;

                crop.Stages.Add(new CropStage(1, cropStage));
                Dictionary <CropStage, CropStage> returnStages = new Dictionary <CropStage, CropStage>();

                for (int i = 0; i < crop.Stages.Count; i++)
                {
                    returnStages.Add(crop.Stages[i], crop.Stages[crop.Stages[i].IndexToReturn]);
                }
                crop.Stages.Sort((x, y) =>
                {
                    if (x.Stage < y.Stage)
                    {
                        return(-1);
                    }
                    else if (x.Stage > y.Stage)
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                });
                serializedObject.UpdateIfRequiredOrScript();
                EditorGUI.BeginChangeCheck();
                foreach (var returnStage in returnStages)
                {
                    SerializedProperty stage = stages.GetArrayElementAtIndex(crop.Stages.IndexOf(returnStage.Key));
                    stage.FindPropertyRelative("indexToReturn").intValue = crop.Stages.IndexOf(returnStage.Value);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    serializedObject.ApplyModifiedProperties();
                }
            }
        };

        stageList.drawHeaderCallback = (rect) =>
        {
            EditorGUI.LabelField(rect, "阶段列表");
        };

        stageList.drawNoneElementCallback = (rect) =>
        {
            EditorGUI.LabelField(rect, "空列表");
        };
    }

    string GetAutoID()
    {
        string newID = string.Empty;

        CropInformation[] crops = Resources.LoadAll <CropInformation>("Configuration");
        for (int i = 1; i < 1000; i++)
        {
            newID = "CROP" + i.ToString().PadLeft(3, '0');
            if (!Array.Exists(crops, x => x.ID == newID))
            {
                break;
            }
        }
        return(newID);
    }

    bool ExistsID()
    {
        CropInformation[] crops = Resources.LoadAll <CropInformation>("Configuration");

        CropInformation find = Array.Find(crops, x => x.ID == _ID.stringValue);

        if (!find)
        {
            return(false);      //若没有找到,则ID可用
        }
        //找到的对象不是原对象 或者 找到的对象是原对象且同ID超过一个 时为true
        return(find != crop || (find == crop && Array.FindAll(crops, x => x.ID == _ID.stringValue).Length > 1));
    }
}