public bool OfferPlayerToChooseTeam() { if (!NetworkStatus.IsServer()) { return(false); } if (TeamManager.FFA && !this.sendChooseTeamMessageIfFFAIsOn) { return(false); } m_teamsToChooseFrom.Clear(); if (TeamManager.FFA) { m_teamsToChooseFrom.AddRange(new string[] { "Play" }); m_titleForChoosingTeams = ""; } else { m_teamsToChooseFrom.AddRange(TeamManager.teamNames); m_titleForChoosingTeams = "Choose team"; } m_shouldChooseTeam = false; m_shouldSendChooseTeamMessage = true; return(true); }
/// <summary> /// Is host active ? /// </summary> public static bool IsHost() { if (!NetworkStatus.IsServer()) { return(false); } return(NetworkServer.localClientActive); }
public override void OnStartClient() { base.OnStartClient(); if (!NetworkStatus.IsServer()) { if (this.playerOwnerGameObject) { this.playerOwner = this.playerOwnerGameObject.GetComponent <Player> (); } else { this.playerOwner = null; } } }
void OnSceneChanged(SceneChangedInfo info) { if (!NetworkStatus.IsServer()) { return; } if (this.resetTeamOnSceneChange) { m_team = ""; m_isSpectator = true; m_shouldChooseTeam = false; m_shouldSendChooseTeamMessage = false; this.OfferPlayerToChooseTeam(); } }
// Update is called once per frame void Update() { if (!NetworkStatus.IsServerStarted() && !NetworkStatus.IsClientConnected()) { m_currentlySpectatedObject = null; return; } if (NetworkStatus.IsClient()) { if (Player.local != null) { if (Player.local.GetControllingGameObject() != null) { // controlling object is alive // set watched object to null m_currentlySpectatedObject = null; } else { // controlling object is not alive if (null == m_currentlySpectatedObject || null == m_currentlySpectatedObject.GetControllingGameObject()) { // we are not spectating anyone // find object for spectating FindObjectForSpectating(0); } else { // we are spectating someone } } } else { // we are on client, and there is no local player m_currentlySpectatedObject = null; } } else if (NetworkStatus.IsServer()) { // we are on dedicated server if (null == m_currentlySpectatedObject || null == m_currentlySpectatedObject.GetControllingGameObject()) { // we are not spectating anyone // find object for spectating FindObjectForSpectating(0); } } // just in case if (m_currentlySpectatedObject) { if (!m_currentlySpectatedObject.GetControllingGameObject()) { // controlling game object of spectated player is dead m_currentlySpectatedObject = null; } } }