Esempio n. 1
0
    public string GetClientServerUrl()
    {
#if PLATFORM_KAKAO
        return(LTPlatformBase.ShareInstance().GetGameServerAddress() + CPlatformConfig.GetPlatForm());
#else
        return(_UpdateConfigParams.GetClientServerUrl() + CPlatformConfig.GetPlatForm());
#endif
    }
Esempio n. 2
0
    public static int InitializeIAP(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 1 && LuaScriptMgr.CheckTypes(L, 1, typeof(float)))
        {
            int roleId = (int)LuaScriptMgr.GetNumber(L, 1);
            LTPlatformBase.ShareInstance().InitializeIAP(roleId);
        }
        else
        {
            LogParamError("InitIAP", count);
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
Esempio n. 3
0
    public static int DoPurchase(IntPtr L)
    {
        int       count = LuaDLL.lua_gettop(L);
        const int nRet  = 0;

        if (count == 3 && LuaScriptMgr.CheckTypes(L, 1, typeof(float), typeof(string), typeof(string)))
        {
            int    purchaseType = (int)LuaScriptMgr.GetNumber(L, 1);
            string orderId      = LuaScriptMgr.GetString(L, 2);
            string productId    = LuaScriptMgr.GetString(L, 3);

            // 开启支付 sdk
            var productInfo = new SDK.BUY_INFO();
            productInfo.iBillingType = purchaseType;
            productInfo.strOrderId   = orderId;
            productInfo.strProductId = productId;
            LTPlatformBase.ShareInstance().Buy(productInfo);
        }
        else if (count == 4 && LuaScriptMgr.CheckTypes(L, 1, typeof(float), typeof(string), typeof(string), typeof(string)))
        {
            int    purchaseType  = (int)LuaScriptMgr.GetNumber(L, 1);
            string orderId       = LuaScriptMgr.GetString(L, 2);
            string productId     = LuaScriptMgr.GetString(L, 3);
            string transactionId = LuaScriptMgr.GetString(L, 4);

            // 开启支付 sdk
            var productInfo = new SDK.BUY_INFO();
            productInfo.iBillingType     = purchaseType;
            productInfo.strOrderId       = orderId;
            productInfo.strProductId     = productId;
            productInfo.strTransactionId = transactionId;
            LTPlatformBase.ShareInstance().Buy(productInfo);
        }
        else
        {
            LogParamError("DoPurchase", count);
        }
        return(GameUtilWrap.CheckReturnNum(L, count, nRet));
    }
Esempio n. 4
0
    IEnumerable InitGameCoroutine()
    {
        DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine Start...");

        foreach (var item in PreInitGameCoroutine())
        {
            yield return(item);
        }

        SetupPath();

        HobaDebuger.GameLogLevel = WriteLogLevel;

        //IOS Application.persistentDataPath  /var/mobile/Containers/Data/Application/app sandbox/Documents
        //Android /storage/emulated/0/Android/data/package name/files
#if UNITY_IOS
        _DocPath = Application.persistentDataPath;
        _LibPath = Path.Combine(Application.persistentDataPath, "UpdateRes");
        _TmpPath = Path.Combine(Application.persistentDataPath, "Tmp");
#elif UNITY_ANDROID
        _DocPath = Application.persistentDataPath;
        _LibPath = Path.Combine(Application.persistentDataPath, "UpdateRes");
        _TmpPath = Path.Combine(Application.persistentDataPath, "Tmp");
#else
        _DocPath = Environment.CurrentDirectory;
        _LibPath = Path.Combine(Environment.CurrentDirectory, "UpdateRes");
        _TmpPath = Path.Combine(Environment.CurrentDirectory, "Tmp");
#endif
        yield return(null);

#if UNITY_ANDROID || UNITY_IPHONE || UNITY_IOS
        //初始化异常上报SDK
        CLogReport.Init();
        yield return(null);
#endif

        //初始化基础目录
        {
            string path = EntryPoint.Instance.ResPath;
            path = path.Replace("file://", "");
            LuaDLL.HOBA_Init(path, _DocPath, _LibPath, _TmpPath);
        }

        _VoiceDir         = Path.Combine(_TmpPath, "Voice");
        _CustomPicDir     = Path.Combine(_TmpPath, "CustomPic");
        _UserLanguageFile = Path.Combine(_DocPath, "userlanguage.txt");
        _UserBillingFile  = Path.Combine(_DocPath, "userbilling.bin");
        _UserDataDir      = Path.Combine(_DocPath, "UserData");

        string strOSLanguage   = OSUtility.GetSystemLanguageCode();
        string strUserLanguage = GetUserLanguageCode();

        if (!Directory.Exists(_LibPath))
        {
            Directory.CreateDirectory(_LibPath);
        }
        if (!Directory.Exists(_VoiceDir))
        {
            Directory.CreateDirectory(_VoiceDir);
        }
        if (!Directory.Exists(_CustomPicDir))
        {
            Directory.CreateDirectory(_CustomPicDir);
        }
        if (!Directory.Exists(_UserDataDir))
        {
            Directory.CreateDirectory(_UserDataDir);
        }
        LuaDLL.HOBA_DeleteFilesInDirectory(_VoiceDir);               //清空Tmp目录
        LuaDLL.HOBA_DeleteFilesInDirectory(_CustomPicDir);           //清空Tmp目录
        yield return(null);

        if (!File.Exists(_UserLanguageFile))                //创建语言配置文件
        {
            WriteUserLanguageCode(strOSLanguage);
        }
        yield return(null);

        //目录信息
//#if (UNITY_EDITOR || UNITY_STANDALONE_WIN)
//         var pType = LTPlatformBase.ShareInstance().GetPlatformType();
//         HobaDebuger.LogWarningFormat("LTPlatformType: {0}", pType.ToString());
//         HobaDebuger.LogWarningFormat("AssetBundlePath: {0}", _AssetBundlePath);
//         HobaDebuger.LogWarningFormat("ResPath: {0}", ResPath);
//         HobaDebuger.LogWarningFormat("DocPath: {0}", _DocPath);
//         HobaDebuger.LogWarningFormat("LibPath: {0}", _LibPath);
//         HobaDebuger.LogWarningFormat("TmpPath: {0}", _TmpPath);
//         HobaDebuger.LogWarningFormat("ConfigPath: {0}", _ConfigPath);
//         HobaDebuger.LogWarningFormat("LuaPath: {0}", _LuaPath);
//         HobaDebuger.LogWarningFormat("VoiceDir: {0}", _VoiceDir);
//         HobaDebuger.LogWarningFormat("CustomPickDir: {0}", _CustomPicDir);
//         HobaDebuger.LogWarningFormat("OSLanguage: {0}, UserLanguage: {1}", strOSLanguage, strUserLanguage);
//         yield return null;
//#endif

        //根据语言设置更新语言
        ReadUpdateStringXmlFromResources(strUserLanguage);
        yield return(null);

#if (UNITY_EDITOR || UNITY_STANDALONE_WIN)               //只在windows下起作用
        bool bDebugSetting = ReadDebugSettingXml();
//         HobaDebuger.LogWarningFormat("DebugSetting: {0}", bDebugSetting);
//         HobaDebuger.LogWarningFormat("DebugSetting SkipUpdate: {0}, Shortcut: {1}, LocalData: {2}, LocalLua: {3}, Is1080P: {4}, FullScreen: {5}",
//             _DebugSetting.SkipUpdate,
//             _DebugSetting.ShortCut,
//             _DebugSetting.LocalData,
//             _DebugSetting.LocalLua,
//             _DebugSetting.Is1080P,
//             _DebugSetting.FullScreen);

        _SkipUpdate = _DebugSetting.SkipUpdate || File.Exists(Path.Combine(_DocPath, "skip.txt"));
        //HobaDebuger.LogWarningFormat("SkipUpdate: {0}", _SkipUpdate);
#endif

#if !UNITY_EDITOR && UNITY_STANDALONE_WIN
        if (_DebugSetting.Is1080P)
        {
            Screen.SetResolution(1920, 1080, _DebugSetting.FullScreen);
        }

        if (_DebugSetting.FPSLimit > 0)
        {
            Application.targetFrameRate = _DebugSetting.FPSLimit;
        }
#endif

        //初始化平台SDK
        {
            GameUpdateMan.Instance.InitUpdateUI(); //显示更新界面

            bool isFinish = false;
            int  code     = -1;
            LTPlatformBase.ShareInstance().InitSDK((_, resultCode) =>
            {
                code     = resultCode;
                isFinish = true;
            });
            LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Start); //平台SDK打点:开始游戏

            while (!isFinish)
            {
                yield return(null);
            }

            bool isInited = LTPlatformBase.ShareInstance().IsInited;
            var  pType    = LTPlatformBase.ShareInstance().GetPlatformType();
            DeviceLogger.Instance.WriteLogFormat("LTPlatform InitSDK result:{0}, return code:{1}, platform type:{2}", isInited.ToString(), code.ToString(), pType.ToString());
            if (!isInited)
            {
                // 初始化失败,弹窗提示,退出游戏
                GameUpdateMan.Instance.HotUpdateViewer.SetCircle(false);
                string errStr = LTPlatformBase.ShareInstance().GetErrStr(code);
                yield return(new WaitForUserClick(MessageBoxStyle.MB_OK, errStr, _UpdateStringConfigParams.PlatformSDKString_InitFailedTitle));

                ExitGame();
                yield break;
            }
        }

        {
            // copy base res
#if UNITY_ANDROID
            string srcDir  = "res_base";
            string destDir = Path.Combine(Application.persistentDataPath, "res_base");

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

            IsInstallFinished = File.Exists(destDir + "/.lock");
            if (!IsInstallFinished)
            {
                DeviceLogger.Instance.WriteLog(string.Format("Begin RunInstallStage... from {0} to {1}", srcDir, destDir));
                foreach (var item in GameUpdateMan.Instance.RunInstallStage(srcDir, destDir))
                {
                    yield return(item);
                }
                DeviceLogger.Instance.WriteLog("End RunInstallStage...");
            }

            if (IsInstallFinished)
            {
                string       lockFile = Path.Combine(destDir, ".lock");
                StreamWriter writer   = File.CreateText(lockFile);
                writer.Write(TotalSizeToCopy);
                writer.Close();
                DeviceLogger.Instance.WriteLog("EntryPoint InitGameCoroutine EntryPoint.Instance.RunInstallStage() Success...");
            }
            else
            {
                DeviceLogger.Instance.WriteLog("EntryPoint InitGameCoroutine EntryPoint.Instance.RunInstallStage() Failed!");
            }
            yield return(null);
#endif
            //在更新开始前,获取ServerConfig.xml
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            {
                string configsDir = Path.Combine(_ResPath, "Configs");
                string path       = Path.Combine(configsDir, "ServerConfig.xml");
                if (!ReadServerConfigXml(path))
                {
                    HobaDebuger.LogWarningFormat("Read ServerConfig Failed: {0}", path);
                }
            }
#else
            {
                string url     = EntryPoint.Instance.GetClientServerUrl().NormalizeDir() + "ServerConfig.xml";
                string tmpPath = Path.Combine(EntryPoint.Instance.TmpPath, "ServerConfig.xml");
                string errMsg;
                var    code = Patcher.FetchByUrl(url, tmpPath, Downloader.DownloadMan.reqTimeOut, out errMsg);
                if (code == Downloader.DownloadTaskErrorCode.Success)
                {
                    if (!ReadServerConfigXml(tmpPath))
                    {
                        HobaDebuger.LogWarningFormat("Read ServerConfig Failed: {0}", url);
                    }
                }
                else
                {
                    HobaDebuger.LogWarningFormat("Download ServerConfig Failed: {0}, {1}", url, code);
                }
            }
#endif
            yield return(null);

            DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine UpdateRoutine Start...");
            //IAP Verify url init and check receipt cache.
            LTPlatformBase.ShareInstance().InitPurchaseVerifyUrl(_ServerConfigParams.GetPurchaseVerifyUrl());
            LTPlatformBase.ShareInstance().ProcessPurchaseCache();
            LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Start_Update); //平台SDK打点:开始更新

            // App & 资源更新
            foreach (var item in GameUpdateMan.Instance.UpdateRoutine())
            {
                yield return(item);
            }
            LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_End_Update); //平台SDK打点:结束更新

            DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine UpdateRoutine End...");
        }

        //初始化pck包, 编辑器模式下不使用pck,策划编辑器模式下使用
