-
Notifications
You must be signed in to change notification settings - Fork 1
/
MatchRewardHandler.cs
39 lines (35 loc) · 1.14 KB
/
MatchRewardHandler.cs
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MatchRewardHandler : MonoBehaviour
{
public static int lastMatchRank = 0;
public static AdsReward lastMatchReward;
public UILastMatchResult uiLastMatchResult;
private void Start()
{
if (lastMatchRank > 0)
{
if (uiLastMatchResult != null)
uiLastMatchResult.Show();
var currencies = lastMatchReward.currencies;
foreach (var currency in currencies)
{
MonetizationManager.Save.AddCurrency(currency.id, currency.amount);
}
var items = lastMatchReward.items;
foreach (var item in items)
{
MonetizationManager.Save.AddPurchasedItem(item.name);
}
lastMatchRank = 0;
}
}
public static void SetRewards(int rank, MatchReward[] rewards)
{
if (rewards == null || rank - 1 < 0 || rank - 1 >= rewards.Length || lastMatchRank > 0)
return;
lastMatchReward = rewards[rank - 1].RandomReward();
lastMatchRank = rank;
}
}