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/CardInfoDisplayer.cs | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 GameCode/CardInfoDisplayer.cs (limited to 'GameCode/CardInfoDisplayer.cs') 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 component2 = obj.transform.GetChild(1).GetComponent(); + 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; + } +} -- cgit v1.1-26-g67d0