예제 #1
0
    /// <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);
    }
    public void FilterResult(ExecuteCloudScriptResult result)
    {
        Bonuses.Clear();
        //Debug.Log(PlayFabSimpleJson.SerializeObject(result.FunctionResult));
        JSONNode jsonResult = JSON.Parse(result.FunctionResult.ToString());

        //Debug.Log(jsonResult);
        if ((jsonResult.Value.Equals("null") || result.Error != null))
        {
            //status = FMRewardStatus.error;
            return;
        }

        //get logi_count statistic
        logCountStatistic = FMPlayfabUserStatistics.GetStatisticProgress("login_count");

        RemainingHours = jsonResult["remainingHour"] == null ? 0 : jsonResult["remainingHour"].AsInt;
        int logCount = jsonResult["login_count"] == null ? logCountStatistic : jsonResult["login_count"].AsInt;;

        //if there's daily bonus
        string dailyRewardKey = jsonResult["daily_reward"];

        if (!string.IsNullOrEmpty(dailyRewardKey))
        {
            TodayReward = FMPlayfabReward.GetRewardFromKey(dailyRewardKey);
        }


        for (int i = 0; i < jsonResult["BonusResult"].AsArray.Count; i++)
        {
            string       rewardKey = jsonResult["BonusResult"].AsArray[i]["reward_key"];
            FMRewardItem reward    = FMPlayfabReward.GetRewardFromKey(rewardKey);

            FMLoginBonusState state;
            if (logCount > i)
            {
                state = FMLoginBonusState.Claimed;
            }
            else if (logCount == i)
            {
                state = FMLoginBonusState.Today;
            }
            else
            {
                state = FMLoginBonusState.Unclaimed;
            }
            Bonuses.Add(new FMLoginBonusItem(i, reward, state));
            //var ri = new FMRewardItem(rewardKey, rewardType, rewardValue, rewardValue);
            //ClaimedRewards.Add(ri);
        }
    }
예제 #3
0
    string GetRewardSprite(FMRewardItem reward)
    {
        switch (reward.RewardTypeValue)
        {
        case "co":
            return("coin_CO");

        case "pc":
            return("coin_PC");

        default:
            return("generic_item");
        }
    }
예제 #4
0
    public static void StoreItemsFromJson(GetTitleDataResult res)
    {
        Items.Clear();
        var allRewardsJson = JSON.Parse(res.Data["fm_rewards"]);

        for (int i = 0; i < allRewardsJson.Count; i++)
        {
            var          reward  = allRewardsJson[i];
            FMRewardType type    = reward["item_key"] == null ? FMRewardType.Currency : FMRewardType.Item;
            int          amount  = type == FMRewardType.Currency ? reward["amount"].AsInt : 0;
            string       itemKey = type == FMRewardType.Item ? reward["item_key"].Value : "";
            var          ri      = new FMRewardItem(reward["key"], reward["reward_type"], amount, itemKey, type);
            Items.Add(ri);
        }
    }
예제 #5
0
    /// <summary>
    /// this could change depending on the game and the atlas used
    /// </summary>
    /// <param name="achivement"></param>
    /// <param name="index"></param>
    /// <returns></returns>
    string GetRewardIconName(FMAchievementItem achivement, int index)
    {
        FMRewardItem reward = FMPlayfabReward.GetRewardFromKey(achivement.RewardKeys[index]);

        //default
        if (index == -1 || reward == null)
        {
            Debug.Log("reward null en " + achivement.Key);
            return("achievement");
        }

        switch (reward.RewardTypeValue)
        {
        case "co":
        case "pc":
            return("coin");

        case "item":
            return("achievement");
        }
        return("");
    }
 public FMLoginBonusItem(int index, FMRewardItem item, FMLoginBonusState state)
 {
     Index  = index;
     Reward = item;
     State  = state;
 }