protected override void init() { base.init(); TargetType = TargetType.Card; attack = baseAttack; reputation = baseReputation; cardName.text = fullName; cardDesc.text = description; cardEffect.text = Regex.Replace(effectDesc, "%ATTACK%", "<b>" + attack.ToString() + "</b>", RegexOptions.IgnoreCase); cardEffect.text = Regex.Replace(cardEffect.text, "%REPUTATION%", "<b>" + reputation.ToString() + "</b>", RegexOptions.IgnoreCase); if (GameManager.instance) { switch (place) { case Place.Board: if (!owner.board.Contains(this)) { owner.board.Add(this); } break; case Place.Deck: if (!owner.deck.Contains(this)) { owner.deck.Add(this); } break; case Place.Hand: if (!owner.hand.Contains(this)) { owner.hand.Add(this); } break; } } var costText = "<color=maroon>" + corruptionCost + "</color>"; costText += "\n"; costText += "<color=#0080ffff>" + sexismeCost + "</color>"; cardCost.text = costText; effect = GetComponent <AbstractCardEffect>(); effect.OnInit(); }
// METHODS public Card Create(int cardId) { // TODO: Refactor factory to load card data from a file. // CardEffectFactory.Instance.Serialize(); CardInfo info; AbstractAliveBehavior behavior; info = _cardsDataJson.CardInfos.FirstOrDefault(i => i.Identifier == cardId); AbstractCardEffect effect = CardEffectFactory.Instance.Create(info.CardEffectAssociated); // TODO: Serialize effects. switch (cardId) { case 0: behavior = new AliveBehavior(); break; case 1: behavior = new NotAliveBehavior(); break; case 2: behavior = new NotAliveBehavior(); break; case 3: behavior = new NotAliveBehavior(); break; case 4: behavior = new NotAliveBehavior(); break; default: behavior = new NotAliveBehavior(); return(null); } Card card = new Card(effect) { AliveBehavior = behavior }; info.InstanceId = InstanceIdManager.NextInstanceId; card.CardInfo = info; return(card); }