void HandleHit() { if (hasShield) { hasShield = false; } else { AudioSource.PlayClipAtPoint(dmgSounds[Random.Range(0, dmgSounds.Length)], Camera.main.transform.position, PlayerPrefsController.GetMasterSFXVolume()); hitPoints--; if (hitPoints <= 0) { StartCoroutine(Die()); } else { StartCoroutine(HitFrames()); } } }
private void Awake() { //set slider values to current volumes upon loading scene musicVolumeSlider.value = PlayerPrefsController.GetMasterMusicVolume(); sFXVolumeSlider.value = PlayerPrefsController.GetMasterSFXVolume(); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "Player") { switch (tag) { case "Point": FindObjectOfType <GameSessionScore>().pointsPickedup++; AudioSource.PlayClipAtPoint(pointSFX, Camera.main.transform.position, PlayerPrefsController.GetMasterSFXVolume()); Destroy(gameObject); Debug.Log("Picked up a Point"); break; case "Part A": if (inventory.partACount < inventory.partLimit) { AudioSource.PlayClipAtPoint(partSFX, Camera.main.transform.position, PlayerPrefsController.GetMasterSFXVolume()); inventory.partACount++; Debug.Log("Picked up an A part"); } Destroy(gameObject); break; case "Part B": if (inventory.partBCount < inventory.partLimit) { AudioSource.PlayClipAtPoint(partSFX, Camera.main.transform.position, PlayerPrefsController.GetMasterSFXVolume()); inventory.partBCount++; Debug.Log("Picked up a B part"); } Destroy(gameObject); break; case "Part C": if (inventory.partCCount < inventory.partLimit) { AudioSource.PlayClipAtPoint(partSFX, Camera.main.transform.position, PlayerPrefsController.GetMasterSFXVolume()); inventory.partCCount++; Debug.Log("Picked up a C part"); } Destroy(gameObject); break; default: Debug.Log("Pickup unkown, did you tag it?"); break; } } else { return; } }