コード例 #1
0
 public void ReturntoTitle()                                 // Winner Scene에서 아무 곳이나 클릭할 경우,
 {
     if (NetworkServer.active && IsSceneActive(winnerScene)) // 서버가 잘 돌아가고 있고, 현재 Scene이 Winner Scene이라면,
     {
         NetworkServer.DisconnectAllConnections();
         StopHost();
     }
 }
コード例 #2
0
ファイル: NetworkServerTest.cs プロジェクト: AW1534/Mirror
        public void DisconnectAllConnectionsTest()
        {
            // listen
            NetworkServer.Listen(1);
            Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));

            // add connection
            NetworkConnectionToClient conn42 = new NetworkConnectionToClient(42, false, 0);

            NetworkServer.AddConnection(conn42);
            Assert.That(NetworkServer.connections.Count, Is.EqualTo(1));

            // disconnect all connections
            NetworkServer.DisconnectAllConnections();
            Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
        }
コード例 #3
0
    void Timer()
    {
        int mode = PlayerPrefs.GetInt("Mode", 0);

        if (timerIsRunning && (mode == 1 || mode == 4 || mode == 5))
        {
            if (timeRemaining > 0)
            {
                DisplayTime(timeRemaining);
                if (GoalText.IsActive() == false)
                {
                    if (TurnText.IsActive() == true)
                    {
                        return;
                    }
                    else
                    {
                        timeRemaining -= Time.deltaTime;
                        PlayerPrefs.SetFloat("Timer", timeRemaining);
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                Debug.Log("Time has run out!");
                timeRemaining = 0f;
                PlayerPrefs.SetFloat("Timer", timeRemaining);
                timerIsRunning = false;
                if (mode == 4)
                {
                    NetworkServer.DisconnectAllConnections();
                    NetworkServer.Shutdown();
                    NetworkClient.Shutdown();
                }

                SceneManager.LoadScene(2);
            }
        }
    }
コード例 #4
0
        public void DisconnectAllConnectionsTest()
        {
            // message handlers
            NetworkServer.RegisterHandler <ConnectMessage>((conn, msg) => { }, false);
            NetworkServer.RegisterHandler <DisconnectMessage>((conn, msg) => { }, false);
            NetworkServer.RegisterHandler <ErrorMessage>((conn, msg) => { }, false);

            // listen
            NetworkServer.Listen(1);
            Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));

            // add connection
            NetworkConnectionToClient conn42 = new NetworkConnectionToClient(42);

            NetworkServer.AddConnection(conn42);
            Assert.That(NetworkServer.connections.Count, Is.EqualTo(1));

            // disconnect all connections
            NetworkServer.DisconnectAllConnections();
            Assert.That(NetworkServer.connections.Count, Is.EqualTo(0));
        }
コード例 #5
0
 public override void OnStopHost()
 {
     Debug.Log("Parando Servidor On Host");
     NetworkServer.DisconnectAllConnections();
     base.OnStopHost();
 }