protected override void DoChanceCardEffect()
    {
        // Get all cards currently in play.
        Card[] allCardsInPlay = GameObject.FindObjectsOfType <Card>();

        // Set health to 0 on each (If a character card)
        for (int i = 0; i < allCardsInPlay.Length; i++)
        {
            CharacterCard characterCard = allCardsInPlay[i] as CharacterCard;
            if (characterCard != null)
            {
                // Multiply stats.
                characterCard.stats.power              *= this.powerModifier;
                characterCard.stats.health             *= this.healthModifer;
                characterCard.stats.timeBetweenAttacks *= this.timeBetweenAttacksModifier;

                // Clamp stats.
                characterCard.stats.power              = Mathf.Max(characterCard.stats.power, 0f);
                characterCard.stats.health             = Mathf.Max(characterCard.stats.health, 0f);
                characterCard.stats.timeBetweenAttacks = Mathf.Max(characterCard.stats.timeBetweenAttacks, 0.1f);   // Leave a little time between attacks?

                // Set card effect color.
                characterCard.SetCardColor(this.colorCharacterCard);
            }
        }
    }
예제 #2
0
    protected override void DoChanceCardEffect()
    {
        // Get all cards currently in play.
        Card[] allCardsInPlay = GameObject.FindObjectsOfType <Card>();

        // Set health to 0 on each (If a character card)
        for (int i = 0; i < allCardsInPlay.Length; i++)
        {
            CharacterCard characterCard = allCardsInPlay[i] as CharacterCard;
            if (characterCard != null)
            {
                characterCard.stats.health = 0f;
                characterCard.SetCardColor(this.colorCharacterCard);
                characterCard.UpdateCardStatsTexts();
            }
        }
    }
예제 #3
0
    public void TakeDamage(CharacterCard characterCardDoingDamage)
    {
        // Do damage to this character's health equal to characterCardDoingDamage power stat.
        this.stats.health -= characterCardDoingDamage.stats.power;
        if (this.stats.health < 0f)
        {
            this.stats.health = 0f;
        }                                                        // Clamp health to greater than zero for safety?

        // Update stats text
        this.UpdateCardStatsTexts();

        // Check if damage has resulted in health been zero (AKA killed)
        if (this.stats.health == 0f)
        {
            Debug.Log(characterCardDoingDamage.cardName + " defeated " + this.cardName);

            // Set defeated characters card color tint to gray.
            this.SetCardColor(Color.gray);
            this.StopAllCoroutines();

            // Reset the winner character color tint back to white.
            characterCardDoingDamage.SetCardColor(Color.white);
            characterCardDoingDamage.StopAllCoroutines();

            // Get gameManager to show the battle winner text.
            this.gameManager.EndBattle(characterCardDoingDamage.cardName + " defeated " + this.cardName);
        }
        else
        {
            Debug.Log(characterCardDoingDamage.cardName + " did " + characterCardDoingDamage.stats.power + " damage to " + this.cardName);

            // Start the damage color fading coroutine.
            StartCoroutine(this.DamageColorCharacter(Color.red));
        }
    }