예제 #1
0
 /// <summary>
 /// 从云上拉去数据到内存中
 /// </summary>
 private void RequestAccountAndChapters()
 {
     if (NetSystem.Instance.GetConnector().GetConnectStatus() == ConnectionStatus.CONNECTED)
     {
         string objectName = LocalAccountStorage.Get().account + ".txt";
         string filePath   = UpdateSystem.Get().saveRoot + objectName;
         NetSystem.Instance.helper.GenPresignedUrl(objectName, "GET", "text/plain", filePath, (int)EventId.OnSyncUserAndChapters);
     }
     else
     {
         StartSingleGame();
     }
 }
예제 #2
0
    /// <summary>
    /// 加载streaming资源
    /// 仅仅是获取了正确的资源路径,仍然使用外部读取手段
    /// </summary>
    /// <param name="relativePath">Relative path.</param>
    public string LoadStramingAsset(string relativePath)
    {
        object asset = null;

                #if !SERVER
        if (UpdateSystem.Get().HaveAssetBundle())
        {
            UpdateSystem.Get().LoadStreamingAssets(relativePath, out asset);
        }
                #endif

        if (asset == null)
        {
            return(DataProviderSystem.FormatDataProviderPath(relativePath));
        }

        return((string)asset);
    }
예제 #3
0
    /// <summary>
    /// 读取资源
    /// </summary>
    /// <returns>The resource.</returns>
    /// <param name="path">Path.</param>
    public Object LoadResource(string path)
    {
        object asset = null;

                #if !SERVER
        if (UpdateSystem.Get().HaveAssetBundle())
        {
            UpdateSystem.Get().LoadAsset(path, out asset);
        }

        if (asset == null)
        {
            asset = Resources.Load(path);
        }
                #endif

        return((Object)asset);
    }
