Exemplo n.º 1
0
        private BlockInstance GetBlockInstanceOfAttacker(CardInstance cardAttacker)
        {
            BlockInstance result = null;

            _blockInstances.TryGetValue(cardAttacker, out result);
            return(result);
        }
Exemplo n.º 2
0
        public bool CanUseCard(CardInstance cardInstance)
        {
            // TODO: fix tries to play cards on enemies battle without special abilities.
            if (!handCards.Contains(cardInstance) || !isHumanPlayer)
            {
                return(false);
            }

            bool result = false;
            var  card   = cardInstance.cardViz.card;

            if (card.cardType is CreatureCard || card.cardType is SpellCard)
            {
                var currentResources = NonUsedCards();
                result = card.cardCost <= currentResources;
            }
            else if (card.cardType is ResourceCard)
            {
                if (resourcesPerTurn - resourcesDroppedThisTurn > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        private BlockInstance GetBlockInstanceOfAttacker(CardInstance cardAttacker,
                                                         Dictionary <CardInstance, BlockInstance> blockInstances)
        {
            BlockInstance result = null;

            blockInstances.TryGetValue(cardAttacker, out result);
            return(result);
        }
Exemplo n.º 4
0
        public void SetCardOnBattleLine(CardInstance cardInstance)
        {
            var position = cardInstance.cardViz.gameObject.transform.position;

            Settings.SetParentForCard(cardInstance.cardViz.gameObject.transform,
                                      battleLine.value.transform);
            position.y = cardInstance.cardViz.gameObject.transform.position.y;
            position.z = cardInstance.cardViz.gameObject.transform.position.z;
            cardInstance.cardViz.gameObject.transform.position = position;
        }
Exemplo n.º 5
0
        public static void DropCreatureCard(Transform cardTransform, Transform parent,
                                            CardInstance cardInstance)
        {
            // Execute any special card abilities on drop.

            SetParentForCard(cardTransform, parent);
            cardInstance.SetFlatfooted(true);

            gameManager.currentPlayer.UseResourceCards(cardInstance.cardViz.card.cardCost);
            gameManager.currentPlayer.DropCard(cardInstance);
        }
Exemplo n.º 6
0
        public void CardToGraveyard(CardInstance cardInstance)
        {
            if (handCards.Contains(cardInstance))
            {
                handCards.Remove(cardInstance);
            }
            if (cardsDown.Contains(cardInstance))
            {
                cardsDown.Remove(cardInstance);
            }

            // No need to remove from attackingCards because it's subset of cardsDown.
        }
Exemplo n.º 7
0
        public bool TypeAllowsForAttack(CardInstance cardInstance)
        {
            // e.g. Flying type can attack even if flatfooted:
            ///bool result = logic.Execute(cardInstance) -> if (cardInstance.isFlatfooted);
            ///cardInstance.isFlatfooted = false;
            ///return true;

            if (canAttack)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 8
0
        public void PutCardToGraveyard(CardInstance cardInstance)
        {
            Debug.Log("Called put to graveyard method.");
            cardInstance.playerOwner.CardToGraveyard(cardInstance);

            _graveyardCards.Add(cardInstance);

            const int offset   = 5;
            var       position = Vector3.zero;

            position.x -= _graveyardCards.Count * offset;
            position.z  = _graveyardCards.Count * offset;

            Settings.SetParentForCard(cardInstance.transform, graveyardVariable.value, position);
        }
Exemplo n.º 9
0
        public void DropCard(CardInstance cardInstance, bool registerEvent = true)
        {
            if (handCards.Contains(cardInstance))
            {
                handCards.Remove(cardInstance);
            }

            if (!cardsDown.Contains(cardInstance))
            {
                cardsDown.Add(cardInstance);
            }

            if (registerEvent)
            {
                Settings.RegisterEvent(username + " used " + cardInstance.cardViz.card.name +
                                       " for " + cardInstance.cardViz.card.cardCost +
                                       " resources.");
            }
        }
Exemplo n.º 10
0
        public bool CanBeBlocked(CardInstance cardBlocker, ref int count)
        {
            bool result = playerOwner.attackingCards.Contains(this);

            if (result && cardBlocker.CanAttack())
            {
                result = true;

                // We can add additional logic when card is attempted to block.

                if (result)
                {
                    Settings.gameManager.AddBlockInstance(this, cardBlocker, ref count);
                }
                return(result);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 11
0
        public void AddBlockInstance(CardInstance cardAttacker, CardInstance cardBlocker,
                                     ref int count)
        {
            var blockInstance = GetBlockInstanceOfAttacker(cardAttacker);

            if (blockInstance == null)
            {
                blockInstance = new BlockInstance
                {
                    cardAttacker = cardAttacker
                };
                _blockInstances.Add(cardAttacker, blockInstance);
            }

            if (!blockInstance.cardBlockers.Contains(cardBlocker))
            {
                blockInstance.cardBlockers.Add(cardBlocker);
                cardBlocker.wasUsed = true;
            }

            count = blockInstance.cardBlockers.Count;
        }
Exemplo n.º 12
0
 public void SetCardDown(CardInstance cardInstance)
 {
     Settings.SetParentForCard(cardInstance.cardViz.gameObject.transform,
                               downGrid.value.transform);
 }
Exemplo n.º 13
0
 public void Set(CardInstance cardInstance)
 {
     value = cardInstance;
 }