Пример #1
0
    public IEnumerator PlayerAttack()
    {
        battleUI.CombatPanel.SetActive(false);
        battleUI.DecisionPanel.SetActive(true);
        battleUI.attackSlider.value = 0;
        state = BattleState.ATTACK;
        int counter = playerActions.Count;

        for (int i = 0; i < counter; i++)
        {
            bool  isDead          = false;
            float damageReduction = 1f;
            float enemyCurHealth  = enemyUnit.curHealth;
            if (enemyActions.Contains(3) && enemyUnit.currentShieldHits <= 2)
            {
                if (enemyUnit.currentShieldHits == 0)
                {
                    damageReduction = 0.2f;
                }
                else if (enemyUnit.currentShieldHits == 1)
                {
                    damageReduction = 0.4f;
                }
                else
                {
                    damageReduction = 0.6f;
                }
                enemyUnit.currentShieldHits += 1;
            }
            if (playerActions[0] == 1)
            {
                audioManager.Play("Punch");
                combatAnim.SetTrigger("soco");
                isDead = enemyUnit.TakeDamage(((playerUnit.attack * 2) / (enemyUnit.defense * 0.5f)) * damageReduction);
                battleUI.StartCoroutine(battleUI.showText("Você socou seu date!"));
            }
            else if (playerActions[0] == 2)
            {
                audioManager.Play("Kick");
                combatAnim.SetTrigger("chute");
                isDead = enemyUnit.TakeDamage(((1.5f * playerUnit.attack * 2) / (enemyUnit.defense * 0.5f)) * damageReduction);
                battleUI.StartCoroutine(battleUI.showText("Você chutou seu date!"));
            }
            else if (playerActions[0] == 3)
            {
                battleUI.StartCoroutine(battleUI.showText("Você está se defendendo!"));
            }
            else if (playerActions[0] == 5)
            {
                battleUI.StartCoroutine(battleUI.showText("Você vai recuperar 7 de energia!"));
                playerUnit.GiveEnergy(5);
            }
            if (playerActions[0] != 3)
            {
                playerActions.Remove(playerActions[0]);
                battleUI.enemyHUD.SetHP(enemyCurHealth, enemyUnit);
                battleUI.SetActionsHUD(playerActions);
            }
            yield return(new WaitForSeconds(0.7f));

            if (isDead)
            {
                state = BattleState.WON;
                EndBattle();
            }
            yield return(new WaitForSeconds(1f));
        }
        if (enemyActions.Contains(3))
        {
            //audioManager.Play("ShieldDown");
            enemyActions.Remove(3);
            enemyUnit.currentShieldHits = 0;
        }
        state = BattleState.ENEMYTURN;
        StartCoroutine(EnemyTurn());
    }