Exemple #1
0
    private IEnumerator Attack()
    {
        while (true)
        {
            CleanNullInEnemyList();
            if (m_enemyInRange.Count == 0)
            {
                RpcDisableLineRenderer();
                break;
            }
            if (m_stockUnits.transform.childCount == 0 || m_enemiesUnits.transform.childCount > 0)
            {
                m_soundEmitter.StopSound();
                RpcDisableLineRenderer();
                yield return(null);

                continue;
            }

            CombatUnit combatUnitEnnemy = m_enemyInRange[0];
            if (combatUnitEnnemy.GetCurrentHealth() > 0)
            {
                RpcEnableLineRenderer(m_enemyInRange[0].transform.position);
                if (Time.time > m_nextAttack && m_attackSpeed[m_stockUnits.transform.childCount] > 0)
                {
                    m_nextAttack = Time.time + m_attackSpeed[m_stockUnits.transform.childCount];
                    combatUnitEnnemy.TakeDamage(m_attackDamage, GetPlayerOwner());
                }
            }
            yield return(null);
        }
        m_crRunning = false;
    }