示例#1
0
        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;
            }
        }
示例#2
0
 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;
 }
示例#3
0
 public override void AddCard(NWCard card)
 {
     bool cardExistsInZone = _cardsInZone.Contains(card);
     base.AddCard (card);
     if (!cardExistsInZone)
     {
         UpdateResourcePool();
         _totalMana++;
         _numberOfResouecesPutThisTurn++;
     }
 }
示例#4
0
    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);
        }
    }
示例#5
0
        public bool IsCardMatchTarget(NWCard card, NWCard target)
        {
            bool isMatched = false;
            switch (Type)
            {
            case NWTargetType.Self:
            {
                if (card == target)
                {
                    isMatched = true;
                }
                break;
            }
            }

            return isMatched;
        }
示例#6
0
 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;
         }
         }
     }
 }
示例#7
0
 void HandleOnCardChangeZone(NWCard card, NWZone fromZone, NWZone toZone)
 {
     fromZone.RemoveCardFromZone(card);
     toZone.AddCard(card);
 }
示例#8
0
 private void PutCardInResources(NWPlayer player, NWCard card)
 {
     if (OnPutCardInResources != null)
     {
         OnPutCardInResources(player, card);
     }
 }
示例#9
0
 private void PlayCard(NWPlayer player, NWCard card)
 {
     if (OnPlayCard != null)
     {
         OnPlayCard(player, card);
     }
 }
示例#10
0
 private void CardDraw(NWPlayer player, NWCard card)
 {
     if (OnCardDraw != null)
     {
         OnCardDraw(player, card);
     }
 }
示例#11
0
 private void CardChangeZone(NWCard card, NWZone fromZone, NWZone toZone)
 {
     if (OnCardChangeZone != null)
     {
         OnCardChangeZone(card, fromZone, toZone);
     }
 }
示例#12
0
 public void SetCard(NWCard card)
 {
     _card = card;
     UpdateCard();
 }
示例#13
0
 private void SelectCard(NWCard card)
 {
     _selectedCard = card;
 }
示例#14
0
 void HandleOnPayForCard(INWPlayer player, NWCard card)
 {
     _resourcePool.PayForCard(card);
 }
示例#15
0
 public virtual void AddCard(NWCard card)
 {
     if (!_cardsInZone.Contains(card))
     {
         _cardsInZone.Add(card);
         NWEventDispatcher.Instance().DispatchEvent(NWEvent.ZoneUpdated(this));
     }
 }
示例#16
0
 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;
 }
示例#17
0
 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;
 }
示例#18
0
 public virtual void RemoveCardFromZone(NWCard i_Card)
 {
     this.RemoveCardsFromZone (new List<NWCard>(){i_Card});
 }
示例#19
0
 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();
     }
 }
示例#20
0
 public void PayForCard(NWCard card)
 {
     _manaUsedThisTurn += card.CastingCost;
     UpdateResourcePool();
     NWEventDispatcher.Instance().DispatchEvent(NWEvent.ZoneUpdated(this));
 }
示例#21
0
 void HandleOnCardCreated(NWCard card)
 {
     CardController newCardController = Instantiate(_cardControllerPrefab) as CardController;
     newCardController.SetCard(card);
     _cardsInGame.Add(card, newCardController);
 }
示例#22
0
 private void CreateNewCard()
 {
     NWCard newCard = new NWCard();
     newCard.CardTypes = new List<NWCardType>();
     newCard.CardColors = new List<NWColor>();
     _selectedCard = newCard;
 }