You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class CardDisplay : MonoBehaviour
|
|
{
|
|
|
|
//UI组件
|
|
public Text nameText;
|
|
public Text attackText;
|
|
public Text healthText;
|
|
public Text effectText;
|
|
|
|
public Image backgroundImage;
|
|
|
|
public Card card;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
ShowCard();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void ShowCard()
|
|
{
|
|
nameText.text=card.CardName;
|
|
if(card is MonsterCard)
|
|
{
|
|
var monster = card as MonsterCard;
|
|
attackText.text=monster.attack.ToString();
|
|
healthText.text=monster.healthPoint.ToString();
|
|
|
|
effectText.gameObject.SetActive(false);//隐藏相应物体
|
|
}
|
|
else if(card is SpellCard)
|
|
{
|
|
var spell = card as SpellCard;
|
|
effectText.text = spell.effect;
|
|
|
|
attackText.gameObject.SetActive(false);//隐藏相应物体
|
|
healthText.gameObject.SetActive(false);//隐藏相应物体
|
|
}
|
|
}
|
|
}
|