#if !UNITY_EDITOR
        {
            string path = _ResPath;
            path = path.Replace("file://", "");
            LuaDLL.HOBA_InitPackages(path);
        }
#endif
        //FIX ME:: 加载不等待2帧 Windows崩溃 待查
        yield return(null);  //等待一帧,否则部分 Android 设置闪烁

        yield return(null);  //等待一帧,否则部分 Android 设置闪烁

        ReadGameCustomConfigParams();
        yield return(null);

        ReadWwiseBankConfigParams();
        yield return(null);

        ReadWwiseSoundConfigParams();
        yield return(null);

        ReadPlayerFollowCameraConfig();
        yield return(null);

        CLogFile.Init();
        yield return(null);

        CGameSession.Instance().PingInterval              = GameCustomConfigParams.PingInterval;
        CGameSession.Instance().MaxProcessProtocol        = GameCustomConfigParams.MaxProcessProtocol;
        CGameSession.Instance().MaxProcessSpecialProtocol = GameCustomConfigParams.MaxProcessSpecialProtocol;

        foreach (var item in InitGameInternal())
        {
            yield return(item);
        }

        CleanupUpdateResources();

        if (PanelLogo != null)
        {
            PanelLogo.SetActive(true);
            yield return(null);
        }

        string videoPath = System.IO.Path.Combine(Application.streamingAssetsPath, "TERA_BackgroundStory.mp4");
        VideoManager.PlayVideo(videoPath, null, null, null, true);
        yield return(null);

        GFXConfig.Instance.Init();

        foreach (var item in DoStartGame())
        {
            yield return(item);
        }

        //DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine DoStartGame End...");

        DeviceLogger.Instance.WriteLogFormat("EntryPoint InitGameCoroutine End...");

        //TestLoadResource("Assets/Outputs/Sfx/Scene/scene_chuansong_chuanzou01.prefab");
    }
