using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public enum PlayableState { Unplayable, Playable, IntendedToPlay, } public class CardUI : MonoBehaviour { public Text nameText; public Text typeText; public Text costText; public Image artImage; public Text effectText; private bool hidden; public void Init(BaseCard card) { this.hidden = false; this.nameText.text = card.GetDisplayName(); this.typeText.text = card.GetDisplayType(); if (card.Type != CardType.Emotion) { this.costText.text = "" + card.GetCost(); } else { this.costText.text = ""; } this.effectText.text = card.GetEffectText(); Sprite sprite = Resources.Load(GetCardArtResourcePath(card)); this.artImage.sprite = sprite; } public void InitHidden() { this.hidden = true; Color BROWN = new Color(0.14f, 0.09f, 0.04f); this.nameText.text = "????"; this.typeText.text = "????"; this.costText.text = "????"; this.effectText.text = "????"; this.GetComponent().color = BROWN; this.artImage.color = BROWN; } public string GetCardArtResourcePath(BaseCard card) { return "CardArt/" + (card.Owner.Team == TeamChoice.Heroes? "Hero" : "Monster") + card.StringId; } // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } public PlayableState State { set { if (this.hidden) return; if (value == PlayableState.Unplayable) { this.GetComponent().color = Color.grey; this.artImage.color = Color.grey; } else if (value == PlayableState.Playable) { this.GetComponent().color = Color.white; this.artImage.color = Color.white; } else if (value == PlayableState.IntendedToPlay) { this.GetComponent().color = Color.yellow; this.artImage.color = Color.yellow; } else { throw new System.ArgumentException("Unknown PlayableState " + value); } } } }