105 lines
3.5 KiB
C#
105 lines
3.5 KiB
C#
using System;
|
|
using Sirenix.OdinInspector;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.InputSystem;
|
|
using UnityEngine.Serialization;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Continentis.MainGame.Card
|
|
{
|
|
public abstract partial class CardViewBase : UIElementBase, IPointerEnterHandler, IPointerExitHandler
|
|
{
|
|
public CardInstance cardInstance;
|
|
public CardLogicBase cardLogic => cardInstance.cardLogic;
|
|
|
|
public Canvas canvas;
|
|
public RectTransform cardTransform;
|
|
|
|
public TMP_Text cardNameText, cardDescriptionText;
|
|
public TMP_Text staminaCostText;
|
|
public TMP_Text manaCostText;
|
|
public TMP_Text cardTypeText;
|
|
public Image cardImage;
|
|
public Image cardRarityMark;
|
|
public CardViewKeywordList keywordList;
|
|
}
|
|
|
|
public partial class CardViewBase
|
|
{
|
|
public bool isOccupied;
|
|
public bool isHovering;
|
|
public bool isSelecting;
|
|
public bool isDuringPlaying;
|
|
|
|
private void Update()
|
|
{
|
|
if (isHovering)
|
|
{
|
|
keywordList.Scroll(Mouse.current.scroll.y.ReadValue());
|
|
}
|
|
}
|
|
|
|
public virtual void OnPointerEnter(PointerEventData eventData)
|
|
{
|
|
if(isDuringPlaying) return;
|
|
|
|
isHovering = true;
|
|
keywordList.Enable(cardInstance.cardLogic.contentSubmodule.keywords);
|
|
}
|
|
|
|
public virtual void OnPointerExit(PointerEventData eventData)
|
|
{
|
|
isHovering = false;
|
|
keywordList.Disable();
|
|
}
|
|
}
|
|
|
|
public partial class CardViewBase
|
|
{
|
|
public virtual void Setup(CardInstance card = null)
|
|
{
|
|
if (card != null)
|
|
{
|
|
cardInstance = card;
|
|
}
|
|
|
|
cardNameText.text = cardLogic.contentSubmodule.cardName;
|
|
cardDescriptionText.text = cardLogic.contentSubmodule.cardDescription;
|
|
cardImage.sprite = cardLogic.contentSubmodule.cardSprite;
|
|
|
|
if (cardLogic.contentSubmodule.cardRarity != CardRarity.None)
|
|
{
|
|
cardRarityMark.color = cardLogic.contentSubmodule.cardRarity switch
|
|
{
|
|
CardRarity.Common => Color.white,
|
|
CardRarity.Uncommon => new Color(0.2f, 0.7f, 0.2f), // 绿色
|
|
CardRarity.Rare => new Color(0f, 0.5f, 1f), // 蓝色
|
|
CardRarity.Epic => new Color(0.6f, 0f, 0.8f), // 紫色
|
|
CardRarity.Legendary => new Color(1f, 0.5f, 0f), // 橙色
|
|
CardRarity.Divine => new Color(1f, 0.84f, 0f), // 金色
|
|
_ => Color.grey
|
|
};
|
|
}
|
|
else
|
|
{
|
|
cardRarityMark.gameObject.SetActive(false);
|
|
}
|
|
|
|
cardTypeText.text = cardLogic.contentSubmodule.cardType.ToString();
|
|
|
|
staminaCostText.text = cardLogic.attributeSubmodule.GetRoundCurrentAttribute("StaminaCost").ToString();
|
|
|
|
int manaCost = cardLogic.attributeSubmodule.GetRoundCurrentAttribute("ManaCost");
|
|
manaCostText.rectTransform.parent.gameObject.SetActive(manaCost > 0);
|
|
manaCostText.text = manaCost.ToString();
|
|
|
|
if (cardLogic.HasTag("Unplayable")) // 如果卡牌不能被打出,则隐藏费用文本
|
|
{
|
|
staminaCostText.rectTransform.parent.gameObject.SetActive(false);
|
|
manaCostText.rectTransform.parent.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
} |