Esempio n. 5
0
 public static string GetCustomData(string key)
 {
     return(LTPlatformBase.ShareInstance().GetCustomData(key));
 }
Esempio n. 6
0
    public IEnumerable UpdateRoutine()
    {
        //检查系统内存

        /*
         * if (SystemInfo.systemMemorySize < nMemoryMinimum)
         * {
         *  yield return new WaitForUserClick(MessageBoxStyle.MB_YesNo,
         *          HobaText.Format(EntryPoint.Instance.UpdateStringConfigParams.SystemRequire_Memory, nMemoryMinimum),
         *          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError));
         *
         *  if (WaitForUserClick.RetCode == 0)
         *  {
         *      Patcher.Instance.UpdateExit();
         *      EntryPoint.ExitGame();
         *      yield break;
         *  }
         * }
         * */

        LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update); //平台SDK打点:检查更新

        yield return(null);

        //更新资源,测试
        {
            string baseDir = EntryPoint.Instance.ResPath;
            string docDir  = EntryPoint.Instance.DocPath;
            string libDir  = EntryPoint.Instance.LibPath;
            string tmpDir  = EntryPoint.Instance.TmpPath;

            string updateServerDir1      = EntryPoint.Instance.GetUpdateServerUrl1();
            string updateServerDir2      = EntryPoint.Instance.GetUpdateServerUrl2();
            string updateServerDir3      = EntryPoint.Instance.GetUpdateServerUrl3();
            string clientServerDir       = EntryPoint.Instance.GetClientServerUrl();
            string dynamicServerDir      = EntryPoint.Instance.GetDynamicServerUrl();
            string dynamicAccountRoleDir = EntryPoint.Instance.GetDynamicAccountRoleUrl();

            foreach (var item in Patcher.Instance.Init(baseDir, docDir, libDir, tmpDir,
                                                       updateServerDir1, updateServerDir2, updateServerDir3, clientServerDir, dynamicServerDir, dynamicAccountRoleDir))
            {
                yield return(item);
            }

            //设置初始版本
#if  UNITY_EDITOR //|| UNITY_STANDALONE_WIN
            Patcher.Instance.CleanAllUpdatesReturnToBase(Patcher.Instance.BaseVersion);
#else
            string baseVersion   = CPlatformConfig.GetBaseVersion();
            bool   bWriteVersion = Patcher.Instance.SetFirstVersion(baseVersion, false);
            if (bWriteVersion)
            {
                Patcher.Instance.CleanAllUpdatesReturnToBase(Patcher.Instance.BaseVersion);
            }
#endif

            bool          bSkipPhase2 = false;
            UpdateRetCode retCode     = UpdateRetCode.success;

UpdateStartPhase1:
            //阶段1...
            int nTryTime = 0;
            do
            {
                _HotUpdateViewer.SetInstallPercent(-1.0f);

                foreach (var item in Patcher.UpdateCoroutinePhase1())
                {
                    CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo();
                    _HotUpdateViewer.SetPartProgress(updateInfo.curUpdateProgress);
                    _HotUpdateViewer.SetAllProgress(updateInfo.totalUpdateProgress);
                    _HotUpdateViewer.SetDesc(updateInfo.strUpdateInfo);

                    //新UI
                    _HotUpdateViewer.SetCurrentVersion(updateInfo.curVersion);
                    _HotUpdateViewer.SetServerVersion(updateInfo.serverVersion);

                    yield return(null);

                    if (item is UpdateRetCode)
                    {
                        retCode = (UpdateRetCode)item;
                        break;
                    }

                    yield return(item);
                }

                m_CurrentVersion = Patcher.Instance.m_CurrentVersion.ToString();
                m_ServerVersion  = Patcher.Instance.m_VersionMan.VerLastest.ToString();

                if (retCode != UpdateRetCode.success)               //错误处理
                {
                    if (nTryTime == 0)
                    {
                        _HotUpdateViewer.SetCircle(false);
                        yield return(new WaitForUserClick(MessageBoxStyle.MB_OK,
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateState_NetworkErr),
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError)));

                        UpdateInfoUtil.SetCanPlay(false);    //重试
                    }
                    else
                    {
                        LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败

                        _HotUpdateViewer.SetCircle(false);
                        yield return(new WaitForUserClick(MessageBoxStyle.MB_OK,
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateState_NetConnectionErr),
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError)));

