/// <summary>
        /// 读取游戏版本号
        /// </summary>
        private void readGameVersion()
        {
            // 拷贝资源版本号
#if UNITY_IOS
            string destVersionPath = BuilderPreference.VERSION_PATH + "/version_ios.txt";
#else
            string destVersionPath = BuilderPreference.VERSION_PATH + "/version.txt";
#endif
            if (!File.Exists(destVersionPath))
            {
                destVersionPath = BuilderPreference.ASSET_PATH + "/version.txt";
            }

            if (File.Exists(destVersionPath))
            {
                var versionPath = BuilderPreference.BUILD_PATH + "/version.txt";
                BuildUtil.SwapPathDirectory(versionPath);

                File.Copy(destVersionPath, versionPath, true);
                gameVersion = GameVersion.CreateVersion(File.ReadAllText(versionPath));
            }
            else
            {
                gameVersion = GameVersion.CreateVersion(Application.version);
            }

            // 读取游戏版本号
            apkVersion      = 0;
            destVersionPath = BuilderPreference.VERSION_PATH + "/apk_version.txt";
            if (File.Exists(destVersionPath))
            {
                var ver = File.ReadAllText(destVersionPath);
                apkVersion = Convert.ToInt32(ver);
            }
        }
Esempio n. 2
0
    static int CreateVersion(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string      arg0 = ToLua.CheckString(L, 1);
                GameVersion o    = GameVersion.CreateVersion(arg0);
                ToLua.PushObject(L, o);
                return(1);
            }
            else if (count == 2)
            {
                string      arg0 = ToLua.CheckString(L, 1);
                string      arg1 = ToLua.CheckString(L, 2);
                GameVersion o    = GameVersion.CreateVersion(arg0, arg1);
                ToLua.PushObject(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: GameVersion.CreateVersion"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Esempio n. 3
0
 void CheckVersion(string version)
 {
     if (string.IsNullOrEmpty(version))
     {
         version = GameManager.localVersion.ToString();
     }
     else
     {
         GameVersion remoteVersion = GameVersion.CreateVersion(version);
         if (GameManager.localVersion < GameManager.packVersion)
         {
             if (remoteVersion < GameManager.packVersion)
             {
                 version = GameManager.packVersion.ToString();
             }
         }
         else
         {
             if (remoteVersion < GameManager.localVersion)
             {
                 version = GameManager.localVersion.ToString();
             }
         }
     }
     User_Config.SetWebServerUrl(Path.Combine(User_Config.resource_server, version));
     Debug.Log(string.Format("Set web url: {0}", User_Config.web_url));
     if (onGetServerInfo != null)
     {
         onGetServerInfo();
     }
 }
Esempio n. 4
0
 public static GameVersion CreateVersion(string fileName, string defaultVersion)
 {
     if (File.Exists(fileName))
     {
         string text = File.ReadAllText(fileName);
         Debug.Log("Read version file: " + fileName + ", " + text);
         return(GameVersion.CreateVersion(text));
     }
     return(GameVersion.CreateVersion(defaultVersion));
 }
    /// <summary>
    /// 全部解压完成
    /// </summary>
    /// <param name="finishedObject"></param>
    private void onExtractComplete(IThreadWorkerObject[] finishedObjects)
    {
        string message = LanguageTips.EXTRACT_FINISHED;

        Debugger.Log(string.Format("启动:{0}", message));
        bar.SetMessage(message);

        File.WriteAllText(Util.DataPath + "extract.txt", "1");

        Util.ClearMemory();

        string localVersionFile = Path.Combine(Util.DataPath, "version.txt");

        GameManager.localVersion = GameVersion.CreateVersion(localVersionFile, GameManager.packVersion.ToString());

        if (onExtractFinish != null)
        {
            onExtractFinish();
        }
    }
Esempio n. 6
0
    public static void UpdateAssets()
    {
        string  path = ABPackHelper.ASSET_PATH + LuaConst.osDir;
        string  args = string.Format("/command:update /path:{0}", path);
        Process p    = Process.Start(TORTOISEPROC_NAME, args);

        p.WaitForExit();
        AssetDatabase.Refresh();

        var destVersionPath = ABPackHelper.VERSION_PATH + "version.txt";

        if (!File.Exists(destVersionPath))
        {
            destVersionPath = ABPackHelper.ASSET_PATH + LuaConst.osDir + "/version.txt";
        }
        var versionPath = ABPackHelper.BUILD_PATH + LuaConst.osDir + "/version.txt";

        File.Copy(destVersionPath, versionPath, true);
        if (File.Exists(versionPath) && AssetBundleEditor.gameVersion == null)
        {
            AssetBundleEditor.gameVersion = GameVersion.CreateVersion(File.ReadAllText(versionPath));
        }
        AssetDatabase.Refresh();
    }
Esempio n. 7
0
    IEnumerator InitVersionAndBugly()
    {
        sr.AdjustResolution();
        sr.setDesignContentScale();
        //Util.AutoAdjustCameraRect(UICamera.mainCamera);
        Debug.Log(string.Format("Resolution: {0}", Screen.currentResolution));
        yield return(Yielders.GetWaitForSeconds(0.1f));

        string versionFile = string.Format("{0}{1}/version.txt", Util.AppContentPath(), LuaConst.osDir);

        Debug.Log(versionFile);
        string version = string.Empty;

        if (Application.isMobilePlatform && Application.platform == RuntimePlatform.Android)
        {
            WWW www = new WWW(versionFile);
            yield return(www);

            if (www.error != null)
            {
                Debug.LogError(www.error);
                version = Application.version;
            }
            else
            {
                version = www.text;
            }
            www.Dispose();
            Debug.Log(string.Format("package version: {0}", version));
        }
        else
        {
            if (File.Exists(versionFile))
            {
                version = File.ReadAllText(versionFile);
            }
            else
            {
                version = Application.version;
            }
        }
        GameManager.packVersion = GameVersion.CreateVersion(version);
        string localVersionFile = Path.Combine(Util.DataPath, "version.txt");

        GameManager.localVersion = GameVersion.CreateVersion(localVersionFile, GameManager.packVersion.ToString());

#if UNITY_EDITOR
        //BuglyAgent.ConfigDebugMode(true);
#else
        //BuglyAgent.ConfigDebugMode(false);
#endif
#if UNITY_IOS
        BuglyAgent.InitWithAppId("1ce5a132bc");
#elif UNITY_ANDROID
        //BuglyAgent.InitWithAppId("529dceaf06");
#endif
        BuglyAgent.SetUserId(string.Format("{0}:{1}", SystemInfo.deviceModel, SystemInfo.deviceName));
        BuglyAgent.ConfigAutoReportLogLevel(LogSeverity.LogAssert);
        BuglyAgent.EnableExceptionHandler();

        InitOtherSetting();
        yield return(Yielders.GetWaitForSeconds(2f));

        SceneManager.LoadScene("UpdateScene");
    }
Esempio n. 8
0
    bool SetServerInfo()
    {
        Hashtable tbl = MiniJSON.Json.Deserialize(_serverInfo) as Hashtable;

        if (tbl == null)
        {
            Debug.LogError(string.Format("Get server list error: {0}", _serverInfo));

#if UNITY_EDITOR
            print("------------------------------------------------------------------");
            _serverInfo = "{\"update_url\":\"http://192.168.0.243/rsync/TestServer/Resources/\",\"corp\":\"1\",\"version\":\"1.0.0\",\"recommend_no\":\"2\",\"serverlist\":[{\"server_no\":\"1\",\"server_name\":\"彭老师联调\",\"ip\":\"192.168.0.94\",\"port\":\"1221\",\"is_open\":\"1\",\"other\":\"\"},{\"server_no\":\"2\",\"server_name\":\"高士哥\",\"ip\":\"192.168.0.80\",\"port\":\"8999\",\"is_open\":\"1\",\"other\":\"\"},{\"server_no\":\"3\",\"server_name\":\"243内部\",\"ip\":\"192.168.0.243\",\"port\":\"2001\",\"is_open\":\"1\",\"other\":\"\"},{\"server_no\":\"5\",\"server_name\":\"海明\",\"ip\":\"192.168.0.185\",\"port\":\"1221\",\"is_open\":\"1\",\"other\":\"\"},{\"server_no\":\"4\",\"server_name\":\"243内部(稳)\",\"ip\":\"192.168.0.243\",\"port\":\"2002\",\"is_open\":\"1\",\"other\":\"\"}]}";
            tbl         = MiniJSON.Json.Deserialize(_serverInfo) as Hashtable;
            if (tbl == null)
            {
                return(false);
            }
#else
            return(false);
#endif
        }

        var           temp_url   = tbl["update_url"].ToString().TrimEnd('/');
        var           temps      = temp_url.Split('/');
        StringBuilder update_url = new StringBuilder();
        for (int i = 0; i < temps.Length; ++i)
        {
            if (i < temps.Length - 1)
            {
                update_url.Append(temps[i]);
                update_url.Append("/");
            }
            else
            {
                if (temps[i].Split('.').Length >= 3)
                {
                    var remoteVersion = GameVersion.CreateVersion(temps[i]);
                    if (GameManager.localVersion < GameManager.packVersion)
                    {
                        if (remoteVersion < GameManager.packVersion)
                        {
                            update_url.Append(GameManager.packVersion.ToString());
                        }
                        else
                        {
                            update_url.Append(remoteVersion.ToString());
                        }
                    }
                    else
                    {
                        if (remoteVersion < GameManager.localVersion)
                        {
                            update_url.Append(GameManager.localVersion.ToString());
                        }
                        else
                        {
                            update_url.Append(remoteVersion.ToString());
                        }
                    }
                }
                else
                {
                    update_url.Append(temps[i]);
                }
                update_url.Append("/");
            }
        }

        User_Config.SetWebServerUrl(update_url.ToString());
        User_Config.SetDefaultServer(Convert.ToInt32(tbl["recommend_no"]));

        ServerInfo info;
        if (User_Config.serverList == null)
        {
            User_Config.serverList = new System.Collections.Generic.List <ServerInfo>();
        }

        ArrayList list = tbl["serverlist"] as ArrayList;
        Hashtable serverTbl;
        int       len = list.Count;
        for (int i = 0; i < len; i++)
        {
            serverTbl = list[i] as Hashtable;

            info            = new ServerInfo();
            info.openTime   = i;
            info.serverNo   = Convert.ToInt32(serverTbl["server_no"].ToString());
            info.serverName = serverTbl["server_name"].ToString();
            info.serverIp   = serverTbl["ip"].ToString();
            info.serverPort = serverTbl["port"].ToString();
            info.isOpen     = Convert.ToInt32(serverTbl["is_open"].ToString());
            info.other      = serverTbl["other"].ToString();
            info.hostId     = serverTbl["host_id"].ToString();
            if (serverTbl.ContainsKey("corp_id"))
            {
                info.corpId = serverTbl["corp_id"].ToString();
            }
            else
            {
                info.corpId = "1000";
            }

            User_Config.serverList.Add(info);
        }

        User_Config.serverList.Sort((x, y) => x.openTime.CompareTo(y.openTime) * -1);
        return(true);
    }