Ejemplo n.º 1
0
        public void CloneTarget(PlayModeInfo target)
        {
            // this.gameId = target.gameId;
            // this.location = target.location;
            // this.showIndex = target.showIndex;  这三个不需要拷贝

            this.bg           = target.bg;
            this.btnImg       = target.btnImg;
            this.cardTheame   = target.cardTheame;
            this.createName   = target.createName;
            this.gameName     = target.gameName;
            this.img          = target.img;
            this.isOnline     = target.isOnline;
            this.isOpen       = target.isOpen;
            this.name         = target.name;
            this.package      = target.package;
            this.playTypeName = target.playTypeName;
            this.tag          = target.tag;
            this.tips         = target.tips;
            this.goldRoomName = target.goldRoomName;
            this.wanfaType    = target.wanfaType;
            this.isOpenGold   = target.isOpenGold;
            this.isOpenMatch  = target.isOpenMatch;
            this.headIcon     = target.headIcon;
        }
Ejemplo n.º 2
0
        // 拷贝一个PlayModeInfo
        private static void copyInfo(PlayModeInfo info)
        {
            if (info == null)
            {
                return;
            }

            copyData = new PlayModeInfo();
            copyData.CloneTarget(info);
        }
Ejemplo n.º 3
0
        public static void copyOrPasteInfo(PlayModeInfo info)
        {
            if (copyData == null)
            {
                copyInfo(info);
                return;
            }

            pasteInfo(info);
        }
