Beispiel #1
0
    private void OnEventProcessed(object sender, SocialEvent socialEvent)
    {
        if (this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }

        if (this.XboxLiveUser != null && this.XboxLiveUser.User != null && socialEvent.User.Gamertag == this.XboxLiveUser.User.Gamertag)
        {
            switch (socialEvent.EventType)
            {
            case SocialEventType.LocalUserAdded:
                if (socialEvent.ErrorCode == 0)
                {
                    this.CreateDefaultSocialGraphs();
                }
                break;

            case SocialEventType.SocialUserGroupLoaded:
            case SocialEventType.SocialUserGroupUpdated:
            case SocialEventType.PresenceChanged:
                this.RefreshSocialGroups();
                break;
            }
        }
        else
        {
            if (this.XboxLiveUser == null)
            {
                this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
            }
        }
    }
Beispiel #2
0
 void Update()
 {
     if (this.XboxLiveUser == null)
     {
         this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
     }
 }
Beispiel #3
0
    private void UpdateData(uint newPage)
    {
        if (!this.isLocalUserAdded)
        {
            return;
        }

        if (this.stat == null)
        {
            return;
        }

        if (this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }

        LeaderboardQuery query;

        if (newPage == this.currentPage + 1 && this.leaderboardData != null && this.leaderboardData.HasNext)
        {
            query = this.leaderboardData.NextQuery;
        }
        else
        {
            switch (leaderboardType)
            {
            case LeaderboardTypes.Global:
                socialGroup = null;
                break;

            case LeaderboardTypes.Favorites:
                socialGroup = "favorite";
                break;

            case LeaderboardTypes.Friends:
                socialGroup = "all";
                break;
            }

            query = new LeaderboardQuery
            {
                StatName          = this.stat.ID,
                SocialGroup       = socialGroup,
                SkipResultsToRank = newPage == 0 ? 0 : (this.currentPage * this.entryCount) - 1,
                MaxItems          = this.entryCount,
            };

            // Handle last page
            if (this.totalPages > 0 && newPage == this.totalPages)
            {
                query.SkipResultsToRank = (newPage * this.entryCount) - 1;
                newPage -= 1;
            }
        }

        this.currentPage = newPage;
        XboxLive.Instance.StatsManager.GetLeaderboard(this.XboxLiveUser.User, query);
    }
Beispiel #4
0
    private void UpdateData(uint newPage)
    {
#if ENABLE_WINMD_SUPPORT
        if (!this.isLocalUserAdded)
        {
            return;
        }

        if (this.stat == null)
        {
            return;
        }

        if (this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }

        LeaderboardQuery query;
        if (newPage == this.currentPage + 1 && this.leaderboardData != null && this.leaderboardData.HasNext)
        {
            query = this.leaderboardData.GetNextQuery();
        }
        else
        {
            switch (leaderboardType)
            {
            case LeaderboardTypes.Global:
                socialGroup = string.Empty;
                break;

            case LeaderboardTypes.Favorites:
                socialGroup = "favorite";
                break;

            case LeaderboardTypes.Friends:
                socialGroup = "all";
                break;
            }

            query = new LeaderboardQuery
            {
                SkipResultToRank = newPage == 0 ? 0 : (newPage * this.entryCount) + 1,
                MaxItems         = this.entryCount,
            };
        }

        this.currentPage = newPage;

        if (socialGroup == string.Empty)
        {
            StatisticManager.SingletonInstance.GetLeaderboard(this.XboxLiveUser.User, this.stat.ID, query);
        }
        else
        {
            StatisticManager.SingletonInstance.GetSocialLeaderboard(this.XboxLiveUser.User, this.stat.ID, socialGroup, query);
        }
#endif
    }
Beispiel #5
0
    public IEnumerator InitializeXboxLiveUser()
    {
        yield return(null);

#if ENABLE_WINMD_SUPPORT
        if (!XboxLiveUserManager.Instance.SingleUserModeEnabled && this.XboxLiveUser != null && this.XboxLiveUser.WindowsSystemUser == null)
        {
            var autoPicker = new Windows.System.UserPicker {
                AllowGuestAccounts = this.AllowGuestAccounts
            };
            autoPicker.PickSingleUserAsync().AsTask().ContinueWith(
                task =>
            {
                if (task.Status == TaskStatus.RanToCompletion)
                {
                    if (task.Result == null)
                    {
                        UnityEngine.WSA.Application.InvokeOnAppThread(() => this.Refresh(), false);
                    }
                    else
                    {
                        this.XboxLiveUser.Initialize(task.Result);
                        this.ExecuteOnMainThread.Enqueue(() => { StartCoroutine(this.SignInAsync()); });
                    }
                }
                else
                {
                    if (XboxLiveServicesSettings.Instance.DebugLogsOn)
                    {
                        Debug.Log("Exception occured: " + task.Exception.Message);
                    }
                    UnityEngine.WSA.Application.InvokeOnAppThread(() => this.Refresh(), false);
                }
            });
        }
        else
        {
            if (this.XboxLiveUser == null)
            {
                this.XboxLiveUser = XboxLiveUserManager.Instance.UserForSingleUserMode;
            }
            if (this.XboxLiveUser.User == null)
            {
                this.XboxLiveUser.Initialize();
            }
            yield return(this.SignInAsync());
        }
#else
        if (XboxLiveUserManager.Instance.SingleUserModeEnabled && this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }

        this.XboxLiveUser.Initialize();
        yield return(this.SignInAsync());
#endif
    }
