예제 #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;
 }