Example #1
0
 //开始检测版本更新
 public void StartUpdate(string strPluginName)
 {
     if (m_gameEntry == null)
     {
         Utility.Log.Error("未初始化");
         return;
     }
     // 更新资源文件确认事件
     Utility.EventEngine.Instance().AddEventListener((int)MainEvent.DOWNLOAD_UPGRADEFILE_CONFIRM, OnEvent);
     PluginName                = strPluginName.ToLower();
     VersionFileName           = PluginName + ".version";
     m_strRomoteVersionFileUrl = m_gameEntry.GetRemoteVersionFileUrl() + PluginName + ".ver";
     m_buildinVersion.ReadFromFile(ref VersionFileName);
     Utility.Log.Trace("StartUpdate {0} ver:{1}", PluginName, m_buildinVersion.ToString());
     m_gameEntry.ChangeState(GameState.CHKVersion, true);
 }
Example #2
0
 public override void OnEvent(int nEventID, object param)
 {
     if (nEventID == (int)MainEvent.GET_REMOTE_VERSIONFILE_OK)
     {
         Utility.Log.Info("Upgrade.Excute");
         string strVersionFile      = GameUpgrade.Instance.VersionFileName;
         string strLocalVersionFile = Utility.FileUtils.Instance().FullPathFileName(ref strVersionFile, Utility.FileUtils.UnityPathType.UnityPath_CustomPath);
         if (!File.Exists(strLocalVersionFile))
         {
             m_owner.ChangeState(GameState.CopyFile, null);
         }
         else
         {
             // 读取本地版本文件
             GameUpgrade.Instance.ReadLocalVersion();
             // 询问是否需要下载
             GameUpgrade.Instance.Execute();
         }
     }
 }
Example #3
0
 // 进入状态
 public override void Enter(object param)
 {
     Utility.Log.Info("CopyFile.Enter");
     m_owner = m_Statemachine.GetOwner();
     if (!Application.isEditor)
     {
         string strDataPath = Application.dataPath;
         Thread t           = new Thread(() =>
         {
             // 更新资源文件
             Utility.EngineNativeMethod.ExtractZip(strDataPath, GameUpgrade.localFilePath, PluginCallback, "assets", "assets/bin");
         });
         t.Start();
     }
     else
     {
         GameUpgrade.Instance.ReadLocalVersion();
         // 版本检测
         m_owner.ChangeState(GameState.CHKVersion, false);
     }
 }
Example #4
0
        private static void OnPluginCallback(int nCur, int nTotal, string strName, IntPtr param)
        {
            Engine.ThreadHelper.RunOnMainThread(() =>
            {
                //Utility.Log.Info("CopyFile Callback {0}", (GameUpgrade.Instance.callback == null) ? 0 : 1);

                if (GameUpgrade.Instance.callback != null)
                {
                    GameUpgrade.Instance.callback(GameUpgrade.UpgradeError.UpgradeError_CopyStreamFile, nCur, nTotal, UpgradeDesc.CopyStreamFile);
                }

                Utility.Log.Info("CopyFile Callback {2} {0}/{1}", nCur, nTotal, strName);

                // 表示已经完成,切换地图
                if (nCur >= nTotal)
                {
                    GameUpgrade.Instance.ReadLocalVersion();
                    // 版本检测
                    m_owner.ChangeState(GameState.CHKVersion, false);
                }
            });
        }