Exemple #1
0
    private IEnumerator ShowRewards()
    {
        if (RewardsReady)
        {
            GameObject gob = Instantiate(ShopMenuPrefab, Camera.main.transform);
            ShopMenuComponent = gob.GetComponent <ShopMenu> ();
            UserDataRecord data;
            string         curr   = "";
            int            amount = 0;

            if (GetNewIntemNotifyComponent() != null)
            {
                if (Rewards.TryGetValue("rewardItems", out data))
                {
                    if (data != null && data.Value != null && data.Value.Length > 0)
                    {
                        ShopMenu.MyShopItemClass item = ShopMenuComponent.FindItem(data.Value);
                        NewItemNotifyComponent.ShowNotify(item.Picture, null, item.DisplayName);
                        yield return(new WaitForSeconds(1.5f));
                    }
                }
                if (Rewards.TryGetValue("rewardCurr", out data))
                {
                    if (data != null && data.Value != null && data.Value.Length > 0)
                    {
                        curr = data.Value;
                    }
                }
                if (Rewards.TryGetValue("rewardCurrAmount", out data))
                {
                    if (data != null && data.Value != null && data.Value.Length > 0)
                    {
                        amount = Int32.Parse(data.Value);
                    }
                }
                if (amount > 0)
                {
                    if (curr.Equals("CR") && amount > 0)
                    {
                        NewItemNotifyComponent.ShowNotify(
                            CreditCurrencyRewardImage, null, amount + " " + CreditCurrencyRewardName
                            );
                    }
                }
            }
        }
        yield return(null);
    }
Exemple #2
0
    private void OnCloudCheckRewards(ExecuteCloudScriptResult result)
    {
        Dictionary <String, UserDataRecord> Rewards;
        NewItemNotify  NewItemNotifyComponent;
        string         curr   = "";
        int            amount = 0;
        UserDataRecord data;

        Debug.Log("Rewards checked" + result.FunctionResult + " error:" + result.Error
                  + " log:" + result.Logs);

        Rewards = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <String, UserDataRecord> >(PlayFab.Json.JsonWrapper.SerializeObject(result.FunctionResult));

        GameObject obj = GameObject.Find("NewItemNotify-Canvas");

        if (obj != null)
        {
            NewItemNotifyComponent = obj.GetComponent <NewItemNotify> ();
        }
        else
        {
            Debug.LogWarning("Cannot find item notify canvas");
            return;
        }

        GameObject gob = Instantiate(ShopMenuPrefab, Camera.main.transform);
        ShopMenu   ShopMenuComponent = gob.GetComponent <ShopMenu> ();

        if (Rewards.TryGetValue("rewardItems", out data))
        {
            if (data != null && data.Value != null && data.Value.Length > 0)
            {
                ShopMenu.MyShopItemClass item = ShopMenuComponent.FindItem(data.Value);
                NewItemNotifyComponent.ShowNotify(item.Picture, null, item.DisplayName);
            }
        }
        if (Rewards.TryGetValue("rewardCurr", out data))
        {
            if (data != null && data.Value != null && data.Value.Length > 0)
            {
                curr = data.Value;
            }
        }
        if (Rewards.TryGetValue("rewardCurrAmount", out data))
        {
            if (data != null && data.Value != null && data.Value.Length > 0)
            {
                amount = Int32.Parse(data.Value);
            }
        }
        if (amount > 0)
        {
            if (curr.Equals("CR") && amount > 0)
            {
                NewItemNotifyComponent.ShowNotify(
                    CreditCurrencyRewardImage, null, amount + " Kredytów"
                    );
            }
        }
        Destroy(gob);
    }