Exemplo n.º 1
0
    private void HandleWeaponFiring()
    {
        // Handle weapon firing if there's ammo
        if (m_ammoCount > 0)
        {
            if (Input.GetMouseButton(0))
            {
                if (Time.time - m_fireRateTimer > m_fireRateLimit)
                {
                    m_fireRateTimer = Time.time;

                    switch (m_CurrentGunSelection)
                    {
                    case GunSelection.MACHINEGUN:
                        Instantiate(m_MachineGunBulletObjectPrefab, m_BulletSpawnPoint.position, m_BulletSpawnPoint.rotation, m_BulletStorage);
                        AudioManager.Instance.PlaySFX(AudioManager.Instance.BulletFire_MachineGun, 1);
                        break;

                    case GunSelection.MISSILE:
                        Instantiate(m_MissileBulletObjectPrefab, m_BulletSpawnPoint.position, m_BulletSpawnPoint.rotation, m_BulletStorage);
                        AudioManager.Instance.PlaySFX(AudioManager.Instance.BulletFire_Missile, 1);
                        break;

                    case GunSelection.ROCKET:
                        Instantiate(m_RocketBulletObjectPrefab, m_BulletSpawnPoint.position, m_BulletSpawnPoint.rotation, m_BulletStorage);
                        AudioManager.Instance.PlaySFX(AudioManager.Instance.BulletFire_Rocket, 1);
                        break;

                    default:
                        Debug.Log("Unhandled gun selection: " + m_CurrentGunSelection);
                        break;
                    }
                    m_ammoCount--;

                    if (m_ammoCount <= 0)
                    {
                        // The player is now out of ammo
                        m_ammoCount = 0;
                        AudioManager.Instance.PlaySFX(AudioManager.Instance.UI_NoAmmo, 1);
                    }

                    // update UI
                    m_sceneManager.SetAmmo(m_ammoCount);
                }
            }
        }
    }
Exemplo n.º 2
0
 public void SetSceneManager(SceneManagerScript val)
 {
     m_sceneManager = val;
     m_sceneManager.SetAmmo(m_ammoCount);
 }