Exemplo n.º 1
0
    void Attack()
    {
        m_audio.TriggerPlayerAttack();

        Vector2 attackDirection = GetAttackDirection();

        for (int i = 0; i < m_currentAttackCount; ++i)
        {
            Vector2 attackNormal   = attackDirection.PerpendicularClockwise();
            Vector2 inaccuracy     = attackNormal * MathsHelper.RandomWithNegative() * (m_currentInaccuracy * (i + 1));
            Vector2 attackVelocity = (attackDirection + inaccuracy) * (m_currentProjectileSpeed);

            Vector2 modifiedVelocity = attackVelocity + (m_movement.CurrentVelocity() * m_velocityMod);

            if (attackVelocity.magnitude < modifiedVelocity.magnitude)
            {
                attackVelocity = modifiedVelocity;
            }

            m_shoot.Shoot(attackVelocity, m_currentAttackDamage);
        }
    }