Exemplo n.º 1
0
        private void Save(object sender, RoutedEventArgs e)
        {
            if (apn.Text.Length == 0 || pas.Text.Length == 0 || usr.Text.Length == 0 || eml.Text.Length == 0)
            {
                MessageBox.Show("你是不是有什么东西没有填写鸭!", "保存失败");
                return;
            }

            RootObject obj = new RootObject();

            obj.appname  = apn.Text;
            obj.email    = eml.Text;
            obj.username = usr.Text;
            obj.password = pas.Text;
            List <ExtraInfo> list = new List <ExtraInfo>();

            foreach (var entry in ei)
            {
                ExtraInfo info = new ExtraInfo();
                info.infokey   = entry.Key;
                info.infovalue = entry.Value;
                list.Add(info);
            }

            obj.extraInfo = list;

            try {
                string     json  = JsonConvert.SerializeObject(obj);
                FileStream fs    = new FileStream(Main.instance.baseDirectory.FullName + @"\" + GetTimeStamp() + ((bool)enc.IsChecked ? ".encrypteduap" : ".uap"), FileMode.CreateNew, FileAccess.Write);
                byte[]     bytes = Encoding.UTF8.GetBytes((bool)enc.IsChecked ? AesUtil.AesEncrypt(json, Main.instance.ENCRYPT_KEY) : json);
                fs.Write(bytes, 0, bytes.Length);
                fs.Flush();
                fs.Dispose();
                fs.Close();
                MessageBox.Show("哇哦,成功了呢", "保存成功");
                Main.instance.Loaduap();
                this.Close();
            } catch (IOException exc) {
                MessageBox.Show("无法报错 未知原因\n" + exc.StackTrace, "保存失败");
            }
        }
Exemplo n.º 2
0
        public static void BuildWithoutJit()
        {
            string luaPath = PlayerPrefs.GetString("lua_path");

            DirectoryInfo di = new DirectoryInfo(luaPath);

            if (string.IsNullOrEmpty(luaPath) || !di.Exists)
            {
                throw new Exception("Lua path not exist.");
            }
            FileInfo[] fis = di.GetFiles("*.lua", SearchOption.AllDirectories);
            List <System.Threading.Tasks.Task> tasks = new List <System.Threading.Tasks.Task>();

            foreach (FileInfo fi in fis)
            {
                if (fi.Extension != ".lua")
                {
                    continue;
                }

                string subPath    = fi.DirectoryName.Replace(luaPath, string.Empty);
                string toPath     = Application.dataPath.Replace("/", "\\") + "\\Sources\\Lua" + subPath;
                string destName   = fi.Name.Replace(".lua", ".bytes");
                string outputPath = toPath + "\\" + destName;

                StreamReader sr = fi.OpenText();
                tasks.Add(sr.ReadToEndAsync().ContinueWith((task, o) =>
                {
                    byte[] encrypted = AesUtil.AesEncrypt(Encoding.UTF8.GetBytes(task.Result), AES_KEY, AES_IV);
                    File.WriteAllBytes(( string )o, encrypted);
                    UnityEngine.Debug.Log("Done:" + o);
                }, outputPath));
            }
            System.Threading.Tasks.Task.WaitAll(tasks.ToArray());
            AssetDatabase.Refresh();
        }
Exemplo n.º 3
0
        public static void BuildIOS()
        {
            //string luaCompilerPath = PlayerPrefs.GetString( "luac_path" );
            string luaCompilerPath = PlayerPrefs.GetString("luajit_path");
            string luaPath         = PlayerPrefs.GetString("lua_path");

            DirectoryInfo di = new DirectoryInfo(luaCompilerPath);

            if (string.IsNullOrEmpty(luaCompilerPath) || !di.Exists)
            {
                throw new Exception("Luajit path not exist.");
            }

            di = new DirectoryInfo(luaPath);
            if (string.IsNullOrEmpty(luaPath) || !di.Exists)
            {
                throw new Exception("Lua path not exist.");
            }

            //md5
            Hashtable md5Map;
            string    v = luaPath + "/ver.txt";

            if (File.Exists(v))
            {
                string vJson = File.ReadAllText(v);
                md5Map = ( Hashtable )MiniJSON.JsonDecode(vJson);
            }
            else
            {
                md5Map = new Hashtable();
            }

            FileInfo[] fis = di.GetFiles("*.lua", SearchOption.AllDirectories);
            foreach (FileInfo fi in fis)
            {
                string md5Digest = MD5Util.GetMd5HexDigest(fi);
                string subPath   = fi.DirectoryName.Replace(luaPath, string.Empty);
                string toPath    = Application.dataPath + "/Sources/Lua" + subPath;
                string destName  = fi.Name.Replace(".lua", ".bytes");
                string dest      = toPath + "/" + destName;

                string key = subPath + "/" + fi.Name;
                if (md5Map.ContainsKey(key) &&
                    ( string )md5Map[key] == md5Digest &&
                    File.Exists(dest))
                {
                    continue;
                }
                md5Map[key] = md5Digest;

                if (!Directory.Exists(toPath))
                {
                    Directory.CreateDirectory(toPath);
                }

                string text  = File.ReadAllText(fi.FullName);
                byte[] bytes = Encoding.UTF8.GetBytes(text);
                bytes = AesUtil.AesEncrypt(bytes);
                File.WriteAllBytes(dest, bytes);
            }

            AssetDatabase.Refresh();

            List <string> assets    = new List <string>();
            string        assetPath = Application.dataPath + "/Sources/Lua";
            DirectoryInfo di2       = new DirectoryInfo(assetPath);

            DirectoryInfo[] di2S = di2.GetDirectories();
            foreach (DirectoryInfo di3 in di2S)
            {
                assets.Add("Assets/Sources/Lua/" + di3.Name);
            }

            FileInfo[] fi2S = di2.GetFiles();
            foreach (FileInfo fi2 in fi2S)
            {
                if (fi2.Extension == ".bytes")
                {
                    assets.Add("Assets/Sources/Lua/" + fi2.Name);
                }
            }

            for (int i = 0; i < assets.Count; i++)
            {
                string assetPath2 = assets[i];
                WriteAssetBundleName(assetPath2, "lua");
            }

            AssetDatabase.Refresh();

            string nv = MiniJSON.JsonEncode(md5Map);

            File.WriteAllText(v, nv);
        }