Ejemplo n.º 4
0
        public static void ReSortId()
        {
            for (int i = 0; i < data.configs.Count; i++)
            {
                for (int j = 0; j < data.configs[i].configs.Count; j++)
                {
                    PlayModeConfig config = data.configs[i].configs[j];
                    for (int k = 0; k < config.playModeList.Count; k++)
                    {
                        PlayModeInfo info = config.playModeList[k];

                        info.gameId = config.key == 1 ? 1 + k : config.key * 100 + 1 + k;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private static void DrawLocationInfo(PlayModeConfig config)
        {
            if (locationName == string.Empty)
            {
                locationName = config.value;
            }
            EditorGUILayout.BeginHorizontal("TextArea", GUILayout.Width(500), GUILayout.Height(25));
            GUILayout.Space(5);
            EditorGUILayout.BeginVertical(GUILayout.Width(50));
            GUILayout.Space(5);
            EditorGUILayout.LabelField("是否开启:", GUILayout.Width(50));
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUILayout.Width(30));
            GUILayout.Space(3);
            config.isOpen = EditorGUILayout.Toggle(config.isOpen);
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUILayout.Width(50));
            GUILayout.Space(5);
            EditorGUILayout.LabelField("地区名:", GUILayout.Width(50));
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUILayout.Width(210));
            GUILayout.Space(5);
            locationName = EditorGUILayout.TextField(locationName, GUILayout.Width(200));
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical(GUILayout.Width(40));
            GUILayout.Space(2);
            if (GUILayout.Button("修改", GUILayout.Width(40)))
            {
                config.value = locationName;
                locationName = string.Empty;
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical(GUILayout.Width(80));
            GUILayout.Space(2);
            if (GUILayout.Button("新增玩法", GUILayout.Width(80)))
            {
                PlayModeInfo info = new PlayModeInfo();
                info.gameId   = config.GetInfoNextId();
                info.location = config.key;
                info.name     = "新增的玩法";
                config.playModeList.Add(info);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();
        }
Ejemplo n.º 6
0
 public static void SortData(ProvinceData curData)
 {
     if (curData == null)
     {
         return;
     }
     for (int i = 0; i < curData.configs.Count; i++)
     {
         curData.configs[i].showIndex = i + 1;
         if (curData.configs[i].playModeList == null)
         {
             continue;
         }
         for (int j = 0; j < curData.configs[i].playModeList.Count; j++)
         {
             PlayModeInfo info = curData.configs[i].playModeList[j];
             info.showIndex = j + 1;
         }
     }
     SaveData();
 }
Ejemplo n.º 7
0
        // 将当前拷贝的PlayModeInfo 赋值给传入的info
        private static void pasteInfo(PlayModeInfo info)
        {
            if (copyData == null)
            {
                Debug.LogError("当前拷贝的PlayModeInfo为Null,无法完成复制!");
                return;
            }

            if (!Directory.Exists(Application.dataPath + "/Scripts/Editor/PlayMode/backUp"))
            {
                Directory.CreateDirectory(Application.dataPath + "/Scripts/Editor/PlayMode/backUp");
            }

            File.Copy(dataPath, backupPath);
            UnityEditor.AssetDatabase.SaveAssets();
            UnityEditor.AssetDatabase.Refresh();

            info.CloneTarget(copyData);

            copyData = null;
        }
Ejemplo n.º 8
0
        private PublicConfig()
        {
            config.key       = 1;
            config.isOpen    = false;
            config.value     = "大众玩法";
            config.showIndex = 1;
            List <PlayModeInfo> copyList = new List <PlayModeInfo>();

            if (PlayModeTools.data.configs.Count > 0 && PlayModeTools.data.configs[0].configs[0].playModeList.Count > 0)
            {
                List <PlayModeInfo> playModeList = PlayModeTools.data.configs[0].configs[0].playModeList;
                for (int i = 0; i < playModeList.Count; i++)
                {
                    PlayModeInfo info = new PlayModeInfo();
                    info.gameId    = playModeList[i].gameId;
                    info.location  = playModeList[i].location;
                    info.showIndex = playModeList[i].showIndex;
                    info.CloneTarget(playModeList[i]);
                    info.isOpen = false;
                    copyList.Add(info);
                }
            }

            copyList.Sort((a, b) => {
                if (a.gameId > b.gameId)
                {
                    return(1);
                }
                else if (a.gameId == b.gameId)
                {
                    return(-1);
                }
                else
                {
                    return(-1);
                }
            });
            config.playModeList = copyList;
        }
Ejemplo n.º 9
0
        private static void DrawPlayModeList(PlayModeInfo info, PlayModeConfig config)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("玩法:", GUILayout.Width(60));
            info.name = EditorGUILayout.TextField(info.name, GUILayout.Width(100));
            EditorGUILayout.LabelField("gameId:" + info.gameId, GUILayout.Width(100));
            EditorGUILayout.LabelField("location:" + info.location, GUILayout.Width(100));
            //EditorGUILayout.LabelField("", GUILayout.Width(300));
            string copyBtnName = PlayModeTools.copyData == null ? "C" : "P";

            GUI.backgroundColor = PlayModeTools.copyData == null ? Color.cyan : Color.yellow;
            if (GUILayout.Button(copyBtnName, GUILayout.Width(20)))
            {
                PlayModeTools.copyOrPasteInfo(info);
            }
            GUI.backgroundColor = Color.white;
            if (GUILayout.Button("↑", GUILayout.Width(20)))
            {
                int infoIndex = config.playModeList.IndexOf(info);
                if (infoIndex != 0)
                {
                    var temp = config.playModeList[infoIndex];
                    config.playModeList[infoIndex]     = config.playModeList[infoIndex - 1];
                    config.playModeList[infoIndex - 1] = temp;
                    PlayModeTools.SortData();
                }
            }
            if (GUILayout.Button("↓", GUILayout.Width(20)))
            {
                int infoIndex = config.playModeList.IndexOf(info);
                if (infoIndex != config.playModeList.Count - 1)
                {
                    var temp = config.playModeList[infoIndex];
                    config.playModeList[infoIndex]     = config.playModeList[infoIndex + 1];
                    config.playModeList[infoIndex + 1] = temp;
                    PlayModeTools.SortData();
                }
            }

            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("DEL", GUILayout.Width(30)))
            {
                config.playModeList.Remove(info);
                return;
            }
            GUI.backgroundColor = new Color(0.8f, 0.8f, 0.8f);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("游戏名:", GUILayout.Width(60));
            info.gameName = EditorGUILayout.TextField(info.gameName, GUILayout.Width(100));
            EditorGUILayout.LabelField("包名:", GUILayout.Width(50));
            info.package = EditorGUILayout.TextField(info.package, GUILayout.Width(100));
            EditorGUILayout.LabelField("货币名:", GUILayout.Width(50));
            info.coinName = EditorGUILayout.TextField(info.coinName, GUILayout.Width(100));

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("玩法Type:", GUILayout.Width(60));
            info.wanfaType = EditorGUILayout.TextField(info.wanfaType, GUILayout.Width(100));
            EditorGUILayout.LabelField("创建名:", GUILayout.Width(50));
            info.createName = EditorGUILayout.TextField(info.createName, GUILayout.Width(100));
            EditorGUILayout.LabelField("附加字段:", GUILayout.Width(50));
            info.tips = EditorGUILayout.TextField(info.tips, GUILayout.Width(100));
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("大厅文字:", GUILayout.Width(60));
            if (info.hallName == "")
            {
                info.hallName = locationName.Equals("大众玩法") ? info.name : locationName;
            }
            info.hallName = EditorGUILayout.TextField(info.hallName, GUILayout.Width(100));
            EditorGUILayout.LabelField("卡牌皮肤:", GUILayout.Width(50));
            info.cardTheame = EditorGUILayout.TextField(info.cardTheame, GUILayout.Width(100));
            EditorGUILayout.LabelField("金币场:", GUILayout.Width(50));
            info.isOpenGold = EditorGUILayout.Toggle(info.isOpenGold);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("playType:", GUILayout.Width(60));
            info.playTypeName = EditorGUILayout.TextField(info.playTypeName, GUILayout.Width(100));
            EditorGUILayout.LabelField("金币场标签", GUILayout.Width(60));
            info.goldRoomName = EditorGUILayout.TextField(info.goldRoomName, GUILayout.Width(100));
            EditorGUILayout.LabelField("打开下载:", GUILayout.Width(50));

            info.isOpenUrl = EditorGUILayout.Toggle(info.isOpenUrl, GUILayout.Width(20));
            if (info.isOpenUrl)
            {
                info.openUrl = EditorGUILayout.TextField(info.openUrl, GUILayout.Width(234));
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("标签:", GUILayout.Width(60));
            info.tag = (TagEnum)EditorGUILayout.EnumPopup(info.tag, GUILayout.Width(100));
            EditorGUILayout.LabelField("面板颜色:", GUILayout.Width(50));
            info.color = (ColorEnum)EditorGUILayout.EnumPopup(info.color, GUILayout.Width(100));
            EditorGUILayout.LabelField("是否开启:", GUILayout.Width(50));
            info.isOpen = EditorGUILayout.Toggle(info.isOpen);
            // EditorGUILayout.LabelField("是否上线:", GUILayout.Width(50));
            // info.isOnline = EditorGUILayout.Toggle(info.isOnline);
            EditorGUILayout.EndHorizontal();



            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("玩法Icon:", GUILayout.Width(60));
            EditorGUI.BeginDisabledGroup(true);
            string[] strs = info.img.Split(',');
            string   str  = "";

            for (int i = 0; i < strs.Length; i++)
            {
                str += strs[i];
                str += "\n";
            }
            Rect headrect = EditorGUILayout.GetControlRect(GUILayout.Width(380), GUILayout.Height(30));

            EditorGUI.TextField(headrect, str);
            EditorGUI.EndDisabledGroup();
            Texture iconObj = (Texture)EditorGUILayout.ObjectField(null, typeof(Texture), true, GUILayout.Width(120));

            if (iconObj != null)
            {
                string path = AssetDatabase.GetAssetPath(iconObj);
                if (path != "")
                {
                    AssetImporter assetImporter = AssetImporter.GetAtPath(path);
                    if (assetImporter != null && assetImporter.assetBundleName != null)
                    {
                        info.img = assetImporter.assetBundleName + "," + System.IO.Path.GetFileNameWithoutExtension(path);
                    }
                    else
                    {
                        Debug.LogError(System.IO.Path.GetFileNameWithoutExtension(path) + " 未设置AssetBundle Paking Tag 请设置后再使用!");
                    }
                }
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("推荐icon:", GUILayout.Width(60));
            EditorGUI.BeginDisabledGroup(true);
            strs = info.headIcon.Split(',');
            str  = "";
            for (int i = 0; i < strs.Length; i++)
            {
                str += strs[i];
                str += "\n";
            }
            headrect = EditorGUILayout.GetControlRect(GUILayout.Width(380), GUILayout.Height(30));
            EditorGUI.TextField(headrect, str);
            EditorGUI.EndDisabledGroup();
            iconObj = (Texture)EditorGUILayout.ObjectField(null, typeof(Texture), true, GUILayout.Width(120));
            if (iconObj != null)
            {
                string path = AssetDatabase.GetAssetPath(iconObj);
                if (path != "")
                {
                    AssetImporter assetImporter = AssetImporter.GetAtPath(path);
                    if (assetImporter != null && assetImporter.assetBundleName != null)
                    {
                        info.headIcon = assetImporter.assetBundleName + "," + System.IO.Path.GetFileNameWithoutExtension(path);
                    }
                    else
                    {
                        Debug.LogError(System.IO.Path.GetFileNameWithoutExtension(path) + " 未设置AssetBundle Paking Tag 请设置后再使用!");
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }