private IEnumerator CastSpell(CardManagerCardInfo info) { var wrapper = CreateStateWrapper(info.Card.GetComponent <CanBeOwned>().PlayerOwned); info.Spell.OnCast(wrapper); yield return(null); }
/// <summary> /// Assembles a card. /// </summary> /// <param name="uniqueCardTypeId">Unique card type id. See CardInfo.UniqueCardTypeId.</param> /// <param name="player">Whether the card is owned by player.</param> /// <returns>Created card game object.</returns> public GameObject CreateCard(string uniqueCardTypeId, bool player) { GameObject card = new GameObject("card"); GameObject detachHandle = new GameObject("handle"); detachHandle.transform.parent = card.transform; card.AddComponent <CanBeDetached>(); card.AddComponent <CanBeOwned>().PlayerOwned = player; card.AddComponent <CanBeMoved>(); card.AddComponent <CanBeMousedOver>(); card.AddComponent <CanBeInHand>(); card.AddComponent <HasOutline>(); card.AddComponent <CanBeHighlighted>(); card.AddComponent <CanBeDragged>(); card.AddComponent <CanBeInteractedWith>(); card.AddComponent <HasCost>(); var physicalCard = card.AddComponent <HasPhysicalCard>(); VisualManager.Instance.PhysicalCard.AttachPhysicalCardCollider(card); CardManagerCardInfo cardInfo = new CardManagerCardInfo(); cardInfo.Card = card; // Find in type mapping Type cardType; if (TypeMapping.TryGetValue(uniqueCardTypeId, out cardType)) { var iCard = card.AddComponent(cardType) as ICardType; cardInfo.CardType = iCard; if (cardType.GetInterfaces().Contains(typeof(ISpell))) { cardInfo.IsSpell = true; cardInfo.Spell = iCard as ISpell; } // Attempt to apply front and back texture ApplyFrontTexture(physicalCard, iCard.GetInfo()); ApplyBackTexture(physicalCard, player); } AllCards.Add(cardInfo); return(card); }