예제 #4
0
    public override void OnUIEventHandler(EventId eventId, params object[] args)
    {
        if (eventId == EventId.RequestUserResult)
        {
            // 请求玩家数据结果
            NetMessage.ErrCode code = (NetMessage.ErrCode)args[0];
            if (code == NetMessage.ErrCode.EC_Ok)
            {
                RequestAccountAndChapters();
            }
            else if (code == NetMessage.ErrCode.EC_NoExist)
            {
                // 默认玩家
                CreateDefaultUser();
            }
            else if (code == NetMessage.ErrCode.EC_NeedResume)
            {
                // 需要恢复
                UISystem.Get().ShowWindow("CommonDialogWindow");
                EventSystem.Instance.FireEvent(EventId.OnCommonDialog, 1, LanguageDataProvider.GetValue(20));
                NetSystem.Instance.helper.ReconnectResume(); // 此时根据结果来判断是走哪种恢复
                //EventSystem.Instance.FireEvent(EventId.OnCommonDialog, 2, LanguageDataProvider.GetValue(20),
                //                                                          new EventDelegate(ReconnectResume),
                //                                                          new EventDelegate(ReconnectGiveup));
            }
        }
        else if (eventId == EventId.CreateUserResult)
        {
            // 创建玩家结果
            NetMessage.ErrCode code = (NetMessage.ErrCode)args[0];
            if (code == NetMessage.ErrCode.EC_Ok)
            {
                RequestAccountAndChapters();
            }
            else if (code == NetMessage.ErrCode.EC_NameExist)
            {
                Tips.Make(LanguageDataProvider.GetValue(4));
            }
            else if (code == NetMessage.ErrCode.EC_InvalidName)
            {
                Tips.Make(LanguageDataProvider.GetValue(5));
            }
            else if (code == NetMessage.ErrCode.EC_AccountExist)
            {
                Tips.Make(LanguageDataProvider.GetValue(6));
            }
            else
            {
                Tips.Make(LanguageDataProvider.GetValue(7));
            }
        }
        else if (eventId == EventId.OnABGetVersions)
        {
            int versionCount = (int)args[0];
            loadingTip.text += "";
            if (versionCount == 0)
            {
                SetProgress(0.6f);
                RequestOfflineNotice();
            }
            else
            {
                loadingTip.text += string.Format(LanguageDataProvider.GetValue(305), versionCount);
                progressInterval = 0.5f / versionCount;
                SetProgress(0.1f);
                CoroutineMono.Start(UpdateSystem.Get().StartUpdate());
            }
        }
        else if (eventId == EventId.OnPackageUpdate)
        {
            // 整包更新
            TableVersion packageUpdateVersion = args[0] as TableVersion;
            // 弹出大版本更新提示框
            string desc = packageUpdateVersion.desc.Replace("\\n", "\n");
            UISystem.Instance.ShowWindow("CommonDialogWindow");
            EventSystem.Instance.FireEvent(EventId.OnCommonDialog, 4, desc
                                           , new EventDelegate(() =>
            {
                Application.OpenURL(packageUpdateVersion.assetTableUrl);
            }));
        }
        else if (eventId == EventId.OnHttpNotice)
        {
            // 获取http公告
            string notice = (string)args[0];
            int    len    = notice.Length;
            if (len < 2)
            {
                // 没有公告,进入sdk登录
                LoginSDK();
            }
            else
            {
                // 有公告,分析公告
                int type = 0;
                int.TryParse(notice.Substring(0, 1), out type);
                string text = notice.Substring(2).Replace("\\n", "\n");
                UISystem.Instance.ShowWindow("CommonNoticeWindow");
                if (type == 0)
                {
                    EventSystem.Instance.FireEvent(EventId.OnCommonDialog, 1, text
                                                   , new EventDelegate(() =>
                    {
                        LoginSDK();
                    }));
                }
                else
                {
                    EventSystem.Instance.FireEvent(EventId.OnCommonDialog, 4, text);
                }
            }
        }
        else if (eventId == EventId.OnABDownloadIndex)
        {
            int index = (int)args[0];
            int size  = (int)args[1];
            loadingTip.text += string.Format(LanguageDataProvider.GetValue(306), index + 1, size / 8000);
            SetProgress(targetProgress + (index + 1) * progressInterval);
        }
        else if (eventId == EventId.OnABDownloading)
        {
            float progress = (float)args[0];
            int   bytes    = (int)args[1];
            Debug.Log("progress : " + progress + "  已接收:" + bytes);
        }
        else if (eventId == EventId.OnABDownloadingFinished)
        {
            loadingTip.text += LanguageDataProvider.GetValue(307);
            SetProgress(0.6f);

            loadingTip.text += LanguageDataProvider.GetValue(308);
            UpdateSystem.Get().ReloadClient();
            loadingTip.text += LanguageDataProvider.GetValue(309);

            RequestOfflineNotice();
        }
        else if (eventId == EventId.OnSDKLoginResult)
        {
            CoroutineMono.Start(LoginServer());
        }

        else if (eventId == EventId.UpdateChaptersView)
        {
            UISystem.Get().HideAllWindow();
            UISystem.Get().ShowWindow("LobbyWindowView");
            EventSystem.Instance.FireEvent(EventId.UpdateChaptersWindow, 1);
        }

        else if (eventId == EventId.OnSyncuserAndChaptersResult)
        {
            //int type    = (int)args[0];
            //int nResult = (int)args[1];
            //if( type == 0 )
            //{
            //    if (UserSyncSysteam.Get().curLoadStruct != null && nResult == 1)
            //    {
            //        if (UserSyncSysteam.Get().curLoadStruct.regtimeSaveFile != LocalAccountStorage.Get().regtimeSaveFile)
            //            UISystem.Instance.ShowWindow("CloudWindow");
            //        else
            //            StartSingleGame();
            //    }
            //    else
            //    {
            //        StartSingleGame();
            //    }
            //}
        }
    }