Skip to content

Commit 41e4784

Browse files
AlmightyMikkelkirre-bylund
authored andcommitted
fix: unintended rebase and missing commit
The changes I made was not in the last commit, not entirely sure how, but they're here
1 parent 7aa6b67 commit 41e4784

File tree

2 files changed

+46
-30
lines changed

2 files changed

+46
-30
lines changed

Samples.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Samples~/LootLockerExamples/8 - Virtual Currency Purchases/LootLockerVirtualStore.cs

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ public class LootLockerVirtualStore : MonoBehaviour
1616
public string catalogKey = "";
1717
public string walletID = "";
1818

19-
private string currencyCode;
19+
private string playerUlid = "";
20+
21+
private string currencyCode = "gld";
22+
private string currencyDisplayCode = "";
23+
private string currencyIdentifier = "";
24+
25+
private string grantCurrencyAmount = "200";
2026

2127
public void Awake()
2228
{
@@ -33,12 +39,37 @@ public void Awake()
3339
{
3440
if (!response.success)
3541
{
36-
Debug.Log("Could not start guest session");
42+
Debug.Log("Could not start guest session\nError: " + response.errorData.ToString());
43+
return;
44+
}
45+
46+
playerUlid = response.player_ulid;
47+
48+
FetchGameCurrencies();
49+
});
50+
}
51+
52+
public void FetchGameCurrencies()
53+
{
54+
LootLockerSDKManager.ListCurrencies((response) =>
55+
{
56+
57+
if (!response.success)
58+
{
59+
Debug.Log("Could not find Currencies\nError: " + response.errorData.ToString());
3760
return;
3861
}
39-
FetchPlayerWallet(response.player_ulid);
40-
FetchVirtualProductsFromCatalog();
4162

63+
foreach (var currency in response.currencies)
64+
{
65+
if (currency.code == currencyCode)
66+
{
67+
currencyIdentifier = currency.id;
68+
currencyDisplayCode = currency.code.ToUpper() + ": ";
69+
}
70+
}
71+
72+
FetchPlayerWallet(playerUlid);
4273
});
4374
}
4475

@@ -48,13 +79,15 @@ public void FetchPlayerWallet(string ulid)
4879
{
4980
if (!response.success)
5081
{
51-
Debug.Log("Could not start guest session");
82+
Debug.Log("Could not Get Players Wallet\nError: " + response.errorData.ToString());
5283
return;
5384
}
5485

5586
walletID = response.id;
56-
GiveGold();
5787

88+
FetchVirtualProductsFromCatalog();
89+
90+
GiveGold();
5891
});
5992
}
6093

@@ -64,36 +97,27 @@ public void GetPlayerGold()
6497
{
6598
if (!response.success)
6699
{
67-
Debug.Log("Could not list balances");
100+
Debug.Log("Could not list balances\nError: " + response.errorData.ToString());
68101
return;
69102
}
70103

71-
//Default to hard coded variables
72-
if(response.balances.Length <= 0)
73-
{
74-
currencyCode = "GLD: ";
75-
return;
76-
}
77-
currencyCode = response.balances[0].currency.code.ToUpper() + ": ";
104+
goldAmount.text = currencyDisplayCode + response.balances[0].amount;
78105

79-
goldAmount.text = currencyCode + response.balances[0].amount;
80106
});
81107
}
82108

83-
84109
public void FetchVirtualProductsFromCatalog()
85110
{
86111
LootLockerSDKManager.ListCatalogItems(catalogKey, 0, "", (response) =>
87112
{
88113
if (!response.success)
89114
{
90-
Debug.Log("Could not fetch Catalog Items");
115+
Debug.Log("Could not fetch Catalog Items\nError: " + response.errorData.ToString());
91116
return;
92117
}
93118

94119
foreach (var item in response.entries)
95120
{
96-
Debug.Log("Item: " + item.entity_name + " | " + item.prices[0].display_amount);
97121
var obj = Instantiate(virtualPurchaseProductPrefab, storeUI);
98122
obj.GetComponent<VirtualPurchaseProduct>().CreateProduct(item.entity_name,
99123
item.prices[0].amount,
@@ -104,17 +128,17 @@ public void FetchVirtualProductsFromCatalog()
104128

105129
public void GiveGold()
106130
{
107-
LootLockerSDKManager.CreditBalanceToWallet(walletID, "01J3MK8BTC6JC9850YTXGXP1H5", "200", (response) =>
131+
LootLockerSDKManager.CreditBalanceToWallet(walletID, currencyIdentifier, grantCurrencyAmount, (response) =>
108132
{
109133
if (!response.success)
110134
{
111-
Debug.Log("Could not Credit gold");
135+
Debug.Log("Could not Credit gold\nError: " + response.errorData.ToString());
112136
return;
113137
}
114138

115-
goldAmount.text = currencyCode + response.amount;
139+
goldAmount.text = currencyDisplayCode + response.amount;
116140
GetPlayerGold();
117141
});
118142
}
119143
}
120-
}
144+
}

0 commit comments

Comments
 (0)