Donations
#
Listing available donations
#
You can list available donations.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
| foreach (var donationKvp in economySystem.Donations)
{
var id = donationKvp.Key;
var donation = donationKvp.Value;
Debug.Log($"Donation {id} - {donation.Name}. Rewards: ");
foreach (var reward in donation.RecipientRewards)
{
foreach (var currency in reward.Currencies)
{
Debug.Log($"{currency.Key}: {currency.Value}");
}
foreach (var item in reward.Items)
{
Debug.Log($"{item.Key}: {item.Value}");
}
foreach (var energy in reward.Energies)
{
Debug.Log($"{energy.Key}: {energy.Value}");
}
}
}
|
You can also list donations in several other ways.
By donation ids:
1
| var donationsKvp = await economySystem.GetDonationsAsync(new [] { "<donationId1>", "<donationId2>" });
|
By team (using the Team System):
1
2
| var teamMembers = teamsSystem.TeamMembers;
var donationsKvp = economySystem.GetDonationsAsync(teamMembers);
|
Or by friends list:
1
2
| var friendsList = await nakamaSystem.Client.ListFriendsAsync(nakamaSystem.Session);
var donationsKvp = await economySystem.GetDonationsAsync(friendsList);
|
Requesting a donation
#
You can request a donation for a user.
1
| await economySystem.RequestDonationAsync("<donationId1>");
|
Donating to a user
#
You can make a donation to a particular user.
1
| await economySystem.DonateAsync("<donationId>", "<targetUserId>");
|
Claiming rewards for donations
#
You can claim rewards for completed donations.
1
| await economySystem.ClaimDonationsAsync(new[] {"<donationId1>", "<donationId2>"});
|