/// <summary> /// allows the player to change the voice mode of themselves. /// </summary> void ToggleVoiceMode() { foreach (GameObject gam in GameObject.FindGameObjectsWithTag("Voice")) { if (gam.GetComponent <PlayerPrefabVoiceControlScript>().locview.owner == PhotonNetwork.player) { locplayer = gam.GetComponent <PlayerPrefabVoiceControlScript>(); } } PlayerPrefabVoiceControlScript.VoiceChannel nextchannel = PlayerPrefabVoiceControlScript.VoiceChannel.TeamOnly; if (locplayer.curchannel == PlayerPrefabVoiceControlScript.VoiceChannel.All) { nextchannel = PlayerPrefabVoiceControlScript.VoiceChannel.TeamOnly; } if (locplayer.curchannel == PlayerPrefabVoiceControlScript.VoiceChannel.TeamOnly) { nextchannel = PlayerPrefabVoiceControlScript.VoiceChannel.Muteall; } if (locplayer.curchannel == PlayerPrefabVoiceControlScript.VoiceChannel.Muteall) { nextchannel = PlayerPrefabVoiceControlScript.VoiceChannel.All; } locplayer.setchannelforall(nextchannel); Updatelocplayer(); }
/// <summary> /// Function that runs every second to allow the voice settings to update. /// </summary> void Rep() { if (PhotonNetwork.offlineMode == false) { Updatelocplayer(); if (VoiceModeSelector.GetActive() == false) { VoiceModeSelector.SetActive(true); } if (locplayer == null && SceneManager.GetActiveScene().name == "mptest" || SceneManager.GetActiveScene().name == "MainMenuIntroLobby") { foreach (GameObject gam in GameObject.FindGameObjectsWithTag("Voice")) { if (gam.GetComponent <PlayerPrefabVoiceControlScript>().locview.owner == PhotonNetwork.player) { locplayer = gam.GetComponent <PlayerPrefabVoiceControlScript>(); } } } } else if (VoiceModeSelector.GetActive() == true) { VoiceModeSelector.SetActive(false); } }
/// <summary> /// Initialisation. /// </summary> void Start() { locview = GetComponent <PhotonView>(); locaudio = GetComponent <AudioSource>(); SceneManager.sceneLoaded += OnLevelFinishedLoading; GameObject[] voices = GameObject.FindGameObjectsWithTag("Voice"); foreach (GameObject voice in voices) { if (voice.GetComponent <PhotonView>().owner == PhotonNetwork.player) { localplayer = voice.GetComponent <PlayerPrefabVoiceControlScript>(); } } OnLevelFinishedLoading(SceneManager.GetActiveScene(), new LoadSceneMode()); if (locview.isMine == true) { foreach (MeshRenderer mesh in GetComponentsInChildren <MeshRenderer>()) { mesh.enabled = false; } } if (GameObject.Find("CrossLevelVariables")) { crossvar = GameObject.Find("CrossLevelVariables").GetComponent <CrossLevelVariableHolder>(); } }