コード例 #1
0
    private IEnumerator CompleteAuthentication(MemberAuthenticationResultView authView, bool isRegistrationLogin = false)
    {
        if (authView == null)
        {
            Debug.LogError("Account authentication error: MemberAuthenticationResultView was null, isRegistrationLogin: "******"There was an error logging you in. Please try again or contact us at http://support.cmune.com");
            yield break;
        }
        if (authView.MemberAuthenticationResult == MemberAuthenticationResult.IsBanned || authView.MemberAuthenticationResult == MemberAuthenticationResult.IsIpBanned)
        {
            ApplicationDataManager.LockApplication(LocalizedStrings.YourAccountHasBeenBanned);
            yield break;
        }
        if (authView.MemberAuthenticationResult == MemberAuthenticationResult.InvalidEsns)
        {
            Debug.Log("Result: " + authView.MemberAuthenticationResult);
            ShowLoginErrorPopup(LocalizedStrings.Error, "Sorry, this account is linked already.");
            yield break;
        }
        if (authView.MemberAuthenticationResult != MemberAuthenticationResult.Ok)
        {
            Debug.Log("Result: " + authView.MemberAuthenticationResult);
            ShowLoginErrorPopup(LocalizedStrings.Error, "Your login credentials are not correct. Please try to login again.");
            yield break;
        }
        Singleton <PlayerDataManager> .Instance.SetLocalPlayerMemberView(authView.MemberView);

        PlayerDataManager.AuthToken = authView.AuthToken;
        if (!PlayerDataManager.IsTestBuild)
        {
            PlayerDataManager.MagicHash = UberDaemon.Instance.GetMagicHash(authView.AuthToken);
            Debug.Log("Magic Hash:" + PlayerDataManager.MagicHash);
        }
        ApplicationDataManager.ServerDateTime = authView.ServerTime;
        global::EventHandler.Global.Fire(new GlobalEvents.Login(authView.MemberView.PublicProfile.AccessLevel));
        _progress.Text     = LocalizedStrings.LoadingFriendsList;
        _progress.Progress = 0.2f;
        yield return(UnityRuntime.StartRoutine(Singleton <CommsManager> .Instance.GetContactsByGroups()));

        _progress.Text     = LocalizedStrings.LoadingCharacterData;
        _progress.Progress = 0.3f;
        yield return(ApplicationWebServiceClient.GetConfigurationData("4.7.1", delegate(ApplicationConfigurationView appConfigView)
        {
            XpPointsUtil.Config = appConfigView;
        }, delegate(Exception ex)
        {
            ApplicationDataManager.LockApplication(LocalizedStrings.ErrorLoadingData);
        }));

        Singleton <PlayerDataManager> .Instance.SetPlayerStatisticsView(authView.PlayerStatisticsView);

        _progress.Text     = LocalizedStrings.LoadingMapData;
        _progress.Progress = 0.5f;
        bool mapsLoadedSuccessfully = false;

        yield return(ApplicationWebServiceClient.GetMaps("4.7.1", DefinitionType.StandardDefinition, delegate(List <MapView> callback)
        {
            mapsLoadedSuccessfully = Singleton <MapManager> .Instance.InitializeMapsToLoad(callback);
        }, delegate(Exception ex)
        {
            ApplicationDataManager.LockApplication(LocalizedStrings.ErrorLoadingMaps);
        }));

        if (!mapsLoadedSuccessfully)
        {
            ShowLoginErrorPopup(LocalizedStrings.Error, LocalizedStrings.ErrorLoadingMapsSupport);
            PopupSystem.HideMessage(_progress);
            yield break;
        }
        _progress.Progress = 0.6f;
        _progress.Text     = LocalizedStrings.LoadingWeaponAndGear;
        yield return(UnityRuntime.StartRoutine(Singleton <ItemManager> .Instance.StartGetShop()));

        if (!Singleton <ItemManager> .Instance.ValidateItemMall())
        {
            PopupSystem.HideMessage(_progress);
            yield break;
        }
        _progress.Progress = 0.7f;
        _progress.Text     = LocalizedStrings.LoadingPlayerInventory;
        yield return(UnityRuntime.StartRoutine(Singleton <ItemManager> .Instance.StartGetInventory(false)));

        _progress.Progress = 0.8f;
        _progress.Text     = LocalizedStrings.GettingPlayerLoadout;
        yield return(UnityRuntime.StartRoutine(Singleton <PlayerDataManager> .Instance.StartGetLoadout()));

        if (!Singleton <LoadoutManager> .Instance.ValidateLoadout())
        {
            ShowLoginErrorPopup(LocalizedStrings.ErrorGettingPlayerLoadout, LocalizedStrings.ErrorGettingPlayerLoadoutSupport);
            yield break;
        }
        _progress.Progress = 0.85f;
        _progress.Text     = LocalizedStrings.LoadingPlayerStatistics;
        yield return(UnityRuntime.StartRoutine(Singleton <PlayerDataManager> .Instance.StartGetMember()));

        if (!Singleton <PlayerDataManager> .Instance.ValidateMemberData())
        {
            ShowLoginErrorPopup(LocalizedStrings.ErrorGettingPlayerStatistics, LocalizedStrings.ErrorPlayerStatisticsSupport);
            yield break;
        }
        _progress.Progress = 0.9f;
        _progress.Text     = LocalizedStrings.LoadingClanData;
        yield return(ClanWebServiceClient.GetMyClanId(PlayerDataManager.AuthToken, delegate(int id)
        {
            PlayerDataManager.ClanID = id;
        }, delegate(Exception ex)
        {
        }));

        if (PlayerDataManager.ClanID > 0)
        {
            yield return(ClanWebServiceClient.GetOwnClan(PlayerDataManager.AuthToken, PlayerDataManager.ClanID, delegate(ClanView ev)
            {
                Singleton <ClanDataManager> .Instance.SetClanData(ev);
            }, delegate(Exception ex)
            {
            }));
        }
        GameState.Current.Avatar.SetDecorator(AvatarBuilder.CreateLocalAvatar());
        GameState.Current.Avatar.UpdateAllWeapons();
        yield return(new WaitForEndOfFrame());

        Singleton <InboxManager> .Instance.Initialize();

        yield return(new WaitForEndOfFrame());

        Singleton <BundleManager> .Instance.Initialize();

        yield return(new WaitForEndOfFrame());

        PopupSystem.HideMessage(_progress);
        if (!authView.IsAccountComplete)
        {
            PanelManager.Instance.OpenPanel(PanelType.CompleteAccount);
        }
        else
        {
            MenuPageManager.Instance.LoadPage(PageType.Home, false);
            IsAuthComplete = true;
        }
        Debug.LogWarning(string.Format("AuthToken:{0}, MagicHash:{1}", PlayerDataManager.AuthToken, PlayerDataManager.MagicHash));
        yield break;
    }