diff options
author | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
commit | 766cdff5ffa72b65d7f106658d1603f47739b2ba (patch) | |
tree | 34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/CardInfoDisplayer.cs |
+ init
Diffstat (limited to 'GameCode/CardInfoDisplayer.cs')
-rw-r--r-- | GameCode/CardInfoDisplayer.cs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/GameCode/CardInfoDisplayer.cs b/GameCode/CardInfoDisplayer.cs new file mode 100644 index 0000000..7c19bfe --- /dev/null +++ b/GameCode/CardInfoDisplayer.cs @@ -0,0 +1,61 @@ +using TMPro; +using UnityEngine; +using UnityEngine.UI; + +public class CardInfoDisplayer : MonoBehaviour +{ + public Color negativeColor; + + public Color positiveColor; + + public GameObject statObject; + + public GameObject grid; + + public GameObject chargeObj; + + public TextMeshProUGUI effectText; + + public TextMeshProUGUI nameText; + + public Image icon; + + public void DrawCard(CardInfoStat[] stats, string cardName, string description = "", Sprite image = null, bool charge = false) + { + if (charge) + { + chargeObj.SetActive(value: true); + chargeObj.transform.SetParent(grid.transform, worldPositionStays: true); + } + if (description != "") + { + effectText.text = description; + effectText.gameObject.SetActive(value: true); + effectText.transform.SetParent(grid.transform, worldPositionStays: true); + } + nameText.text = cardName.ToUpper(); + for (int i = 0; i < stats.Length; i++) + { + GameObject obj = Object.Instantiate(statObject, grid.transform.position, grid.transform.rotation, grid.transform); + obj.SetActive(value: true); + obj.transform.localScale = Vector3.one; + TextMeshProUGUI component = obj.transform.GetChild(0).GetComponent<TextMeshProUGUI>(); + TextMeshProUGUI component2 = obj.transform.GetChild(1).GetComponent<TextMeshProUGUI>(); + component.text = stats[i].stat; + if (stats[i].simepleAmount != 0 && !Optionshandler.showCardStatNumbers) + { + component2.text = stats[i].GetSimpleAmount(); + } + else + { + component2.text = stats[i].amount; + } + component2.color = (stats[i].positive ? positiveColor : negativeColor); + } + if ((bool)image) + { + icon.sprite = image; + } + effectText.transform.position += Vector3.up * 0.3f; + } +} |