Example #1
0
    /// <summary>
    /// attempts to remove d charges from random cards in the hand, discarding any that hit 0 charges.
    /// returns how much damage was actually dealt
    /// </summary>
    public int Damage(int d)
    {
        int alreadyDealt = 0;

        while ((currentHandSize > 0) && (alreadyDealt < d))
        {
            //pick a random card in the hand
            CardScript       toDamage  = cards[Random.Range(0, currentHandSize)];
            PlayerCardScript scriptRef = toDamage.GetComponent <PlayerCardScript>();

            //deal damage to it
            int toDeal = Mathf.Min(scriptRef.card.charges, (d - alreadyDealt));
            scriptRef.card.charges -= toDeal;
            scriptRef.updateChargeText();

            //spawn combat text to show the damage
            Vector3 pos = scriptRef.combatTextPosition;
            MessageHandlerScript.instance.spawnPlayerDamageText(pos, toDeal);

            //track it
            alreadyDealt += toDeal;

            if (scriptRef.card.charges == 0)
            {
                toDamage.SendMessage("Discard"); //discard the card if it is out of charges
            }
            else
            {
                scriptRef.updateChargeText(); //otherwise, tell the card to update its header text
            }
        }

        return(alreadyDealt);
    }
 /// <summary>
 /// stores a reference to the card that created this tooltip
 /// </summary>
 private void SetParent(PlayerCardScript parent)
 {
     parentCardScript = parent;
     if (parentCardScript.card.data.cardType == PlayerCardType.tower)
     {
         rangeImage.color = parentCardScript.card.data.towerData.towerColor.toColor();
     }
 }
Example #3
0
 public void removeCardFromHand(PlayerCardScript card)
 {
     this.hand.Remove(card);
 }
Example #4
0
 public void addCardToHand(PlayerCardScript card)
 {
     this.hand.Add(card);
 }