Ejemplo n.º 1
0
        void OnGUI()
        {
            GUIStyle boxStyle = new GUIStyle("box");

            var width  = position.size.x - boxStyle.border.horizontal;
            var height = position.size.y - boxStyle.border.vertical;

            var innerBoxWidth  = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal);
            var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical);

            MyGUIExtend.Instance.ToolbarButton(new Dictionary <string, Action>
            {
                {
                    "读取", loadWeapon
                },
                {
                    "保存", saveWeapon
                },
                {
                    "制作当前预制体", CreatCurrentPrefab
                }
            });


            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height));

            MyGUIExtend.Instance.Foldout("WeaponEditor", "路径信息", (() =>
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(weaponDataFile);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath);
                if (MyGUI.Button("载入表格"))
                {
                    EditorTools.AnalyzeExcelToDic(excelPath, dic =>
                    {
                        EquipType equipType = (EquipType)Convert.ToInt32(dic["EquipType"]);
                        bool newWeaponData = true;
                        switch (equipType)
                        {
                        case EquipType.Lswd:
                            break;

                        case EquipType.Shield:
                            break;

                        case EquipType.Swd:
                            break;

                        case EquipType.Sswd:
                            break;

                        case EquipType.Saxe:
                            break;

                        case EquipType.Blunt:
                            break;

                        case EquipType.Katana:
                            break;

                        case EquipType.Bow:
                            break;

                        case EquipType.Spear:
                            break;

                        default:
                            newWeaponData = false;
                            break;
                        }
                        if (newWeaponData)
                        {
                            WeaponData NewWeaponData = new WeaponData();
                            foreach (var item in dic)
                            {
                                switch (item.Key)
                                {
                                case "id":
                                    NewWeaponData.id = Convert.ToString(item.Value);
                                    break;

                                case "IconName":
                                    NewWeaponData.icon = Convert.ToString(item.Value);
                                    break;

                                case "name":
                                    NewWeaponData.name = Convert.ToString(item.Value);
                                    break;

                                case "Lv":
                                    NewWeaponData.level = Convert.ToInt32(item.Value);
                                    break;

                                case "desc":
                                    NewWeaponData.desc = Convert.ToString(item.Value);
                                    break;

                                case "Hp":
                                    NewWeaponData.attrData.hpMax = Convert.ToSingle(item.Value);
                                    break;

                                case "defence":
                                    NewWeaponData.attrData.def = Convert.ToSingle(item.Value);
                                    break;

                                case "ATK":
                                    NewWeaponData.attrData.atk = Convert.ToSingle(item.Value);
                                    break;

                                case "speed":
                                    NewWeaponData.attrData.atkSpeedScale = Convert.ToSingle(item.Value);
                                    break;

                                case "Critical":
                                    NewWeaponData.attrData.criticalRate = Convert.ToSingle(item.Value);
                                    break;

                                case "CriticalDamage":
                                    NewWeaponData.attrData.criticalDamage = Convert.ToSingle(item.Value);
                                    break;

                                case "move":
                                    NewWeaponData.attrData.moveSpeedScale = Convert.ToSingle(item.Value);
                                    break;

                                case "EquipType":
                                    NewWeaponData.equipType = equipType;
                                    break;
                                }
                            }

                            int index = weaponDataList.FindIndex((data) => data.id == NewWeaponData.id);

                            if (index >= 0)
                            {
                                string icon = weaponDataList[index].icon;
                                weaponDataList.RemoveAt(index);
                                NewWeaponData.icon = icon;
                            }

                            weaponDataList.Add(NewWeaponData);
                        }
                    });
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(prefabPath);
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                skeletonDataAsset = (Spine.Unity.SkeletonDataAsset)AssetDatabase.LoadAssetAtPath(skeletonDataAssetPath, typeof(Spine.Unity.SkeletonDataAsset));
                skeletonDataAsset = (Spine.Unity.SkeletonDataAsset)EditorGUILayout.ObjectField(new GUIContent("SkeletonDataAsstet"), skeletonDataAsset, typeof(Spine.Unity.SkeletonDataAsset), true);
                skeletonDataAssetPath = AssetDatabase.GetAssetPath(skeletonDataAsset);
                EditorGUILayout.EndHorizontal();
            }));



            // 编辑区域 add by TangJian 2017/11/15 16:28:19
            EditorGUILayout.BeginHorizontal();

            // // 列表框 add by TangJian 2017/11/15 16:27:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos);

            for (int i = weaponDataList.Count - 1; i >= 0; i--)
            {
                var item = weaponDataList[i];
                EditorGUILayout.BeginHorizontal();

                int Index = MyGUIExtend.Instance.ListSingleButton("WeaponEditor", item.id, i, (() => { currWeaponData = item; }));

                MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action>
                {
                    {
                        "复制", (() =>
                        {
                            var weaponData = Tools.Json2Obj <WeaponData>(Tools.Obj2Json(weaponDataList[Index], true));
                            weaponDataList.Add(weaponData);
                        })
                    },
                    {
                        "删除", (() => { weaponDataList.RemoveAt(Index); })
                    }
                });
                EditorGUILayout.EndHorizontal();
            }

            if (MyGUI.Button("+"))
            {
                weaponDataList.Add(new WeaponData());
            }

            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();


            // 编辑框 add by TangJian 2017/11/15 16:28:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos);
            if (currWeaponData != null)
            {
                MyGUI.ItemDataField(currWeaponData, skeletonDataAssetPath);
            }

            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();


            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 2
