Esempio n. 1
0
    IEnumerator WWWLoadLanguage()
    {
        yield return(null);

        string path = CDirectory.MakeCachePath(language);

        if (!File.Exists(path) || Application.isEditor)
        {
            using (var www = new WWW(CDirectory.MakeWWWStreamPath(language)))
            {
                yield return(www);

                if (!string.IsNullOrEmpty(www.error))
                {
                    throw new Exception(string.Format("WWW download:" + www.error + "  path :  " + www.url));
                }
                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.WriteAllBytes(path, www.bytes);
            }
        }

        byte[] bytes = File.ReadAllBytes(path);
        Localization.language = "language";
        Localization.LoadCSV(bytes);

        LoadDll();
    }
Esempio n. 2
0
    IEnumerator WWWLoadAssembly()
    {
        yield return(null);

        string path = CDirectory.MakeCachePath(_DllPath);

        if (!File.Exists(path))
        {
            using (var www = new WWW(CDirectory.MakeWWWStreamPath(_DllPath)))
            {
                yield return(www);

                if (!string.IsNullOrEmpty(www.error))
                {
                    throw new Exception(string.Format("WWW download:" + www.error + "  path :  " + www.url));
                }
                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.WriteAllBytes(path, www.bytes);
            }
        }
        System.Reflection.Assembly assembly = null;
#if ZTK
        assembly = ZToolKit.LoadAssembly(path);
#else
        FileStream stream = File.Open(path, FileMode.Open);
        byte[]     buffer = new byte[stream.Length];
        stream.Read(buffer, 0, (int)stream.Length);
        stream.Close();
        assembly = System.Reflection.Assembly.Load(buffer);
#endif

        this.game = (IGame)assembly.CreateInstance("CGame");
        this.game.StartGame();
    }