/// <summary> /// OnClick Listener for Ready button (WeaponSelection Menu). /// </summary> public void Ready() { //free up memory weaponNamesToButtons = null; weaponStatToText = null; StartCoroutine(Utils.Fade( fader, fader.color, Color.clear, 0.1f)); weaponSelection.SetActive(false); weaponStats.SetActive(false); krieger.SetRendererLayer("Gameground"); GameState.instance.isReady = true; }
private void Start() { // musicVolume.onValueChanged.AddListener( // delegate // { // AudioManager.musicVolume = musicVolume.value; // AudioManager.instance.musicSource.volume = AudioManager.musicVolume; // PlayerPrefs.SetFloat("MusicVolume", AudioManager.musicVolume); // }); // musicVolume.value = PlayerPrefs.GetFloat("MusicVolume", 1f); // soundFXVolume.onValueChanged.AddListener( // delegate // { // AudioManager.soundFXVolume = soundFXVolume.value; // AudioManager.instance.ambienceSource.volume = AudioManager.soundFXVolume; // PlayerPrefs.SetFloat("SoundFXVolume", AudioManager.soundFXVolume); // }); // soundFXVolume.value = PlayerPrefs.GetFloat("SoundFXVolume", 1f); //add click sounds Button[] buttons = Resources.FindObjectsOfTypeAll <Button>(); foreach (Button b in buttons) { b.onClick.AddListener(() => AudioManager.PlayOneClip(AudioManager.instance.ambienceSource, clicks)); } //weapon selection Button[] weaponButtons = weaponSelection.transform.Find("Names").GetComponentsInChildren <Button>(); foreach (Button b in weaponButtons) { weaponNamesToButtons.Add(b.name, b); b.onClick.AddListener(() => SelectWeapon(b.gameObject.name)); } //weapon stats Text[] weaponStatTexts = weaponStats.transform.GetComponentsInChildren <Text>(); foreach (Text t in weaponStatTexts) { weaponStatToText.Add(t.name, t); Utils.AdjustTextScaleForCustomFont(t); } Utils.AdjustTextScaleForCustomFont(endGameText); krieger = Krieger.instance; krieger.OnDeath += EndScreenSequenceWrapper; krieger.OnShoot += DisplayAmmoWrapper; //set to UI so that Fader doesn't affect it during weapon selection krieger.SetRendererLayer("UI"); fader.color = new Color(0f, 0f, 0f, 210f / 255f); LockUnavailableWeaponsFromPlayerData(); SelectWeapon( "Shovel", initialization: true); SelectWeapon( "Blaster", initialization: true); }