0
        private void OnGUI()
        {
            dropItemsDataAsset = (DropItemsDataAsset)EditorGUILayout.ObjectField("dropItemsDataAsset",
                                                                                 dropItemsDataAsset, typeof(DropItemsDataAsset));

            excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath);

//            text = GUILayout.TextArea(text, new GUIStyle(){});

            if (MyGUI.Button("载入表格"))
            {
                dropItemsDataAsset.DropItemList.Clear();

                EditorTools.AnalyzeExcel(excelPath, (List <KeyValuePair <string, object> > pairs) =>
                {
                    DropItemsDataAsset.DropItem dropItem = new DropItemsDataAsset.DropItem();
                    foreach (var pair in pairs)
                    {
                        switch (pair.Key)
                        {
                        case "id":
                            dropItem.Id = Convert.ToString(pair.Value);
                            break;

                        case "MonsterID":
                            dropItem.RoleId = Convert.ToString(pair.Value);
                            break;

                        case "Name":
                            dropItem.RoleName = Convert.ToString(pair.Value);
                            break;

                        case "Lv":
                            string[] lvs    = Convert.ToString(pair.Value).Split(';');
                            dropItem.LvFrom = Convert.ToInt32(lvs[0]);
                            dropItem.LvTo   = Convert.ToInt32(lvs[1]);
                            break;

                        case "DropOne":
                            dropItem.DropOne = Convert.ToInt32(pair.Value);
                            break;

                        case "DropTwo":
                            dropItem.DropTwo = Convert.ToInt32(pair.Value);
                            break;

                        case "DropThree":
                            dropItem.DropThree = Convert.ToInt32(pair.Value);
                            break;

                        case "DropSoul":
                            dropItem.DropSoul = Convert.ToInt32(pair.Value);
                            break;
                        }
                    }
                    dropItemsDataAsset.DropItemList.Add(dropItem);
                });

                EditorUtility.SetDirty(dropItemsDataAsset);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }

            if (MyGUI.Button("测试"))
            {
                text = "";

                int instanceLevelMin = 1;
                int instanceLevelMax = 99;

                var roleIds = DropItemsDataAsset.Instance.GetAllRoleId();
                foreach (var roleId in roleIds)
                {
                    for (int instanceLevel = instanceLevelMin; instanceLevel <= instanceLevelMax; instanceLevel++)
                    {
                        List <string> dropItemIdList = DropItemsDataAsset.Instance.GetDropItemIdList(instanceLevel, roleId);
                        int           soulCount      = DropItemsDataAsset.Instance.GetDropSoulCount(instanceLevel, roleId);

                        text += "id: " + roleId + ", " + "instanceLevel: " + instanceLevel + ", dropItems: ";
                        EditorUtility.DisplayProgressBar("测试", "id: " + roleId + ", " + "instanceLevel: " + instanceLevel + ", dropItems: ", (float)instanceLevel / instanceLevelMax);

                        if (dropItemIdList != null)
                        {
                            for (int i = 0; i < dropItemIdList.Count; i++)
                            {
                                var dropItemId = dropItemIdList[i];
                                if (i == dropItemIdList.Count - 1)
                                {
                                    text += dropItemId;
                                    text += "\n";
                                }
                                else
                                {
                                    text += dropItemId;
                                    text += ", ";
                                }
                            }
                        }

                        // 掉落魂数目 add by TangJian 2019/3/13 12:55
                        if (soulCount > 0)
                        {
                            text += ", Soulx" + soulCount;
                        }

                        text += "\n";
                    }
                }

                EditorUtility.ClearProgressBar();
            }

            if (MyGUI.Button("测试1"))
            {
//                List<string> itemList = ItemManager.Instance.GetItemIdListDescendingOrder(0, 1, 0);
//                foreach (var itemId in itemList)
//                {
//                    text += itemId;
//                    text += "\n";
//                }

                List <string> itemList = DropItemsDataAsset.Instance.GetDropItemIdList(9, "Human");
                foreach (var itemId in itemList)
                {
                    text += itemId;
                    text += "\n";
                }
            }

            textScrollViewPos = GUILayout.BeginScrollView(textScrollViewPos);
            text = EditorGUILayout.TextArea(text);
            GUILayout.EndScrollView();
        }