#if !UNITY_EDITOR
                        Patcher.Instance.UpdateExit();
                        EntryPoint.ExitGame();
                        yield break;
#else                                                            //忽略错误,直接游戏
                        retCode     = UpdateRetCode.success;
                        bSkipPhase2 = true;
                        break;
#endif
                    }

                    ++nTryTime;
                }
                else                 //成功
                {
                    if (IsVersionCanUpdate() && !IsVersionComplete())
                    {
                        long   downloadSize = GetDownloadTotalSize();
                        string num          = string.Empty;
                        float  fMB          = downloadSize / (1024.0f * 1024.0f);
                        if (fMB >= 1f)
                        {
                            fMB = ((fMB * 10) - (fMB * 10) % 1) / 10; //保留一位小数
                            if (fMB % 1 > 0)
                            {
                                //有小数点
                                num = HobaText.Format("{0:0.0} MB", fMB);
                            }
                            else
                            {
                                num = HobaText.Format("{0:0} MB", fMB);
                            }
                        }
                        else
                        {
                            float fKB = downloadSize / 1024.0f;
                            num = HobaText.Format("{0:0} KB", fKB);
                        }

                        //下载总量提示
                        _HotUpdateViewer.SetCircle(false);
                        yield return(new WaitForUserClick(MessageBoxStyle.MB_OkCancel,
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateState_DownloadCheck),
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateStatus_BeginUpdate),
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_WifiTips),
                                                          num));

                        if (WaitForUserClick.RetCode == 0)
                        {
                            LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败
                            Patcher.Instance.UpdateExit();
                            EntryPoint.ExitGame();
                            yield break;
                        }

                        //存储空间检查,提示
                        long lDiskSize = OSUtility.GetFreeDiskSpace();
                        long lNeedSize = (long)(downloadSize * fExtraSpace) + 100 * 1024 * 1024;

                        Patcher.Instance.LogString(HobaText.Format("CheckDownloadSize! FreeDiskSize: {0}, NeedSize: {1}", lDiskSize, lNeedSize));

                        if (lDiskSize != 0 && lDiskSize < lNeedSize)
                        {
                            LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败

                            long   iNeedSizeMB       = lNeedSize / (1024 * 1024);
                            string strNoSpaceMessage = HobaText.Format(EntryPoint.Instance.UpdateStringConfigParams.SystemRequire_Space, iNeedSizeMB);
                            yield return(new WaitForUserClick(MessageBoxStyle.MB_OK,
                                                              strNoSpaceMessage,
                                                              UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalError)));

                            Patcher.Instance.UpdateExit();
                            EntryPoint.ExitGame();
                            yield break;
                        }

                        _HotUpdateViewer.StartPromotion();
                    }
                    break;              //确认下载,进入下一阶段
                }
            } while (true);

            if (!bSkipPhase2 && retCode == UpdateRetCode.success)
            {
                yield return(new WaitForSeconds(0.2f));

                if (!IsVersionComplete() && !bWifiMsgBoxShow)           //需要下载更新包,如果不是wifi需要提示
                {
                    if (OSUtility.IsNetAvailable() && !OSUtility.IsWifi())
                    {
                        _HotUpdateViewer.SetCircle(false);
                        yield return(new WaitForUserClick(MessageBoxStyle.MB_OkCancel,
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasErrorNotWifi),
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError)));

                        bWifiMsgBoxShow = true;

                        if (WaitForUserClick.RetCode == 0)
                        {
                            LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败
                            Patcher.Instance.UpdateExit();
                            EntryPoint.ExitGame();
                            yield break;
                        }
                        //继续
                    }
                }

                //阶段2...
                do
                {
                    foreach (var item in Patcher.UpdateCoroutinePhase2())
                    {
                        CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo();
                        _HotUpdateViewer.SetPartProgress(updateInfo.curUpdateProgress);
                        _HotUpdateViewer.SetAllProgress(updateInfo.totalUpdateProgress);
                        _HotUpdateViewer.SetDesc(updateInfo.strUpdateInfo);
                        _HotUpdateViewer.SetCurrentVersion(updateInfo.curVersion);
                        _HotUpdateViewer.SetServerVersion(updateInfo.serverVersion);

                        yield return(null);

                        if (item is UpdateRetCode)
                        {
                            retCode = (UpdateRetCode)item;
                            break;
                        }
                        else
                        {
                            yield return(item);
                        }
                    }

                    if (retCode == UpdateRetCode.pack_err ||                  //包错误, 严重错误,需要清空所有更新目录重试
                        retCode == UpdateRetCode.pack_open_err ||
                        retCode == UpdateRetCode.pack_read_err ||
                        retCode == UpdateRetCode.pack_write_err)
                    {
                        _HotUpdateViewer.SetCircle(false);
                        yield return(new WaitForUserClick(MessageBoxStyle.MB_OK,
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalErrorNeedCleanUp),
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalError)));

                        yield return(new WaitForSeconds(1.0f));

                        //上次写包错误,这时需要删除所有更新包,从基础版本重新更新,待测试
                        Patcher.Instance.CleanAllUpdatesReturnToBase(Patcher.Instance.BaseVersion);
                        UpdateInfoUtil.SetCanPlay(false);    //重试

                        yield return(new WaitForSeconds(1.0f));

                        goto UpdateStartPhase1;                                //重新开始更新,阶段1
                    }
                    else if (retCode == UpdateRetCode.patcher_version_too_new) //版本太老,不能通过自动更新解决, 需要重新下载程序
                    {
                        _HotUpdateViewer.SetCircle(false);
#if UNITY_STANDALONE_WIN
                        //FIXME:: 原逻辑版本不一致都不能进入游戏, 策划需求Windows 特殊处理点取消进入游戏,忽略程序版本限制
                        yield return(new WaitForUserClick(MessageBoxStyle.MB_OkCancel,
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalErrorNeedReinstall),
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateStatus_BeginUpdate)));

                        if (WaitForUserClick.RetCode == 0)
                        {
                            retCode = UpdateRetCode.success;       //走Phase3
                            break;
                        }
                        else
                        {
                            Patcher.Instance.UpdateExit();
                            EntryPoint.ExitGame();
                            yield break;
                        }