Beispiel #6
0
    void Start()
    {
        if (this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }

        if (this.XboxLiveUser != null && this.XboxLiveUser.User != null && this.XboxLiveUser.User.IsSignedIn)
        {
            this.HandleGetStat(this.XboxLiveUser.User, this.ID);
        }
    }
Beispiel #7
0
 private void Start()
 {
     if (this.XboxLiveUser == null &&
         XboxLiveUserManager.Instance.SingleUserModeEnabled &&
         XboxLiveUserManager.Instance.GetSingleModeUser() != null &&
         XboxLiveUserManager.Instance.GetSingleModeUser().User != null &&
         XboxLiveUserManager.Instance.GetSingleModeUser().User.IsSignedIn)
     {
         this.XboxLiveUser     = XboxLiveUserManager.Instance.GetSingleModeUser();
         this.isLocalUserAdded = true;
         this.UpdateData(0);
     }
 }
Beispiel #8
0
    private void Start()
    {
        if (this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }

        if (this.XboxLiveUser != null && this.XboxLiveUser.User != null && this.XboxLiveUser.User.IsSignedIn)
        {
            this.CreateDefaultSocialGraphs();
            this.RefreshSocialGroups();
        }
    }
Beispiel #9
0
    // Use this for initialization
    void Start()
    {
        XboxLiveServicesSettings.EnsureXboxLiveServicesSettings();
        this.logText        = string.Empty;
        this.random         = new System.Random();
        this.gameSaveHelper = new GameSaveHelper();
        this.logLines       = new List <string>();

        if (this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }
    }
Beispiel #10
0
    void Start()
    {
        if (this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }

#if ENABLE_WINMD_SUPPORT
        if (this.XboxLiveUser != null && this.XboxLiveUser.User != null && this.XboxLiveUser.User.IsSignedIn)
        {
            this.HandleGetStat(this.XboxLiveUser.User, this.ID);
        }
#endif
    }
Beispiel #11
0
    public IEnumerator InitializeXboxLiveUser()
    {
        yield return(null);

        // Disable the sign-in button
        this.signInPanel.GetComponentInChildren <Button>().interactable = false;

#if ENABLE_WINMD_SUPPORT
        if (!XboxLiveUserManager.Instance.SingleUserModeEnabled && this.XboxLiveUser != null && this.XboxLiveUser.WindowsSystemUser == null)
        {
            var autoPicker = new Windows.System.UserPicker {
                AllowGuestAccounts = this.AllowGuestAccounts
            };
            autoPicker.PickSingleUserAsync().AsTask().ContinueWith(
                task =>
            {
                if (task.Status == TaskStatus.RanToCompletion)
                {
                    this.XboxLiveUser.WindowsSystemUser = task.Result;
                    this.XboxLiveUser.Initialize();
                }
                else
                {
                    if (XboxLiveServicesSettings.Instance.DebugLogsOn)
                    {
                        Debug.Log("Exception occured: " + task.Exception.Message);
                    }
                }
            });
        }
        else
        {
            if (this.XboxLiveUser == null)
            {
                this.XboxLiveUser = XboxLiveUserManager.Instance.UserForSingleUserMode;
            }
            if (this.XboxLiveUser.User == null)
            {
                this.XboxLiveUser.Initialize();
            }
        }
#else
        if (XboxLiveUserManager.Instance.SingleUserModeEnabled && this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }

        this.XboxLiveUser.Initialize();
#endif
    }
    private void UpdateData(uint newPage)
    {
        if (!this.isLocalUserAdded)
        {
            return;
        }

        if (this.stat == null)
        {
            return;
        }

        if (this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }

        LeaderboardQuery query;

        if (newPage == this.currentPage + 1 && this.leaderboardData != null && this.leaderboardData.HasNext)
        {
            query = this.leaderboardData.GetNextQuery();
        }
        else
        {
            switch (leaderboardType)
            {
            case LeaderboardTypes.Global:
                socialGroup = "";
                break;

            case LeaderboardTypes.Favorites:
                socialGroup = "favorite";
                break;

            case LeaderboardTypes.Friends:
                socialGroup = "all";
                break;
            }

            query = new LeaderboardQuery()
            {
                SkipResultToRank = newPage == 0 ? 0 : ((newPage - 1) * this.entryCount),
                MaxItems         = this.entryCount,
            };
        }

        this.currentPage = newPage;
        XboxLive.Instance.StatsManager.GetLeaderboard(this.XboxLiveUser.User, this.stat.ID, query);
    }
