/// <summary> /// if any state of the achievement is "unclaimed" we can get the reward /// </summary> /// <param name="itemUI"></param> void OpenReward(FMAchievementItemUI itemUI) { int achievementIndex = itemUI.CurrentIndex; string rewardKey = itemUI.Achievement.RewardKeys[achievementIndex]; FMRewardItem reward = FMPlayfabReward.GetRewardFromKey(rewardKey); if (!string.IsNullOrEmpty(reward.ItemKey)) { //TODO show item information //IVDialogDisplayer.DisplayNotice("you got " + reward.ItemKey, null); FMPlayfabUserAchievement.Instance.SetUserAchievementAsClaimedLocal(itemUI.Key, achievementIndex); return; } //spawming particles to currencies Debug.Log("reward type " + reward.RewardTypeValue); switch (reward.RewardTypeValue) { case "co": spawners[1].SpawnParticles(UICamera.mainCamera.ScreenToWorldPoint(Input.mousePosition)); break; case "pc": spawners[2].SpawnParticles(UICamera.mainCamera.ScreenToWorldPoint(Input.mousePosition)); break; case "item": spawners[0].SpawnParticles(UICamera.mainCamera.ScreenToWorldPoint(Input.mousePosition)); break; } //particleSpawner.SpawnParticles(UICamera.mainCamera.ScreenToWorldPoint(Input.mousePosition)); FMPlayfabUserAchievement.Instance.SetUserAchievementAsClaimedLocal(itemUI.Key, achievementIndex); }
void DisplayAchievements(FMPlayfabUserAchievementResult rs) { if (rs.status == FMAchievementStatus.error) { Debug.Log(rs.ErrorMessage); return; } Debug.Log("display achievements " + FMPlayfabAchievements.Items.Count); Debug.Log("display user achievements " + FMPlayfabUserAchievement.Items.Count); //adding elements in grid foreach (FMAchievementItem item in FMPlayfabAchievements.Items) { GameObject achievementPrefab = Instantiate(Resources.Load("FMAchievementItemUI")) as GameObject; FMAchievementItemUI itemData = achievementPrefab.GetComponent <FMAchievementItemUI>(); int currenIndex = FMPlayfabUserAchievement.Instance.GetUserAchievementFromKey(item.Key) != null? FMPlayfabUserAchievement.Instance.GetUserAchievementFromKey(item.Key).CurrenIndex : 0; itemData.SetData(item, GetRewardIconName(item, currenIndex)); itemData.Achievement = item; switch (itemData.GetCurrentState()) { case FMAchievementState.Unclaimed: itemData.OnReward = OpenReward; break; case FMAchievementState.Claimed: itemData.SetRewardAsClaimed(); break; } //Add to grid achievementPrefab.transform.parent = grid.transform; achievementPrefab.transform.localScale = Vector3.one; } grid.Reposition(); }