Beispiel #1
0
        public static void GetAvatars()
        {
            var professions = new List <Profession>();
            var builder     = new LSBuilder();

            builder.ReadJson(Resources.profession).GetValue(ref professions);
            var gamePath = "D:\\地下城与勇士";
            var parts    = new string[] { "hair", "cap", "face", "neck", "coat", "skin", "belt", "pants", "shoes" };

            var regex = new Regex("\\d+");

            foreach (var prof in professions)
            {
                foreach (var part in parts)
                {
                    var file = $"{gamePath}\\{NpkCoder.IMAGE_DIR}\\{Avatars.GetAvatarFile(prof.Name, part)}.NPK";
                    if (!File.Exists(file))
                    {
                        continue;
                    }
                    var array = GetAvatar(prof.Name, part);
                    var list  = NpkCoder.LoadAll(file, e => MatchAvatar(e, array));
                    var path  = $"d:\\avatar\\new_image\\{prof.Name}\\{part}";
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    foreach (var img in list)
                    {
                        var image = img[prof.Frame];
                        var match = regex.Match(img.Name);
                        ImageToJson(path, prof.Name, part, img.Name, match.Value, image);
                    }
                }
            }
        }