Ejemplo n.º 1
0
    //private void LoadLanguage()
    //{
    //    byte[] bytes = File.ReadAllBytes(CDirectory.MakeFilePath(language));
    //    Localization.language = "language";
    //    Localization.LoadCSV(bytes);
    //}

    void LoadAssembly()
    {
        string mdb_path;
        string path = GetAssemblyPath(out mdb_path);

        System.Reflection.Assembly assembly = null;
        if (path.IndexOf(_DllPath) == -1)
        {
            FileStream stream = File.Open(path, FileMode.Open);
            byte[]     buffer = new byte[stream.Length];
            stream.Read(buffer, 0, (int)stream.Length);
            stream.Close();
            if (string.IsNullOrEmpty(mdb_path) && File.Exists(mdb_path))
            {
                FileStream mdb_stream = File.Open(mdb_path, FileMode.Open);
                byte[]     mdb_buffer = new byte[mdb_stream.Length];
                mdb_stream.Read(mdb_buffer, 0, (int)mdb_stream.Length);
                mdb_stream.Close();
                assembly = System.Reflection.Assembly.Load(buffer, mdb_buffer);
            }
            else
            {
                assembly = System.Reflection.Assembly.Load(buffer);
            }
        }
        else
        {
#if ZTK
            assembly = ZToolKit.LoadAssembly(path);
#endif
        }
        this.game = (IGame)assembly.CreateInstance("CGame");
        this.game.StartGame();
    }
Ejemplo 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();
    }