Ejemplo n.º 3
0
        void OnGUI()
        {
            GUIStyle boxStyle = new GUIStyle("box");

            var width  = position.size.x - boxStyle.border.horizontal;
            var height = position.size.y - boxStyle.border.vertical;

            var innerBoxWidth  = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal);
            var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical);

            MyGUIExtend.Instance.ToolbarButton(new Dictionary <string, Action>
            {
                {
                    "读取", LoadData
                },
                {
                    "保存", SaveData
                },
                {
                    "制作预制体", CreatePrefabs
                }
            });

            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height));


            MyGUIExtend.Instance.Foldout("DcorationEditor", "路径信息", (() =>
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(decorationDataFile);
                excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath);
                if (MyGUI.Button("载入Excel"))
                {
                    EditorTools.AnalyzeExcelToDic(excelPath, dic =>
                    {
                        EquipType equipType = (EquipType)Convert.ToInt32(dic["EquipType"]);
                        switch (equipType)
                        {
                        case EquipType.Decoration:
                        case EquipType.Glove:
                        case EquipType.Shoe:
                        case EquipType.Ring:
                            DecorationData newDecorationData = new DecorationData();

                            foreach (var item in dic)
                            {
                                switch (item.Key)
                                {
                                case "id":
                                    newDecorationData.id = Convert.ToString(item.Value);
                                    break;

                                case "IconName":
                                    newDecorationData.icon = Convert.ToString(item.Value);
                                    break;

                                case "name":
                                    newDecorationData.name = Convert.ToString(item.Value);
                                    break;

                                case "Lv":
                                    newDecorationData.level = Convert.ToInt32(item.Value);
                                    break;

                                case "desc":
                                    newDecorationData.desc = Convert.ToString(item.Value);
                                    break;

                                case "Hp":
                                    newDecorationData.attrData.hpMax = Convert.ToSingle(item.Value);
                                    break;

                                case "defence":
                                    newDecorationData.attrData.def = Convert.ToSingle(item.Value);
                                    break;

                                case "ATK":
                                    newDecorationData.attrData.atk = Convert.ToSingle(item.Value);
                                    break;

                                case "speed":
                                    newDecorationData.attrData.atkSpeedScale = Convert.ToSingle(item.Value);
                                    break;

                                case "Critical":
                                    newDecorationData.attrData.criticalRate = Convert.ToSingle(item.Value);
                                    break;

                                case "CriticalDamage":
                                    newDecorationData.attrData.criticalDamage = Convert.ToSingle(item.Value);
                                    break;

                                case "move":
                                    newDecorationData.attrData.moveSpeedScale = Convert.ToSingle(item.Value);
                                    break;

                                case "EquipType":
                                    newDecorationData.equipType = equipType;
                                    break;
                                }
                            }

                            int index = decorationDataList.FindIndex((data) =>
                            {
                                return(data.id == newDecorationData.id);
                            });

                            if (index >= 0)
                            {
                                decorationDataList.RemoveAt(index);
                            }

                            decorationDataList.Add(newDecorationData);

                            break;
                        }
                    });
                }
                EditorGUILayout.EndHorizontal();

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(prefabPath);
                EditorGUILayout.EndHorizontal();
            }));



            // 编辑区域 add by TangJian 2017/11/15 16:28:19
            EditorGUILayout.BeginHorizontal();

            // // 列表框 add by TangJian 2017/11/15 16:27:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos);

            for (int i = decorationDataList.Count - 1; i >= 0; i--)
            {
                var item = decorationDataList[i];

                EditorGUILayout.BeginHorizontal();
                int Index = MyGUIExtend.Instance.ListSingleButton("DocrationEditor", item.id, i, (() => { currDecorationData = item; }));

                MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action>
                {
                    {
                        "删除", (() => { decorationDataList.RemoveAt(Index); })
                    },
                    {
                        "复制", () =>
                        {
                            var decorationData = Tools.Json2Obj <DecorationData>(Tools.Obj2Json(decorationDataList[Index], true));
                            decorationDataList.Add(decorationData);
                        }
                    }
                });
                EditorGUILayout.EndHorizontal();
            }

            if (MyGUI.Button("+"))
            {
                decorationDataList.Add(new DecorationData());
            }

            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();


            // 编辑框 add by TangJian 2017/11/15 16:28:46
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true));
            editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos);
            if (currDecorationData != null)
            {
                MyGUI.ItemDataField(currDecorationData);
            }

            GUILayout.Space(10);
            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();


            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();
        }
