// // Copyright (C) 2014 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #if UNITY_ANDROID namespace GooglePlayGames.BasicApi { using System; using System.Collections.Generic; using GooglePlayGames.OurUtils; using UnityEngine.SocialPlatforms; /// /// Dummy client used in Editor. /// /// Google Play Game Services are not supported in the Editor /// environment, so this client is used as a placeholder. /// public class DummyClient : IPlayGamesClient { /// /// Authenticates the user. /// /// Callback to handle the sign-in status. public void Authenticate(Action callback) { LogUsage(); if (callback != null) { callback(SignInStatus.Canceled); } } /// /// Manually authenticates the user. /// /// Callback to handle the sign-in status. public void ManuallyAuthenticate(Action callback) { LogUsage(); if (callback != null) { callback(SignInStatus.Canceled); } } /// /// Checks if the user is authenticated. /// /// Returns false indicating user is not authenticated. public bool IsAuthenticated() { LogUsage(); return false; } /// /// Requests server-side access with a refresh token. /// /// Flag to force refresh the token. /// Callback to handle the response. public void RequestServerSideAccess(bool forceRefreshToken, Action callback) { LogUsage(); if (callback != null) { callback(null); } } /// /// Requests server-side access with specific scopes. /// /// Flag to force refresh the token. /// List of requested authorization scopes. /// Callback to handle the response. public void RequestServerSideAccess(bool forceRefreshToken, List scopes, Action callback) { LogUsage(); if (callback != null) { callback(null); } } /// /// Requests recall of the access token. /// /// Callback to handle the recall response. public void RequestRecallAccessToken(Action callback) { LogUsage(); if (callback != null) { callback(null); } } /// /// Retrieves the user ID. /// /// Returns a dummy user ID. public string GetUserId() { LogUsage(); return "DummyID"; } /// /// Retrieves the player statistics. /// /// Callback to handle the player stats response. public void GetPlayerStats(Action callback) { LogUsage(); callback(CommonStatusCodes.ApiNotConnected, new PlayerStats()); } /// /// Retrieves the user's display name. /// /// Returns a dummy display name. public string GetUserDisplayName() { LogUsage(); return "Player"; } /// /// Retrieves the user's image URL. /// /// Returns null since no image is available. public string GetUserImageUrl() { LogUsage(); return null; } /// /// Loads user profiles for the given user IDs. /// /// List of user IDs. /// Callback to handle the user profile response. public void LoadUsers(string[] userIds, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(null); } } /// /// Loads achievements for the current user. /// /// Callback to handle the achievement response. public void LoadAchievements(Action callback) { LogUsage(); if (callback != null) { callback.Invoke(null); } } /// /// Unlocks the specified achievement. /// /// The achievement ID to unlock. /// Callback to handle the unlock result. public void UnlockAchievement(string achId, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(false); } } /// /// Reveals the specified achievement. /// /// The achievement ID to reveal. /// Callback to handle the reveal result. public void RevealAchievement(string achId, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(false); } } /// /// Increments the specified achievement by a number of steps. /// /// The achievement ID to increment. /// The number of steps to increment the achievement. /// Callback to handle the increment result. public void IncrementAchievement(string achId, int steps, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(false); } } /// /// Sets the steps of the specified achievement to at least a certain number. /// /// The achievement ID to update. /// The number of steps to set. /// Callback to handle the result of setting the steps. public void SetStepsAtLeast(string achId, int steps, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(false); } } /// /// Displays the achievements UI. /// /// Callback to handle the UI status. public void ShowAchievementsUI(Action callback) { LogUsage(); if (callback != null) { callback.Invoke(UIStatus.VersionUpdateRequired); } } /// /// Requests the load friends resolution UI. /// /// Callback to handle the UI status. public void AskForLoadFriendsResolution(Action callback) { LogUsage(); if (callback != null) { callback.Invoke(UIStatus.VersionUpdateRequired); } } /// /// Retrieves the last load friends status. /// /// Returns the last known load friends status. public LoadFriendsStatus GetLastLoadFriendsStatus() { LogUsage(); return LoadFriendsStatus.Unknown; } /// /// Loads friends with paging options. /// /// The number of friends to load per page. /// Flag to force reload of the friends list. /// Callback to handle the load friends status. public void LoadFriends(int pageSize, bool forceReload, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(LoadFriendsStatus.Unknown); } } /// /// Loads additional friends if available. /// /// The number of additional friends to load. /// Callback to handle the load friends status. public void LoadMoreFriends(int pageSize, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(LoadFriendsStatus.Unknown); } } /// /// Displays the compare profile UI for a player. /// /// The user ID of the player to compare. /// The in-game name of the other player. /// The in-game name of the current player. /// Callback to handle the UI status. public void ShowCompareProfileWithAlternativeNameHintsUI(string userId, string otherPlayerInGameName, string currentPlayerInGameName, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(UIStatus.VersionUpdateRequired); } } /// /// Retrieves the visibility status of the friends list. /// /// Flag to force reload the friends list visibility. /// Callback to handle the friends list visibility status. public void GetFriendsListVisibility(bool forceReload, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(FriendsListVisibilityStatus.Unknown); } } /// /// Displays the leaderboard UI for a specific leaderboard. /// /// The ID of the leaderboard. /// The time span for the leaderboard. /// Callback to handle the UI status. public void ShowLeaderboardUI( string leaderboardId, LeaderboardTimeSpan span, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(UIStatus.VersionUpdateRequired); } } /// /// Retrieves the maximum number of leaderboard results that can be loaded. /// /// Returns the maximum number of leaderboard results. public int LeaderboardMaxResults() { return 25; } /// /// Loads the leaderboard scores based on the specified parameters. /// /// The ID of the leaderboard to load scores from. /// The start position for loading scores. /// The number of scores to load. /// The collection type (e.g., public or social). /// The time span for the leaderboard scores. /// Callback to handle the leaderboard score data. public void LoadScores( string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, Action callback) { LogUsage(); if (callback != null) { callback(new LeaderboardScoreData( leaderboardId, ResponseStatus.LicenseCheckFailed)); } } /// /// Loads more leaderboard scores based on the provided pagination token. /// /// The token used for pagination. /// The number of scores to load. /// Callback to handle the leaderboard score data. public void LoadMoreScores( ScorePageToken token, int rowCount, Action callback) { LogUsage(); if (callback != null) { callback(new LeaderboardScoreData( token.LeaderboardId, ResponseStatus.LicenseCheckFailed)); } } /// /// Submits a score to a specific leaderboard. /// /// The ID of the leaderboard. /// The score to submit. /// Callback to handle the score submission result. public void SubmitScore(string leaderboardId, long score, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(false); } } /// /// Submits a score with additional metadata to a specific leaderboard. /// /// The ID of the leaderboard. /// The score to submit. /// Additional metadata to submit with the score. /// Callback to handle the score submission result. public void SubmitScore( string leaderboardId, long score, string metadata, Action callback) { LogUsage(); if (callback != null) { callback.Invoke(false); } } /// /// Retrieves the saved game client. /// /// Returns null since no saved game client is available. public SavedGame.ISavedGameClient GetSavedGameClient() { LogUsage(); return null; } /// /// Retrieves the events client. /// /// Returns null since no events client is available. public GooglePlayGames.BasicApi.Events.IEventsClient GetEventsClient() { LogUsage(); return null; } /// /// Loads friends with a simple boolean flag indicating success or failure. /// /// Callback to handle the load result. public void LoadFriends(Action callback) { LogUsage(); callback(false); } /// /// Retrieves the list of friends for the current user. /// /// Returns an empty array since no friends are loaded. public IUserProfile[] GetFriends() { LogUsage(); return new IUserProfile[0]; } /// /// Logs method usage for debugging purposes. /// private static void LogUsage() { Logger.d("Received method call on DummyClient - using stub implementation."); } } } #endif