Beispiel #1
0
    public async UniTaskVoid Start()
    {
        await InitModules();

        SignInPanel.Create().Forget();
        LangSelector.Create();

#if GMS
        FB.Init(OnInitComplete);
#endif

#if HMS
        AdPlaceholder.SetActive(!HMSAdsKitManager.Instance.IsBannerAdLoaded);
        HMSAdsKitManager.Instance.OnBannerLoadEvent += () => AdPlaceholder.SetActive(false);
#endif

#if UNITY_WEBGL
        if (JsManager.IsFigSdkInit() == 0)
        {
            Debug.Log("seems like you're in the demo not fig");
            //TestClientStart.Create();
            return;
        }

        Debug.Log("user data: " + JsManager.GetUserData());
        var fbigUserData = JsonUtility.FromJson <FbigUserData>(JsManager.GetUserData());
        Debug.Log("user data loaeds: " + JsonUtility.ToJson(fbigUserData));

        if (fbigUserData.EnteredBefore == 0)
        {
            ConnectToServer(fbigToken: fbigUserData.Token, fbigUserData.Name, fbigUserData.PictureUrl);
        }
        else
        {
            ConnectToServer(fbigToken: fbigUserData.Token);
        }

        Repository.I.TopFriends = JsonUtility.FromJson <List <FbigFriend> >(JsManager.GetFriends())
                                  .Select(f => new MinUserInfo {
            Id = f.Id, Name = f.Name, PictureUrl = f.PictureUrl
        })
                                  .ToArray();

        Debug.Log("friends are: " + JsManager.GetFriends());
        Debug.Log("friends loaded: " + JsonUtility.ToJson(Repository.I.TopFriends));

        JsManager.StartFbigGame();
        //you can think it would make more sence to start when conntected, but there could be network issue and require reconnect for example
        //the decision is not final anyway
#endif
    }
Beispiel #2
0
    private void OnInitComplete()
    {
        Debug.Log(
            $"OnInitCompleteCalled IsLoggedIn={FB.IsLoggedIn} IsInitialized={FB.IsInitialized}" +
            $" and the AccessToken.CurrentAccessToken is {AccessToken.CurrentAccessToken}");

        if (FB.IsLoggedIn)
        {
            ConnectToServer(facebookAccToken: AccessToken.CurrentAccessToken.TokenString);
        }
        else
        {
            SignInPanel.Create().Forget();
        }
    }