Esempio n. 1
0
        public async Task Load(string mapServer, string mapName)
        {
            await Task.Run(delegate
            {
                if (!Directory.Exists("Maps"))
                {
                    Directory.CreateDirectory("Maps");
                }
            });

            string remoteFile           = mapServer + mapName + ".rar";
            string localFile            = "Maps/" + mapName + ".rar";
            string localFileUnencrypted = "Maps/" + mapName;

            if (!File.Exists(localFileUnencrypted))
            {
                await _client.DownloadFileTaskAsync(remoteFile, localFile);

                Unrar rar = new Unrar();
                await Task.Run(() => rar.UnpackArchive(localFile, "Maps", PASSWORD));

                await Task.Run(() => File.Delete(localFile));
            }
            await Task.Run(delegate
            {
                _content = File.ReadAllText(localFileUnencrypted);
            });

            Map = new Map(_content);
        }