Ejemplo n.º 1
0
    private IEnumerator Fight()
    {
        if (fighter1Properties.action == "Strike")
        {
            yield return(new WaitForSeconds(0.5f));

            if (fighter2Properties.action == "Focus")
            {
                _cardEffects.FocusBreak(fighter2);
                yield return(new WaitForSeconds(1f));
            }
            //play blocked animations
            for (int i = 0; i < fighter1Properties.numberOfCards; i++)
            {
                if (fighter1Properties.blockedCards[i] == true)
                {
                    Transform cardslot = fighter1.Find("Cardslot" + i.ToString());
                    cardslot.GetComponent <Animator>().Play("FrameGlowRed");
                    yield return(new WaitForSeconds(0.5f));
                }
            }
            for (int i = 0; i < fighter1Properties.numberOfCards; i++)
            {
                //if card not blocked
                if (!fighter1Properties.blockedCards[i])
                {
                    _cardEffects.DamagePlayer(fighter2, fighter1Properties.currentCardDamage[i]);
                    //play card animation
                    fighter1.Find("Cardslot" + i.ToString()).GetComponent <Animator>()
                    .Play("FrameGlowGreen");
                    yield return(new WaitForSeconds(0.5f));
                }
            }
        }

        if (fighter2Properties.action == "Strike")
        {
            yield return(new WaitForSeconds(0.5f));

            if (fighter1Properties.action == "Focus")
            {
                _cardEffects.FocusBreak(fighter1);
                yield return(new WaitForSeconds(1f));
            }
            for (int i = 0; i < fighter2Properties.numberOfCards; i++)
            {
                if (fighter2Properties.blockedCards[i] == true)
                {
                    Transform cardslot = fighter2.Find("Cardslot" + i.ToString());
                    cardslot.GetComponent <Animator>().Play("FrameGlowRed");
                    yield return(new WaitForSeconds(0.5f));
                }
            }
            for (int i = 0; i < fighter2Properties.numberOfCards; i++)
            {
                //if card not blocked
                if (!fighter2Properties.blockedCards[i])
                {
                    _cardEffects.DamagePlayer(fighter1, fighter2Properties.currentCardDamage[i]);
                    //play card animation
                    fighter2.Find("Cardslot" + i.ToString()).GetComponent <Animator>()
                    .Play("FrameGlowGreen");
                    yield return(new WaitForSeconds(0.5f));
                }
            }
        }
        //MIDFIGHT RESET
        _cardEffects.RemoveProtection(fighter1);
        _cardEffects.RemoveProtection(fighter2);
        _cardEffects.RemoveNullify(fighter1);
        _cardEffects.RemoveNullify(fighter2);
        if (_cardEffects.ResetDamageModifier(fighter1)
            | _cardEffects.ResetDamageModifier(fighter2))
        {
            yield return(new WaitForSeconds(0.5f));
        }
        StartCoroutine(ActivateEffects("After"));
    }