Ejemplo n.º 4
0
        private void OnGUI()
        {
            roleUpgradeDataAsset = (RoleUpgradeDataAsset)EditorGUILayout.ObjectField("roleUpgradeDataAsset",
                                                                                     roleUpgradeDataAsset, typeof(DropItemsDataAsset));

            excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath);

//            text = GUILayout.TextArea(text, new GUIStyle(){});

            if (MyGUI.Button("载入表格"))
            {
                roleUpgradeDataAsset.Clear();

                EditorTools.AnalyzeExcel(excelPath, (List <KeyValuePair <string, object> > pairs) =>
                {
                    DropItemsDataAsset.DropItem dropItem = new DropItemsDataAsset.DropItem();

                    int lv  = -1;
                    int exp = -1;

                    foreach (var pair in pairs)
                    {
                        switch (pair.Key)
                        {
                        case "lv":
                            lv = Convert.ToInt32(pair.Value);
                            break;

                        case "exp":
                            exp = Convert.ToInt32(pair.Value);
                            break;
                        }
                    }

                    Debug.Assert(lv >= 1 && exp >= 0);
                    roleUpgradeDataAsset.AddItem(lv, exp);
                });

                EditorUtility.SetDirty(roleUpgradeDataAsset);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }

            if (MyGUI.Button("测试"))
            {
                outputText = "";

                outputText += "通过经验获取等级:\n";
                for (int exp = 0; exp <= RoleUpgradeDataAsset.Instance.GetLevelMaxExp() * 2; exp++)
                {
                    int level = RoleUpgradeDataAsset.Instance.GetLevel(exp);

                    outputText += "exp: " + exp + " -> level: " + level + "\n";
                }

                for (int i = 0; i < 10; i++)
                {
                    outputText += "\n";
                }

                outputText += "通过等级获取经验:\n";
                for (int level = 1; level <= RoleUpgradeDataAsset.Instance.GetLevelMax(); level++)
                {
                    int exp = RoleUpgradeDataAsset.Instance.GetExp(level);

                    outputText += "level: " + level + " -> exp: " + exp + "\n";
                }
            }

            outputTextScrollViewPos = EditorGUILayout.BeginScrollView(outputTextScrollViewPos, GUILayout.ExpandWidth(true));

            outputText = EditorGUILayout.TextArea(outputText);

            EditorGUILayout.EndScrollView();
        }