Esempio n. 1
0
    IEnumerator SpeedBattle()
    {
        battleState = BattleState.SPEEDBATTLE;
        float delay;

        delay = actionDelay / 100;

        while (true)
        {
            bool breakOut = false;
            playerUnit.AddToTurnPos((float)playerUnit.job.speed / (10 / actionDelay) + Random.Range(-0.25f, 0.25f));
            playerBattleHUD.SetSpeedGauge(playerUnit.GetTurnPos());

            for (int i = 0; i < enemies.Length; i++)
            {
                if (!enemies[i].isDead())
                {
                    enemies[i].AddToTurnPos((float)targetedEnemyUnit.job.speed / (10 / actionDelay) + Random.Range(-0.25f, 0.25f));
                }

                enemyBattleHUD.SetSpeedGauge(enemies[i].GetTurnPos());
            }
            turnSliders.UpdateTurnBar(playerUnit, enemies);

            yield return(new WaitForSeconds(delay));

            if (playerUnit.GetTurnPos() >= 100)
            {
                playerWinsSpeedBattle = true;
                breakOut = true;
            }

            for (int i = 0; i < enemies.Length; i++)
            {
                if (enemies[i].GetTurnPos() >= 100)
                {
                    playerWinsSpeedBattle = false;
                    breakOut           = true;
                    activeEnemyUnitIdx = i;
                }
            }

            if (breakOut)
            {
                break;
            }
        }

        if (playerWinsSpeedBattle)
        {
            StartCoroutine(PlayerTurn());
        }
        else
        {
            StartCoroutine(StartEnemyTurn());
        }
    }