コード例 #1
0
        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);
        }
コード例 #2
0
        /// <summary>
        /// Is host active ?
        /// </summary>
        public static bool    IsHost()
        {
            if (!NetworkStatus.IsServer())
            {
                return(false);
            }

            return(NetworkServer.localClientActive);
        }
コード例 #3
0
        public override void    OnStartClient()
        {
            base.OnStartClient();

            if (!NetworkStatus.IsServer())
            {
                if (this.playerOwnerGameObject)
                {
                    this.playerOwner = this.playerOwnerGameObject.GetComponent <Player> ();
                }
                else
                {
                    this.playerOwner = null;
                }
            }
        }
コード例 #4
0
        void OnSceneChanged(SceneChangedInfo info)
        {
            if (!NetworkStatus.IsServer())
            {
                return;
            }

            if (this.resetTeamOnSceneChange)
            {
                m_team                        = "";
                m_isSpectator                 = true;
                m_shouldChooseTeam            = false;
                m_shouldSendChooseTeamMessage = false;

                this.OfferPlayerToChooseTeam();
            }
        }
コード例 #5
0
ファイル: Spectator.cs プロジェクト: b2220333/uGameCore
        // 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;
                }
            }
        }