public void RegisterAbility(NWCard parentCard, IEventDispatcher eventDispatcher, AbilityActivatedDelegate activatedCallBack) { _parentCard = parentCard; if (Type == NWAbilityType.Triggered) { switch (Trigger.Type) { case NWTriggerType.DrawCard: { break; } case NWTriggerType.EnterZone: { eventDispatcher.OnCardChangeZone += CardChangeZoneHandler; break; } case NWTriggerType.StartOfTurn: { break; } case NWTriggerType.None: default: { break; } } OnActivateAbility += activatedCallBack; } }
public bool CanPayForCard(NWCard card) { Debug.Log("can pay for card: " + card.CastingCost + " total mana: " + _totalMana); if (_totalMana - _manaUsedThisTurn >= card.CastingCost) { return true; } return false; }
public override void AddCard(NWCard card) { bool cardExistsInZone = _cardsInZone.Contains(card); base.AddCard (card); if (!cardExistsInZone) { UpdateResourcePool(); _totalMana++; _numberOfResouecesPutThisTurn++; } }
void HandleOnCardChangeZone(NWCard card, NWZone fromZone, NWZone toZone) { ZoneControllerAbstract fromZoneController = _zonesIngames[fromZone]; ZoneControllerAbstract toZoneController = _zonesIngames[toZone]; CardController cardController = _cardsInGame[card]; if (fromZoneController != null && toZoneController != null && card != null) { fromZoneController.RemoveCardFromZone(cardController); toZoneController.AddCardToZone(cardController); } }
public bool IsCardMatchTarget(NWCard card, NWCard target) { bool isMatched = false; switch (Type) { case NWTargetType.Self: { if (card == target) { isMatched = true; } break; } } return isMatched; }
private void CardChangeZoneHandler(NWCard card, NWZone fromZone, NWZone toZone) { if (Type == NWAbilityType.Triggered) { switch (Trigger.Type) { case NWTriggerType.EnterZone: { if (Trigger.ToZone == toZone.Type && Trigger.Target.IsCardMatchTarget(_parentCard, card)) { ResolveAbilityEvent(); } break; } default: { break; } } } }
void HandleOnCardChangeZone(NWCard card, NWZone fromZone, NWZone toZone) { fromZone.RemoveCardFromZone(card); toZone.AddCard(card); }
private void PutCardInResources(NWPlayer player, NWCard card) { if (OnPutCardInResources != null) { OnPutCardInResources(player, card); } }
private void PlayCard(NWPlayer player, NWCard card) { if (OnPlayCard != null) { OnPlayCard(player, card); } }
private void CardDraw(NWPlayer player, NWCard card) { if (OnCardDraw != null) { OnCardDraw(player, card); } }
private void CardChangeZone(NWCard card, NWZone fromZone, NWZone toZone) { if (OnCardChangeZone != null) { OnCardChangeZone(card, fromZone, toZone); } }
public void SetCard(NWCard card) { _card = card; UpdateCard(); }
private void SelectCard(NWCard card) { _selectedCard = card; }
void HandleOnPayForCard(INWPlayer player, NWCard card) { _resourcePool.PayForCard(card); }
public virtual void AddCard(NWCard card) { if (!_cardsInZone.Contains(card)) { _cardsInZone.Add(card); NWEventDispatcher.Instance().DispatchEvent(NWEvent.ZoneUpdated(this)); } }
public static NWEvent Draw(INWPlayer player, NWCard card) { Hashtable data = new Hashtable(); data.Add((int)eEventField.Card, card.CardUniqueID); data.Add((int)eEventField.Player, player.PlayerID); NWEvent eventObject = new NWEvent(NWEventType.DrawCard, data); return eventObject; }
public static NWEvent CardChangeZone(NWCard card, NWZone fromZone, NWZone toZone) { Hashtable data = new Hashtable(); data.Add((int)eEventField.Card , card.CardUniqueID); data.Add((int)eEventField.FromZone, fromZone.ZoneID); data.Add((int)eEventField.ToZone, toZone.ZoneID); NWEvent eventObject = new NWEvent(NWEventType.CardChangeZone, data); return eventObject; }
public virtual void RemoveCardFromZone(NWCard i_Card) { this.RemoveCardsFromZone (new List<NWCard>(){i_Card}); }
public static void SaveCardToFile(NWCard card) { string dir = Application.dataPath; string filePath = Path.Combine(dir + NWCardsLoader.CARDS_RESOURCE_PATH, card.CardID + NWCardsLoader.CARDS_RESOURCE_EXTENSION); Debug.Log("save card: " + filePath); var serializer = new XmlSerializer(typeof(NWCard)); using(var stream = new FileStream(filePath, FileMode.Create)) { serializer.Serialize(stream, card); stream.Close(); } }
public void PayForCard(NWCard card) { _manaUsedThisTurn += card.CastingCost; UpdateResourcePool(); NWEventDispatcher.Instance().DispatchEvent(NWEvent.ZoneUpdated(this)); }
void HandleOnCardCreated(NWCard card) { CardController newCardController = Instantiate(_cardControllerPrefab) as CardController; newCardController.SetCard(card); _cardsInGame.Add(card, newCardController); }
private void CreateNewCard() { NWCard newCard = new NWCard(); newCard.CardTypes = new List<NWCardType>(); newCard.CardColors = new List<NWColor>(); _selectedCard = newCard; }