blob: 3008ae7644dcd6640390002bc591a4df04367874 (
plain)
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
|
using System;
using UnityEngine;
using UnityEngine.UI;
public class CardRarityColor : MonoBehaviour
{
public Color uncommonColor;
public Color rareColor;
public Color uncommonColorOff;
public Color rareColorOff;
private void Awake()
{
CardVisuals componentInParent = GetComponentInParent<CardVisuals>();
componentInParent.toggleSelectionAction = (Action<bool>)Delegate.Combine(componentInParent.toggleSelectionAction, new Action<bool>(Toggle));
}
public void Toggle(bool isOn)
{
CardInfo componentInParent = GetComponentInParent<CardInfo>();
if (componentInParent.rarity == CardInfo.Rarity.Uncommon)
{
GetComponent<Image>().color = (isOn ? uncommonColor : uncommonColorOff);
}
if (componentInParent.rarity == CardInfo.Rarity.Rare)
{
GetComponent<Image>().color = (isOn ? rareColor : rareColorOff);
}
}
}
|