Card爆改!
This commit is contained in:
@@ -10,8 +10,7 @@ namespace Continentis.MainGame.Card
|
||||
{
|
||||
public abstract partial class CardViewBase : UIElementBase, IPointerEnterHandler, IPointerExitHandler
|
||||
{
|
||||
public CardInstance cardInstance;
|
||||
public CardLogicBase cardLogic => cardInstance.cardLogic;
|
||||
public CardInstance card;
|
||||
|
||||
public Canvas canvas;
|
||||
public RectTransform cardTransform;
|
||||
@@ -58,7 +57,7 @@ namespace Continentis.MainGame.Card
|
||||
isHovering = true;
|
||||
|
||||
List<string> allKeywords = new List<string>();
|
||||
allKeywords.AddRange(cardLogic.contentSubmodule.keywords);
|
||||
allKeywords.AddRange(card.contentSubmodule.keywords);
|
||||
keywordList.Enable(allKeywords);
|
||||
}
|
||||
|
||||
@@ -75,20 +74,25 @@ namespace Continentis.MainGame.Card
|
||||
{
|
||||
if (card != null)
|
||||
{
|
||||
cardInstance = card;
|
||||
this.card = card;
|
||||
isOccupied = false;
|
||||
isHovering = false;
|
||||
isSelecting = false;
|
||||
isDuringPlaying = false;
|
||||
}
|
||||
|
||||
cardNameText.text = cardLogic.contentSubmodule.cardName;
|
||||
cardDescriptionText.text = cardLogic.contentSubmodule.interpretedFunctionText;
|
||||
cardImage.sprite = cardLogic.contentSubmodule.cardSprite;
|
||||
|
||||
if (cardLogic.contentSubmodule.cardRarity != Rarity.None)
|
||||
else if (this.card == null)
|
||||
{
|
||||
cardRarityMark.color = MainGameManager.Instance.basePrefabs.GetRarityColor(cardLogic.contentSubmodule.cardRarity);
|
||||
Debug.LogError("CardViewBase Setup called with null card!");
|
||||
return;
|
||||
}
|
||||
|
||||
cardNameText.text = this.card.contentSubmodule.cardName;
|
||||
cardDescriptionText.text = this.card.contentSubmodule.interpretedFunctionText;
|
||||
cardImage.sprite = this.card.contentSubmodule.cardSprite;
|
||||
|
||||
if (this.card.contentSubmodule.cardRarity != Rarity.None)
|
||||
{
|
||||
cardRarityMark.color = MainGameManager.Instance.basePrefabs.GetRarityColor(this.card.contentSubmodule.cardRarity);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -98,21 +102,21 @@ namespace Continentis.MainGame.Card
|
||||
if (string.IsNullOrEmpty(collectionName)) collectionName = "Basic";
|
||||
CardViewCollection collection = MainGameManager.Instance.basePrefabs.cardViewCollections[collectionName];
|
||||
|
||||
List<string> layoutTags = cardLogic.cardData.cardLayoutTags; //TODO:后续可扩展为动态布局标签
|
||||
List<string> layoutTags = this.card.cardData.cardLayoutTags; //TODO:后续可扩展为动态布局标签
|
||||
string firstLayoutTag = layoutTags.Count > 0 ? layoutTags[0] : "Default";
|
||||
if (!collection.cardViews.ContainsKey(firstLayoutTag)) firstLayoutTag = "Default";
|
||||
cardBackground.sprite = collection.cardViews[firstLayoutTag].background;
|
||||
|
||||
cardTypeText.text = cardLogic.contentSubmodule.cardType.ToString();
|
||||
cardTypeText.text = this.card.contentSubmodule.cardType.ToString();
|
||||
|
||||
staminaCostText.rectTransform.parent.gameObject.SetActive(true);
|
||||
staminaCostText.text = cardLogic.attributeSubmodule.GetRoundCurrentAttribute("StaminaCost").ToString();
|
||||
staminaCostText.text = this.card.attributeSubmodule.GetRoundCurrentAttribute("StaminaCost").ToString();
|
||||
|
||||
int manaCost = cardLogic.attributeSubmodule.GetRoundCurrentAttribute("ManaCost");
|
||||
int manaCost = this.card.attributeSubmodule.GetRoundCurrentAttribute("ManaCost");
|
||||
manaCostText.rectTransform.parent.gameObject.SetActive(manaCost > 0);
|
||||
manaCostText.text = manaCost.ToString();
|
||||
|
||||
if (cardLogic.HasKeyword("Unplayable")) // 如果卡牌不能被打出,则隐藏费用文本
|
||||
if (this.card.HasKeyword("Unplayable")) // 如果卡牌不能被打出,则隐藏费用文本
|
||||
{
|
||||
staminaCostText.rectTransform.parent.gameObject.SetActive(false);
|
||||
manaCostText.rectTransform.parent.gameObject.SetActive(false);
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Continentis.MainGame.Card
|
||||
public override void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
base.OnPointerEnter(eventData);
|
||||
cardLogic.contentSubmodule.dirtyMark = true;
|
||||
card.contentSubmodule.dirtyMark = true;
|
||||
if (CombatUIManager.Instance.selectingCardView == null)
|
||||
{
|
||||
canvas.overrideSorting = true;
|
||||
@@ -46,7 +46,7 @@ namespace Continentis.MainGame.Card
|
||||
{
|
||||
if(isOccupied) return;
|
||||
|
||||
if (CombatUIManager.Instance.combatMainPage.handCardSelector.selectedCards.Contains(cardInstance))
|
||||
if (CombatUIManager.Instance.combatMainPage.handCardSelector.selectedCards.Contains(card))
|
||||
{
|
||||
CombatUIManager.Instance.combatMainPage.handCardSelector.Deselect(this);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ namespace Continentis.MainGame.Card
|
||||
{
|
||||
if(isOccupied) return;
|
||||
|
||||
if (CombatUIManager.Instance.combatMainPage.customCardSelector.selectedCards.Contains(cardInstance))
|
||||
if (CombatUIManager.Instance.combatMainPage.customCardSelector.selectedCards.Contains(card))
|
||||
{
|
||||
CombatUIManager.Instance.combatMainPage.customCardSelector.Deselect(this);
|
||||
}
|
||||
@@ -75,14 +75,14 @@ namespace Continentis.MainGame.Card
|
||||
isSelecting = true;
|
||||
CombatUIManager.Instance.selectingCardView = this;
|
||||
|
||||
cardInstance.user = CombatMainManager.Instance.currentCharacter;
|
||||
cardLogic.DetectTargetsValidity(out validTargets, out conditionNotMetTargets, out invalidTargets);
|
||||
card.user = CombatMainManager.Instance.currentCharacter;
|
||||
card.DetectTargetsValidity(out validTargets, out conditionNotMetTargets, out invalidTargets);
|
||||
|
||||
if (cardLogic.attributeSubmodule.targetCount == 1)
|
||||
if (card.attributeSubmodule.targetCount == 1)
|
||||
{
|
||||
CombatUIManager.Instance.arrowsPage.GeneratePointerArrow(cardTransform.position, cardTransform.position, true);
|
||||
}
|
||||
else if (cardLogic.attributeSubmodule.targetCount == -1)
|
||||
else if (card.attributeSubmodule.targetCount == -1)
|
||||
{
|
||||
CombatUIManager.Instance.arrowsPage.GeneratePointerArrow(cardTransform.position, cardTransform.position, true);
|
||||
|
||||
@@ -105,16 +105,16 @@ namespace Continentis.MainGame.Card
|
||||
// 如果悬停视图不是空的,说明鼠标移动到了一个新的目标上
|
||||
if (CombatUIManager.Instance.hoveringCharacterView != null)
|
||||
{
|
||||
cardLogic.eventSubmodule.onTargeting(CombatUIManager.Instance.hoveringCharacterView.character);
|
||||
card.Targeting(CombatUIManager.Instance.hoveringCharacterView.character);
|
||||
currentTargetingCharacterView = CombatUIManager.Instance.hoveringCharacterView;
|
||||
}
|
||||
else // 悬停视图是空的,说明鼠标离开了之前的目标
|
||||
{
|
||||
cardLogic.eventSubmodule.onUntargeting();
|
||||
card.Untargeting();
|
||||
currentTargetingCharacterView = null;
|
||||
}
|
||||
|
||||
cardLogic.contentSubmodule.dirtyMark = true;
|
||||
card.contentSubmodule.dirtyMark = true;
|
||||
}
|
||||
|
||||
Vector3 startPosition = cardTransform.position + new Vector3(0, cardTransform.rect.height * cardTransform.lossyScale.y / 2, 0);
|
||||
@@ -124,7 +124,7 @@ namespace Continentis.MainGame.Card
|
||||
CombatCharacterViewBase hoveringCharacterView = CombatUIManager.Instance.hoveringCharacterView;
|
||||
CharacterBase hoveringCharacter = hoveringCharacterView != null ? hoveringCharacterView.character : null;
|
||||
|
||||
if (cardLogic.attributeSubmodule.targetCount == 1)
|
||||
if (card.attributeSubmodule.targetCount == 1)
|
||||
{
|
||||
mainPointerArrow.SetArrow(startPosition, endPosition);
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Continentis.MainGame.Card
|
||||
mainPointerArrow.SetColor(Color.white);
|
||||
}
|
||||
}
|
||||
else if (cardLogic.attributeSubmodule.targetCount == -1)
|
||||
else if (card.attributeSubmodule.targetCount == -1)
|
||||
{
|
||||
mainPointerArrow.SetArrow(startPosition, endPosition);
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace Continentis.MainGame.Card
|
||||
CombatUIManager.Instance.arrowsPage.otherPointerArrows.ForEach(arrow => { arrow.gameObject.SetActive(false); });
|
||||
}
|
||||
}
|
||||
else if (cardLogic.attributeSubmodule.targetCount == 0)
|
||||
else if (card.attributeSubmodule.targetCount == 0)
|
||||
{
|
||||
Vector3 cardPosition = SpaceConverter.ScreenPointToUIPoint(arrowCanvasRect, eventData.position, uiCamera);
|
||||
cardTransform.position = cardPosition;
|
||||
@@ -234,21 +234,21 @@ namespace Continentis.MainGame.Card
|
||||
CombatUIManager.Instance.selectingCardView = null;
|
||||
canvas.overrideSorting = false;
|
||||
canvas.sortingOrder = 0;
|
||||
cardLogic.eventSubmodule.onUntargeting();
|
||||
cardLogic.contentSubmodule.dirtyMark = true;
|
||||
card.eventSubmodule.onUntargeting();
|
||||
card.contentSubmodule.dirtyMark = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (cardLogic.HasKeyword("Unplayable")) // 如果有“不能打出”关键词,直接返回
|
||||
if (card.HasKeyword("Unplayable")) // 如果有“不能打出”关键词,直接返回
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!cardLogic.HasKeyword("TargetSelf"))
|
||||
if (!card.HasKeyword("TargetSelf"))
|
||||
{
|
||||
if (!validTargets.Contains(hoveringCharacter))
|
||||
{
|
||||
@@ -258,14 +258,14 @@ namespace Continentis.MainGame.Card
|
||||
}
|
||||
|
||||
// 根据目标类型,打出卡牌
|
||||
if (cardLogic.attributeSubmodule.targetCount == 1)
|
||||
if (card.attributeSubmodule.targetCount == 1)
|
||||
{
|
||||
if (hoveringCharacter != null && validTargets.Contains(hoveringCharacter))
|
||||
{
|
||||
if (!cardLogic.Play(new List<CharacterBase>() { hoveringCharacter }))
|
||||
if (!card.Play(new List<CharacterBase>() { hoveringCharacter }))
|
||||
{
|
||||
cardLogic.eventSubmodule.onUntargeting();
|
||||
cardLogic.contentSubmodule.dirtyMark = true;
|
||||
card.eventSubmodule.onUntargeting();
|
||||
card.contentSubmodule.dirtyMark = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -275,18 +275,18 @@ namespace Continentis.MainGame.Card
|
||||
bool isInDropZone = RectTransformUtility.RectangleContainsScreenPoint(dropZone, eventData.position, uiCamera);
|
||||
List<CharacterBase> targetList = new List<CharacterBase>();
|
||||
|
||||
if (cardLogic.attributeSubmodule.targetCount == -1)
|
||||
if (card.attributeSubmodule.targetCount == -1)
|
||||
{
|
||||
targetList.AddRange(validTargets);
|
||||
}
|
||||
else if (cardLogic.HasKeyword("TargetSelf") && cardLogic.attributeSubmodule.targetCount == 0)
|
||||
else if (card.HasKeyword("TargetSelf") && card.attributeSubmodule.targetCount == 0)
|
||||
{
|
||||
targetList.Add(cardLogic.user);
|
||||
targetList.Add(card.user);
|
||||
}
|
||||
|
||||
if (!isInDropZone)
|
||||
{
|
||||
cardLogic.Play(targetList);
|
||||
card.Play(targetList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user