/// Listen to events that will change the UI including leaderboard refreshes, score updates or account changes /// private void Start() { AccountSystem.Get().OnAccountStatusChanged += SetState; LeaderboardSystem.Get().OnLeaderboardRefreshed += (scores) => m_leaderboardUIController.Refresh(scores); //Whenever a new score is posted auto update the leaderboard LeaderboardSystem.Get().OnScorePosted += () => LeaderboardSystem.Get().FetchFriendLeaderboard(); }
public LeaderboardSystem LeaderBoardSystem; // Connect gameObject Grp_CanvasLeaderboard //public CameraMovement MainCamera; // Connect gameObject MainCamera void Start() { Component[] objs_Search = GetComponentsInChildren(typeof(RectTransform), true); foreach (RectTransform _obj in objs_Search) { if (_obj.gameObject.name == "Quit_Game") { SectionQuitSceneGame = _obj.gameObject; } if (_obj.gameObject.name == "Quit_Scene_InGame") { SectionPauseSceneInGame = _obj.gameObject; } if (_obj.gameObject.name == "Button_Pause") { ButtonPauseSceneGame = _obj.gameObject; } if (_obj.gameObject.name == "Canvas_Menu") { SectionMenu = _obj.gameObject; } if (_obj.gameObject.name == "Canvas_Game") { SectionGame = _obj.gameObject; } } foreach (Transform child in gameObject.transform) { if (child.name == "Grp_CanvasLeaderboard") { SectionLeaderBoard = child.gameObject; } } GameObject tmpObj = GameObject.Find("Camera_Main"); //if(tmpObj)MainCamera = tmpObj.GetComponent<CameraMovement>(); tmpObj = GameObject.Find("LeaderboardSystem"); if (tmpObj) { LeaderBoardSystem = tmpObj.GetComponent <LeaderboardSystem>(); } }
/// Decides what to display based on the users login status. /// What the user sees depends on whether they are logged in via FB or not /// private void SetState(AccountSystem.AccountStatus status) { switch (status) { case AccountSystem.AccountStatus.NONE: m_fbLoginButton.SetActive(false); m_playerInfoPanel.SetActive(false); m_postScoreButton.SetActive(false); m_refreshButton.SetActive(false); m_leaderboardPanel.SetActive(false); m_title.SetActive(false); break; case AccountSystem.AccountStatus.LOGIN_ANONYMOUS: m_fbLoginButton.SetActive(true); m_playerInfoPanel.SetActive(true); m_postScoreButton.SetActive(false); m_refreshButton.SetActive(false); m_leaderboardPanel.SetActive(false); m_title.SetActive(false); m_localPlayerName.text = "Anonymous"; break; case AccountSystem.AccountStatus.LOGIN_FB: m_fbLoginButton.SetActive(false); m_playerInfoPanel.SetActive(true); m_postScoreButton.SetActive(true); m_refreshButton.SetActive(true); m_leaderboardPanel.SetActive(true); m_title.SetActive(true); m_localPlayerName.text = AccountSystem.Get().GetLocalPlayerName(); LeaderboardSystem.Get().FetchFriendLeaderboard(); break; } }
/// public LeaderboardSystem() { s_singletonInstance = this; }
/// Called when the user presses the refresh button. Pulls the latest /// friends scores from ChilliConnect and updates the leaderboard display /// private void OnRefreshLeaderboardSelected() { LeaderboardSystem.Get().FetchFriendLeaderboard(); }
/// Called when the user presses the post score button. /// The current score is captured and set to ChilliConnect. Depending on the /// leaderboard config the score is accepted or discarded. In our case it will only /// be accepted if it is higher than the existing score /// private void OnPostScoreSelected() { LeaderboardSystem.Get().PostScore(m_currentPostScore); }