Ejemplo n.º 1
0
    //----------------------------------------------------------------------------
    // Fire logic
    //----------------------------------------------------------------------------

    public void FireLeft(Vehicle vehicleToFire)
    {
        if (m_leftCooldown > 0f)
        {
            return;
        }

        // Loop through the cannons prefab inside the vehicle
        foreach (var weapon in m_leftWeapons)
        {
            // Check current cannon shots count
            if (cannonballCount <= 0)
            {
                break;
            }

            Cannon cannon = Instantiate(m_cannonBallPrefab, weapon.transform.position, weapon.transform.rotation);
            weapon.GetComponentInChildren <ParticleSystem>()?.Play(true);
            cannon.SetShooter(vehicleToFire);
            cannon.AddDmg(bonusCannonDamage);
            --cannonballCount;
        }

        m_leftCooldown = m_fireCoolDown;
    }