Exemple #1
0
        // 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;
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// Is client connected ?
 /// TODO: This method should be corrected to return: is client active.
 /// </summary>
 public static bool    IsClient()
 {
     return(NetworkStatus.IsClientConnected());
 }
Exemple #3
0
 public static bool    IsClient(this NetworkManager netMgr)
 {
     return(NetworkStatus.IsClientConnected());
 }