Beispiel #13
0
    // Update is called once per frame
    void Update()
    {
        if (this.XboxLiveUser == null)
        {
            this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
        }
        else
        {
            if (this.XboxLiveUser.User != null && this.XboxLiveUser.User.IsSignedIn && !this.gameSaveHelper.IsInitialized() && !this.initializing)
            {
                this.initializing = true;
                this.InitializeSaveSystem();
            }
        }


        if (!string.IsNullOrEmpty(this.GenerateNewControllerButton) && Input.GetKeyDown(this.GenerateNewControllerButton))
        {
            this.GenerateData();
        }

        if (!string.IsNullOrEmpty(this.SaveDataControllerButton) && Input.GetKeyDown(this.SaveDataControllerButton))
        {
            this.SaveData();
        }

        if (!string.IsNullOrEmpty(this.LoadDataControllerButton) && Input.GetKeyDown(this.LoadDataControllerButton))
        {
            this.LoadData();
        }

        if (!string.IsNullOrEmpty(this.GetInfoControllerButton) && Input.GetKeyDown(this.GetInfoControllerButton))
        {
            this.GetContainerInfo();
        }

        if (!string.IsNullOrEmpty(this.DeleteContainerControllerButton) && Input.GetKeyDown(this.DeleteContainerControllerButton))
        {
            this.DeleteContainer();
        }
    }
Beispiel #14
0
 protected void Update()
 {
     if (this.XboxLiveUser != null && this.XboxLiveUser.User != null && this.XboxLiveUser.User.IsSignedIn &&
         !this.isLocalUserAdded && !this.LocalUserAddedSetup)
     {
         StatsManagerComponent.Instance.LocalUserAdded += (sender, args) =>
         {
             if (args.User.Gamertag == this.XboxLiveUser.User.Gamertag)
             {
                 this.HandleGetStat(args.User, this.ID);
             }
         };
         this.LocalUserAddedSetup = true;
     }
     else
     {
         if (this.XboxLiveUser == null)
         {
             this.XboxLiveUser = XboxLiveUserManager.Instance.GetSingleModeUser();
         }
     }
 }
Beispiel #15
0
    public void Start()
    {
        // Disable the sign-in button if there's no configuration available.
        if (XboxLiveAppConfiguration.SingletonInstance == null || XboxLiveAppConfiguration.SingletonInstance.ServiceConfigurationId == null)
        {
            this.ConfigAvailable = false;

            Text signInButtonText = this.signInPanel.GetComponentInChildren <Button>().GetComponentInChildren <Text>(true);
            if (signInButtonText != null)
            {
                signInButtonText.fontSize = 16;
                signInButtonText.text     = "Xbox Live is not enabled.\nSee errors for detail.";
            }
        }
        this.Refresh();

        SocialManagerComponent.Instance.EventProcessed += SocialManagerEventProcessed;
        Microsoft.Xbox.Services.System.XboxLiveUser.SignOutCompleted += XboxLiveUserOnSignOutCompleted;

        if (XboxLiveUserManager.Instance.SingleUserModeEnabled)
        {
            if (XboxLiveUserManager.Instance.UserForSingleUserMode == null)
            {
                XboxLiveUserManager.Instance.UserForSingleUserMode = Instantiate(this.XboxLiveUserPrefab);
                this.XboxLiveUser = XboxLiveUserManager.Instance.UserForSingleUserMode;
                if (XboxLiveAppConfiguration.SingletonInstance != null && XboxLiveAppConfiguration.SingletonInstance.ServiceConfigurationId != null)
                {
                    this.SignIn();
                }
            }
            else
            {
                this.XboxLiveUser = XboxLiveUserManager.Instance.UserForSingleUserMode;
                this.LoadProfileInfo();
            }
        }
    }
Beispiel #16
0
    public void Start()
    {
        // Disable the sign-in button if there's no configuration available.
        if (XboxLive.Instance.AppConfig == null || XboxLive.Instance.AppConfig.AppId == null)
        {
            Button signInButton = this.signInPanel.GetComponentInChildren <Button>();
            signInButton.interactable = false;
            this.profileInfoPanel.SetActive(false);
            Text signInButtonText = signInButton.GetComponentInChildren <Text>(true);
            if (signInButtonText != null)
            {
                signInButtonText.fontSize = 16;
                signInButtonText.text     = "Xbox Live is not enabled.\nSee errors for detail.";
            }
        }

        if (XboxLiveUserManager.Instance.SingleUserModeEnabled)
        {
            if (XboxLiveUserManager.Instance.UserForSingleUserMode == null)
            {
                XboxLiveUserManager.Instance.UserForSingleUserMode = Instantiate(this.XboxLiveUserPrefab);
                this.XboxLiveUser = XboxLiveUserManager.Instance.UserForSingleUserMode;
                if (XboxLive.Instance.AppConfig != null && XboxLive.Instance.AppConfig.AppId != null)
                {
                    this.SignIn();
                }
            }
            else
            {
                this.XboxLiveUser = XboxLiveUserManager.Instance.UserForSingleUserMode;
                this.StartCoroutine(this.LoadProfileInfo());
            }
        }


        this.Refresh();
    }