// Update is called once per frame void Update() { if (referenceCard != null) { cardDesc = referenceCard.cardData; } if (cardDesc != null) { cardName.text = cardDesc.GetCardName(); typeText.text = CardParsing.Parse(cardDesc.GetCardType()).ToUpper(); int manaVal = cardDesc.GetManaCost(); int baseManaVal = cardDesc.GetBaseManaCost(); mana.text = manaVal.ToString(); if (manaVal < baseManaVal) { mana.text = "<color=green>" + mana.text + "</color>"; } else if (manaVal > baseManaVal) { mana.text = "<color=red>" + mana.text + "</color>"; } string effectText = ""; creatureFields.SetActive(false); switch (cardDesc.GetCardType()) { case CardType.CREATURE: creatureFields.SetActive(true); creatureType.text = CardParsing.Parse(cardDesc.GetCreatureType()).ToUpper(); int atkVal = cardDesc.GetAttackVal(); int baseAtkVal = cardDesc.GetBaseAttackVal(); int hpVal = cardDesc.GetHealthVal(); int hpBaseVal = cardDesc.GetBaseHealthVal(); atk.text = atkVal.ToString(); def.text = hpVal.ToString(); if (atkVal > baseAtkVal) { atk.text = "<color=green>" + atk.text + "</color>"; } else if (atkVal < baseAtkVal) { atk.text = "<color=red>" + atk.text + "</color>"; } if (hpVal > hpBaseVal) { def.text = "<color=green>" + def.text + "</color>"; } else if (hpVal < hpBaseVal) { def.text = "<color=red>" + def.text + "</color>"; } bool first = true; SortedSet <KeywordAttribute> baseAttributes = cardDesc.GetBaseAttributes(); foreach (KeywordAttribute a in cardDesc.GetAttributes()) { if (first) { first = !first; } else { effectText += ", "; } if (baseAttributes.Contains(a)) { effectText += CardParsing.Parse(a); } else { effectText += "<color=#009A35ff>" + CardParsing.Parse(a) + "</color>"; } } if (!first) { effectText += "\n\n"; } templateImage.sprite = cardTemplates[0]; break; case CardType.SPELL: templateImage.sprite = cardTemplates[1]; break; case CardType.TRAP: templateImage.sprite = cardTemplates[2]; break; } foreach (CardEffectDescription effect in cardDesc.GetCardEffects()) { string effectString = effect.CardText(); effectString += '\n'; effectText += effectString; } textBox.text = effectText; if (cardDesc.GetImage()) { Sprite[] sprites = Resources.LoadAll <Sprite>(GameConstants.PATHS.CARD_IMAGES + cardDesc.GetImage().name); cardImage.sprite = sprites[0]; } } }
private bool IsTargettableCard(TargettingQuery targetQuery) { bool valid = false; ITargettingDescription desc = targetQuery.targettingDesc; if (desc.targettingType == TargettingType.EXCEPT) { ExceptTargetDescription exceptDesc = (ExceptTargetDescription)desc; desc = exceptDesc.targetDescription; } switch (desc.targetType) { case TargetType.CARDS: valid = true; break; case TargetType.CREATURE_CARDS: valid = cardData.GetCardType() == CardType.CREATURE; break; case TargetType.SPELL_CARDS: valid = cardData.GetCardType() == CardType.SPELL; break; case TargetType.TRAP_CARDS: valid = cardData.GetCardType() == CardType.TRAP; break; } if (valid) { IQualifiableTargettingDescription qualifiableDesc = (IQualifiableTargettingDescription)desc; if (qualifiableDesc != null) { valid = qualifiableDesc.GetPlayerAlignment() == Alignment.NEUTRAL || (qualifiableDesc.GetPlayerAlignment() == GetAlignmentToPlayer(targetQuery.requestingPlayer)); IQualifierDescription qualifier = qualifiableDesc.qualifier; if (valid && qualifier != null) { switch (qualifier.qualifierType) { case QualifierType.NONE: break; case QualifierType.CREATURE_TYPE: { CreatureTypeQualifierDescription creatureQualifier = (CreatureTypeQualifierDescription)qualifier; valid = creatureQualifier.creatureType == cardData.GetCreatureType(); } break; case QualifierType.CARD_TYPE: { CardTypeQualifierDescription cardTypeQualifier = (CardTypeQualifierDescription)qualifier; valid = cardTypeQualifier.cardType == cardData.GetCardType(); } break; default: valid = false; break; } } } } return(valid); }