#else
                        //FIXME:: 原逻辑
                        LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败
#if PLATFORM_KAKAO
                        while (true)
                        {
                            yield return(new WaitForUserClick(MessageBoxStyle.MB_OK,
                                                              UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalErrorNeedReinstall),
                                                              UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateStatus_BeginUpdate)));


                            string url = string.Empty;
                            if (Application.platform == RuntimePlatform.Android)
                            {
                                string id = "com.longtugame.xxaxc"; //写死
                                url = string.Format("market://details?id={0}", id);
                            }
                            else if (Application.platform == RuntimePlatform.IPhonePlayer)
                            {
                                string id = "1073000645"; //写死
                                url = string.Format("itms-apps://itunes.apple.com/app/id{0}?action=write-review", id);
                            }
                            Patcher.Instance.LogString(string.Format("OpenUrl:{0}", url));
                            OSUtility.OpenUrl(url);  //跳转到商店

                            yield return(null);

                            yield return(null);
                        }
#else
                        // 非Kakao平台
                        yield return(new WaitForUserClick(MessageBoxStyle.MB_OK,
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasFatalErrorNeedReinstall),
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateStatus_BeginUpdate)));

                        Patcher.Instance.UpdateExit();
                        EntryPoint.ExitGame();
                        yield break;
