From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 27 Oct 2023 11:05:14 +0800 Subject: + init --- GameCode/CardRarityColor.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 GameCode/CardRarityColor.cs (limited to 'GameCode/CardRarityColor.cs') diff --git a/GameCode/CardRarityColor.cs b/GameCode/CardRarityColor.cs new file mode 100644 index 0000000..3008ae7 --- /dev/null +++ b/GameCode/CardRarityColor.cs @@ -0,0 +1,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(); + componentInParent.toggleSelectionAction = (Action)Delegate.Combine(componentInParent.toggleSelectionAction, new Action(Toggle)); + } + + public void Toggle(bool isOn) + { + CardInfo componentInParent = GetComponentInParent(); + if (componentInParent.rarity == CardInfo.Rarity.Uncommon) + { + GetComponent().color = (isOn ? uncommonColor : uncommonColorOff); + } + if (componentInParent.rarity == CardInfo.Rarity.Rare) + { + GetComponent().color = (isOn ? rareColor : rareColorOff); + } + } +} -- cgit v1.1-26-g67d0