private void Fire() { var gamepad = Gamepad.current; if (timePassed >= ultimateAttackCooldown && !ultraReady) //player can cast ultimate attack { ultraReady = true; timePassed = 0f; StopCoroutine(ChargeSuperBar()); } else if (!ultraReady) { timePassed += Time.deltaTime; StartCoroutine(ChargeSuperBar()); } if (timeBtwShots <= 0) { if ((!mobile && (Input.GetMouseButton(0) || (gamepad != null && gamepad.rightTrigger.wasPressedThisFrame)))) // left click { if (!shotSound.isPlaying) { shotSound.Play(); } Instantiate(normalAttackPrefab[PlayerPrefs.GetInt("sanitizerEquipped")], shotPoint.position, shotPoint.rotation); timeBtwShots = startTimeBetweenShots; } } else { timeBtwShots -= Time.deltaTime; } if (ultraReady) { if (Input.GetMouseButton(1) || (gamepad != null && gamepad.leftTrigger.wasPressedThisFrame)) // right click { if (!ultraSound.isPlaying) { ultraSound.Play(); } Instantiate(ultraAttackPrefab[PlayerPrefs.GetInt("sanitizerEquipped")], shotPoint.position, shotPoint.rotation); ultraReady = false; superAttackBar.SetFloatValue(0f); // resets super attack bar } } }
// Start is called before the first frame update void Start() { breakingObjectSound = Resources.Load <AudioClip>("breaking-bottle"); shitSound = Resources.Load <AudioClip>("shit"); healthSound = Resources.Load <AudioClip>("healthpickup"); puffSound = Resources.Load <AudioClip>("poof"); //appearanceSound = Resources.Load<AudioClip>("appearance"); audioSrc = GetComponent <AudioSource>(); // retrieve mixers attribs value set in main menu musicMixer.SetFloat("volume", PlayerPrefs.GetFloat("musicVolume")); musicSlider.SetFloatValue(PlayerPrefs.GetFloat("musicVolume")); effectsMixer.SetFloat("volume", PlayerPrefs.GetFloat("effectsVolume")); effectsSlider.SetFloatValue(PlayerPrefs.GetFloat("effectsVolume")); }