#endif
#endif
                    }
                    else if (retCode == UpdateRetCode.pack_file_broken)                                       //某些安卓机型上出现解包错误,重启app继续更新即可
                    {
                        LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败

                        _HotUpdateViewer.SetCircle(false);
                        CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo();
                        yield return(new WaitForUserClick(MessageBoxStyle.MB_OK,
                                                          updateInfo.strUpdateInfo,
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError)));

                        {
                            Patcher.Instance.UpdateExit();
#if UNITY_ANDROID
                            AndroidUtil.DoRestart(200);
#else
                            EntryPoint.ExitGame();
#endif
                            yield break;
                        }
                    }
                    else if (retCode != UpdateRetCode.success)               //普通错误处理
                    {
                        CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo();
                        string      msgText    = string.Format("{0} {1}", updateInfo.strUpdateInfo, retCode.ToString());

                        _HotUpdateViewer.SetCircle(false);
                        yield return(new WaitForUserClick(MessageBoxStyle.MB_OkCancel,
                                                          msgText,
                                                          UpdateInfoUtil.GetStateString(UPDATE_STATE.UpdateString_HasError)));

                        if (WaitForUserClick.RetCode == 0)
                        {
#if !UNITY_EDITOR
                            LTPlatformBase.ShareInstance().SetBreakPoint(SDK.POINT_STATE.Game_Check_Update_Fail); //平台SDK打点:检查更新失败
                            Patcher.Instance.UpdateExit();
                            EntryPoint.ExitGame();
                            yield break;
#else
                            retCode = UpdateRetCode.success;       //走Phase3
                            break;
#endif
                        }
                        else
                        {
                            UpdateInfoUtil.SetCanPlay(false);    //重试
                        }
                    }
                    else                   //成功
                    {
                        break;
                    }
                } while (true);
            }

            Patcher.Instance.ReleasePackages();

            //第三阶段,下载服务器列表
            if (retCode == UpdateRetCode.success)
            {
                _HotUpdateViewer.SetCircle(false);
                _HotUpdateViewer.PrepareEnterGame();
                //_HotUpdateViewer.SetInstallPercent(-1.0f);

                //yield return new WaitForSeconds(0.2f);

                float progress = 0f;
                float count    = 0;
                foreach (var item in Patcher.UpdateCoroutinePhase3())
                {
                    CUpdateInfo updateInfo = UpdateInfoUtil.GetUpdateInfo();
                    _HotUpdateViewer.SetPartProgress(updateInfo.curUpdateProgress);
                    _HotUpdateViewer.SetAllProgress(updateInfo.totalUpdateProgress);
                    _HotUpdateViewer.SetDesc(updateInfo.strUpdateInfo);
                    _HotUpdateViewer.SetCurrentVersion(updateInfo.curVersion);
                    _HotUpdateViewer.SetServerVersion(updateInfo.serverVersion);

                    //新UI
                    _HotUpdateViewer.SetInstallInfo(updateInfo.strUpdateInfo);
                    _HotUpdateViewer.SetEnterGameTips(updateInfo.strUpdateInfo);
                    //模拟进度条
                    _HotUpdateViewer.SetEnterGameProgress(progress);
                    float maxProgress = (count < 2) ? 0.5f : 1f;
                    progress = UnityEngine.Random.Range(progress, maxProgress);
                    count++;

                    yield return(null);

                    if (item is UpdateRetCode)
                    {
                        retCode = (UpdateRetCode)item;
                        break;
                    }
                    else
                    {
                        yield return(item);
                    }
                }

                if (retCode != UpdateRetCode.success)
                {
                    yield return(new WaitForSeconds(1.0f));

                    UpdateInfoUtil.SetCanPlay(false);
                }
                else
                {
                    _HotUpdateViewer.SetEnterGameProgress(1f);
                    yield return(new WaitForSeconds(0.3f));

                    UpdateInfoUtil.SetCanPlay(true);
                }
            }
        }

        Patcher.Instance.UpdateExit();

        if (UpdateInfoUtil.GetUpdateInfo().bCanPlay)
        {
            _IsUpdateSucceed = true;
            yield return(null);
        }

        //yield return new WaitForSeconds(2.0f);
    }
Esempio n. 7
0
 public void PlatformSDKLoginCallBack(string param)
 {
     LTPlatformBase.ShareInstance().DoLoginCallBack(param);
 }