public void IncrementAchievement(UM_Achievement achievement, float percentages) { switch (Application.platform) { case RuntimePlatform.IPhonePlayer: GameCenterManager.SubmitAchievement(percentages, achievement.IOSId); break; case RuntimePlatform.Android: GPAchievement a = GooglePlayManager.instance.GetAchievement(achievement.AndroidId); if (a != null) { if (a.type == GPAchievementType.TYPE_INCREMENTAL) { int steps = Mathf.CeilToInt((a.totalSteps / 100f) * percentages); GooglePlayManager.instance.IncrementAchievementById(achievement.AndroidId, steps); } else { GooglePlayManager.instance.UnlockAchievementById(achievement.AndroidId); } } break; } }
public void IncrementAchievement(UM_Achievement achievement, float percentages) { switch (Application.platform) { case RuntimePlatform.IPhonePlayer: GameCenterManager.SubmitAchievement(percentages, achievement.IOSId); break; case RuntimePlatform.Android: if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon) { SA_AmazonGameCircleManager.Instance.UpdateAchievementProgress(achievement.AmazonId, percentages); } else { GPAchievement a = GooglePlayManager.Instance.GetAchievement(achievement.AndroidId); if (a != null) { if (a.Type == GPAchievementType.TYPE_INCREMENTAL) { int steps = Mathf.CeilToInt(((float)a.TotalSteps / 100f) * percentages); GooglePlayManager.Instance.IncrementAchievementById(achievement.AndroidId, steps); } else { GooglePlayManager.Instance.UnlockAchievementById(achievement.AndroidId); } } } break; } }
private void OnAchievementsLoaded(GooglePlayResult result) { GooglePlayManager.ActionAchievementsLoaded -= OnAchievementsLoaded; if (result.isSuccess) { foreach (string achievementId in GooglePlayManager.Instance.achievements.Keys) { GPAchievement achievement = GooglePlayManager.Instance.GetAchievement(achievementId); Debug.Log(achievement.id); Debug.Log(achievement.name); Debug.Log(achievement.description); Debug.Log(achievement.type); Debug.Log(achievement.state); Debug.Log(achievement.currentSteps); Debug.Log(achievement.totalSteps); } SA_StatusBar.text = "Total Achievement: " + GooglePlayManager.Instance.achievements.Count.ToString(); AN_PoupsProxy.showMessage("Achievments Loaded", "Total Achievements: " + GooglePlayManager.Instance.achievements.Count.ToString()); } else { SA_StatusBar.text = result.message; AN_PoupsProxy.showMessage("Achievments Loaded error: ", result.message); } }
private void OnAchievementsLoaded(CEvent e) { GooglePlayManager.instance.removeEventListener(GooglePlayManager.ACHIEVEMENTS_LOADED, OnAchievementsLoaded); GooglePlayResult result = e.data as GooglePlayResult; if (result.isSuccess) { foreach (string achievementId in GooglePlayManager.instance.achievements.Keys) { GPAchievement achievement = GooglePlayManager.instance.GetAchievement(achievementId); Debug.Log(achievement.id); Debug.Log(achievement.name); Debug.Log(achievement.description); Debug.Log(achievement.type); Debug.Log(achievement.state); Debug.Log(achievement.currentSteps); Debug.Log(achievement.totalSteps); } SA_StatusBar.text = "Total Achievement: " + GooglePlayManager.instance.achievements.Count.ToString(); AN_PoupsProxy.showMessage("Achievments Loaded", "Total Achievements: " + GooglePlayManager.instance.achievements.Count.ToString()); } else { SA_StatusBar.text = result.message; AN_PoupsProxy.showMessage("Achievments Loaded error: ", result.message); } }
public int GetAchievementProgressInSteps(UM_Achievement achievement) { if (achievement == null) { Debug.LogError("Achievement is null. No progress can be retrieved."); return(0); } switch (Application.platform) { case RuntimePlatform.IPhonePlayer: float percentage = GameCenterManager.GetAchievementProgress(achievement.IOSId); return(Mathf.CeilToInt(((float)achievement.Steps / 100f) * percentage)); case RuntimePlatform.Android: GPAchievement a = GooglePlayManager.Instance.GetAchievement(achievement.AndroidId); if (a != null) { if (a.Type == GPAchievementType.TYPE_INCREMENTAL) { return(a.CurrentSteps); } else { return((a.State == GPAchievementState.STATE_UNLOCKED) ? 1 : 0); } } break; } return(0); }
public void IncrementAchievementByCurrentSteps(UM_Achievement achievement, int steps) { switch (Application.platform) { case RuntimePlatform.IPhonePlayer: { float percentage = ((float)steps / (float)achievement.Steps) * 100f; GameCenterManager.SubmitAchievement(percentage, achievement.IOSId); break; } case RuntimePlatform.Android: { GPAchievement a = GooglePlayManager.Instance.GetAchievement(achievement.AndroidId); if (a != null) { if (a.Type == GPAchievementType.TYPE_INCREMENTAL) { GooglePlayManager.Instance.IncrementAchievementById(a.Id, steps - a.CurrentSteps); } else { GooglePlayManager.Instance.UnlockAchievementById(a.Id); } } break; } } }
public float GetAchievementProgress(UM_Achievement achievement) { if (achievement == null) { return(0f); } switch (Application.platform) { case RuntimePlatform.IPhonePlayer: return(GameCenterManager.GetAchievementProgress(achievement.IOSId)); case RuntimePlatform.Android: if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon) { GC_Achievement ach = SA_AmazonGameCircleManager.Instance.GetAchievement(achievement.AmazonId); if (ach != null) { return(ach.Progress); } } else { GPAchievement a = GooglePlayManager.Instance.GetAchievement(achievement.AndroidId); if (a != null) { if (a.Type == GPAchievementType.TYPE_INCREMENTAL) { return(((float)a.CurrentSteps / a.TotalSteps) * 100f); } else { if (a.State == GPAchievementState.STATE_UNLOCKED) { return(100f); } else { return(0f); } } } } break; } return(0f); }
private void OnAchievmnetsLoadedInfoListner(GooglePlayResult res) { GPAchievement achievement = GooglePlayManager.Instance.GetAchievement(INCREMENTAL_ACHIEVEMENT_ID); if (achievement != null) { a_id.text = "Id: " + achievement.Id; a_name.text = "Name: " + achievement.Name; a_descr.text = "Description: " + achievement.Description; a_type.text = "Type: " + achievement.Type.ToString(); a_state.text = "State: " + achievement.State.ToString(); a_steps.text = "CurrentSteps: " + achievement.CurrentSteps.ToString(); a_total.text = "TotalSteps: " + achievement.TotalSteps.ToString(); } }
public int GetAchievementProgressInSteps(UM_Achievement achievement) { if (achievement == null) { Debug.LogError("Achievement is null. No progress can be retrieved."); return(0); } switch (Application.platform) { case RuntimePlatform.IPhonePlayer: float percentage = GameCenterManager.GetAchievementProgress(achievement.IOSId); return(Mathf.CeilToInt(((float)achievement.Steps / 100f) * percentage)); case RuntimePlatform.Android: if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon) { GC_Achievement ac = SA_AmazonGameCircleManager.Instance.GetAchievement(achievement.AmazonId); if (ac != null) { return(Mathf.CeilToInt(((float)achievement.Steps / 100f) * ac.Progress)); } } else { GPAchievement a = GooglePlayManager.Instance.GetAchievement(achievement.AndroidId); if (a != null) { if (a.Type == GPAchievementType.TYPE_INCREMENTAL) { return(a.CurrentSteps); } else { return((a.State == GPAchievementState.STATE_UNLOCKED) ? 1 : 0); } } } break; } return(0); }
private void OnAchievementsLoaded(string data) { string[] storeData; storeData = data.Split(AndroidNative.DATA_SPLITTER [0]); GooglePlayResult result = new GooglePlayResult(storeData [0]); if (result.isSuccess) { _achievements.Clear(); for (int i = 1; i < storeData.Length; i += 7) { if (storeData[i] == AndroidNative.DATA_EOF) { break; } GPAchievement ach = new GPAchievement(storeData[i], storeData[i + 1], storeData[i + 2], storeData[i + 3], storeData[i + 4], storeData[i + 5], storeData[i + 6] ); Debug.Log(ach.name); Debug.Log(ach.type); _achievements.Add(ach.id, ach); } Debug.Log("Loaded: " + _achievements.Count + " Achievements"); } ActionAchievementsLoaded(result); dispatch(ACHIEVEMENTS_LOADED, result); }
private void OnAchievementsLoaded(string data) { string[] storeData; storeData = data.Split(AndroidNative.DATA_SPLITTER [0]); GooglePlayResult result = new GooglePlayResult(storeData [0]); if (result.IsSucceeded) { Achievements.Clear(); for (int i = 1; i < storeData.Length; i += 7) { if (storeData[i] == AndroidNative.DATA_EOF) { break; } GPAchievement ach = new GPAchievement(storeData[i], storeData[i + 1], storeData[i + 2], storeData[i + 3], storeData[i + 4], storeData[i + 5], storeData[i + 6] ); Debug.Log(ach.Name); Debug.Log(ach.Type); Achievements.Add(ach); } Debug.Log("Loaded: " + Achievements.Count + " Achievements"); } ActionAchievementsLoaded(result); }
public float GetAchievementProgress(UM_Achievement achievement) { if (achievement == null) { return(0f); } switch (Application.platform) { case RuntimePlatform.IPhonePlayer: return(GameCenterManager.GetAchievementProgress(achievement.IOSId)); case RuntimePlatform.Android: GPAchievement a = GooglePlayManager.instance.GetAchievement(achievement.AndroidId); if (a != null) { if (a.type == GPAchievementType.TYPE_INCREMENTAL) { return((a.currentSteps / a.totalSteps) * 100f); } else { if (a.state == GPAchievementState.STATE_UNLOCKED) { return(100f); } else { return(0f); } } } break; } return(0f); }
public void IncrementAchievementByCurrentSteps(UM_Achievement achievement, int steps) { switch (Application.platform) { case RuntimePlatform.IPhonePlayer: { float percentage = ((float)steps / (float)achievement.Steps) * 100f; GameCenterManager.SubmitAchievement(percentage, achievement.IOSId); break; } case RuntimePlatform.Android: { if (UltimateMobileSettings.Instance.PlatformEngine == UM_PlatformDependencies.Amazon) { float percentage = ((float)steps / (float)achievement.Steps) * 100f; SA_AmazonGameCircleManager.Instance.UpdateAchievementProgress(achievement.AmazonId, percentage); } else { GPAchievement a = GooglePlayManager.Instance.GetAchievement(achievement.AndroidId); if (a != null) { if (a.Type == GPAchievementType.TYPE_INCREMENTAL) { GooglePlayManager.Instance.IncrementAchievementById(a.Id, steps - a.CurrentSteps); } else { GooglePlayManager.Instance.UnlockAchievementById(a.Id); } } } break; } } }
private void PlayServiceSettings() { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Play Service API Settings", MessageType.None); PlayServiceDrawXmlIDs(); EditorGUILayout.Space(); EditorGUI.indentLevel++; { EditorGUILayout.BeginVertical (GUI.skin.box); EditorGUILayout.BeginHorizontal(); AndroidNativeSettings.Instance.ShowLeaderboards = EditorGUILayout.Foldout(AndroidNativeSettings.Instance.ShowLeaderboards, "Leaderboards"); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if(AndroidNativeSettings.Instance.ShowLeaderboards) { foreach(GPLeaderBoard leaderboard in AndroidNativeSettings.Instance.Leaderboards) { EditorGUILayout.BeginVertical (GUI.skin.box); EditorGUILayout.BeginHorizontal(); GUIStyle s = new GUIStyle(); s.padding = new RectOffset(); s.margin = new RectOffset(); s.border = new RectOffset(); if(leaderboard.Texture != null) { GUILayout.Box(leaderboard.Texture, s, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(18)}); } leaderboard.IsOpen = EditorGUILayout.Foldout(leaderboard.IsOpen, leaderboard.Name); bool ItemWasRemoved = DrawSortingButtons((object) leaderboard, AndroidNativeSettings.Instance.Leaderboards); if(ItemWasRemoved) { return; } EditorGUILayout.EndHorizontal(); if(leaderboard.IsOpen) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(LeaderboardIdDLabel); leaderboard.Id = EditorGUILayout.TextField(leaderboard.Id); if(leaderboard.Id.Length > 0) { leaderboard.Id = leaderboard.Id.Trim(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(LeaderboardNameLabel); leaderboard.Name = EditorGUILayout.TextField(leaderboard.Name); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(LeaderboardDescriptionLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); leaderboard.Description = EditorGUILayout.TextArea(leaderboard.Description, new GUILayoutOption[]{GUILayout.Height(60), GUILayout.Width(200)} ); leaderboard.Texture = (Texture2D) EditorGUILayout.ObjectField("", leaderboard.Texture, typeof (Texture2D), false); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if(GUILayout.Button("Add new", EditorStyles.miniButton, GUILayout.Width(250))) { GPLeaderBoard leaderboard = new GPLeaderBoard(string.Empty, "New Leaderboard"); AndroidNativeSettings.Instance.Leaderboards.Add(leaderboard); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } EditorGUI.indentLevel--; EditorGUI.indentLevel++; { EditorGUILayout.BeginVertical (GUI.skin.box); EditorGUILayout.BeginHorizontal(); AndroidNativeSettings.Instance.ShowAchievements = EditorGUILayout.Foldout(AndroidNativeSettings.Instance.ShowAchievements, "Achievements"); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if(AndroidNativeSettings.Instance.ShowAchievements) { foreach(GPAchievement achievement in AndroidNativeSettings.Instance.Achievements) { EditorGUILayout.BeginVertical (GUI.skin.box); EditorGUILayout.BeginHorizontal(); GUIStyle s = new GUIStyle(); s.padding = new RectOffset(); s.margin = new RectOffset(); s.border = new RectOffset(); if(achievement.Texture != null) { GUILayout.Box(achievement.Texture, s, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(18)}); } achievement.IsOpen = EditorGUILayout.Foldout(achievement.IsOpen, achievement.Name); bool ItemWasRemoved = DrawSortingButtons((object) achievement, AndroidNativeSettings.Instance.Achievements); if(ItemWasRemoved) { return; } EditorGUILayout.EndHorizontal(); if(achievement.IsOpen) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(AchievementIdDLabel); achievement.Id = EditorGUILayout.TextField(achievement.Id); if(achievement.Id.Length > 0) { achievement.Id = achievement.Id.Trim(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(AchievementNameLabel); achievement.Name = EditorGUILayout.TextField(achievement.Name); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(AchievementDescriptionLabel); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); achievement.Description = EditorGUILayout.TextArea(achievement.Description, new GUILayoutOption[]{GUILayout.Height(60), GUILayout.Width(200)} ); achievement.Texture = (Texture2D) EditorGUILayout.ObjectField("", achievement.Texture, typeof (Texture2D), false); EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if(GUILayout.Button("Add new", EditorStyles.miniButton, GUILayout.Width(250))) { GPAchievement achievement = new GPAchievement(string.Empty, "New Achievement"); AndroidNativeSettings.Instance.Achievements.Add(achievement); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } EditorGUI.indentLevel--; EditorGUILayout.LabelField("API:", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(PlusApiLabel); settings.EnablePlusAPI = EditorGUILayout.Toggle(settings.EnablePlusAPI); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(GamesApiLabel); settings.EnableGamesAPI = EditorGUILayout.Toggle(settings.EnableGamesAPI); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(AppInviteAPILabel); settings.EnableAppInviteAPI = EditorGUILayout.Toggle(settings.EnableAppInviteAPI); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(DriveApiLabel); settings.EnableDriveAPI = EditorGUILayout.Toggle(settings.EnableDriveAPI); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; EditorGUILayout.LabelField("Auto Image Loading:", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Profile Icons"); settings.LoadProfileIcons = EditorGUILayout.Toggle(settings.LoadProfileIcons); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Profile Hi-res Images"); settings.LoadProfileImages = EditorGUILayout.Toggle(settings.LoadProfileImages); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Event Icons"); settings.LoadEventsIcons = EditorGUILayout.Toggle(settings.LoadEventsIcons); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Quest Icons"); settings.LoadQuestsIcons = EditorGUILayout.Toggle(settings.LoadQuestsIcons); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Quest Banners"); settings.LoadQuestsImages = EditorGUILayout.Toggle(settings.LoadQuestsImages); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; EditorGUILayout.LabelField("Extras:", EditorStyles.boldLabel); EditorGUI.indentLevel++; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Show Connecting Popup"); settings.ShowConnectingPopup = EditorGUILayout.Toggle(settings.ShowConnectingPopup); EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel--; }
private GPAchievement GetAndroidAchievement(string id) { foreach (GPAchievement ach in AndroidNativeSettings.Instance.Achievements) { if (ach.Id.Equals(id)) { return ach; } } GPAchievement a = new GPAchievement(id, string.Empty); AndroidNativeSettings.Instance.Achievements.Add(a); return a; }