Exemple #1
0
    public override void OnServerDisconnect(NetworkConnection conn)
    {
        // Quitar de las estructuras de datos.
        if (conn.identity != null)
        {
            print("OnServerDisconnect: conn.identity no es null");
            var player = conn.identity.GetComponent <RoomPlayer>();
            RoomPlayers.Remove(player);
        }

        if (tokenConnection.Exists(p => p.Value == conn))
        {
            print("OnServerDisconnect: Existe token asociado a la conexión");
            tokenConnection.Remove(tokenConnection.Find(p => p.Value == conn));
            if (modoServidor == ServidorPartida)
            {
                print("OnServerDisconnect: Estamos en server partida");
                serverPlayers--;
                if (serverPlayers < 0)
                {
                    serverPlayers = 0;
                }
                print("OnServerDisconnect: serverPlayers: " + serverPlayers + " --- MaxPlayers: " + maxPlayers);
                if (partidaFinalizada && serverPlayers <= 0) // partidaFinalizada implica que serverPlayers ha sido maxPlayers (buscar partidaFinalizada = true para comprobarlo)
                {
                    print("Empezamos ENDMATCH");
                    StartCoroutine(EndMatch());
                }
            }
        }


        base.OnServerDisconnect(conn);
    }
Exemple #2
0
    public override void OnServerDisconnect(NetworkConnection conn)     // -------- Both LOBBY and GAME --------- (invoking some functions)
    {
        string currentSceneName = SceneManager.GetActiveScene().name;

        switch (currentSceneName)
        {
        case "Menu":
        {
            if (conn.identity != null)
            {
                var player = conn.identity.GetComponent <NetworkRoomPlayer>();
                RoomPlayers.Remove(player);

                NotifyPlayersOfReadyState();
            }

            base.OnServerDisconnect(conn);

            break;
        }

        case "Game_PVP":
        {
            OnServerWhenClientDisconnectedIngame?.Invoke();         // RpcClient function invoking (from spawn system)

            base.OnServerDisconnect(conn);

            break;
        }
        }
    }
Exemple #3
0
 public override void OnServerDisconnect(NetworkConnection conn)
 {
     if (conn.identity != null)
     {
         var player = conn.identity.GetComponent <NetworkRoomPlayerLobby>();
         RoomPlayers.Remove(player);
         NotifyPlayersOfReadyState();
     }
     base.OnServerDisconnect(conn);
 }
Exemple #4
0
    public override void OnClientDisconnect(NetworkConnection conn)
    {
        if (conn.identity != null)
        {
            NetworkRoomPlayerLobby player = conn.identity.GetComponent <NetworkRoomPlayerLobby>();
            RoomPlayers.Remove(player);
        }

        base.OnClientDisconnect(conn);
        ClientDisconnected?.Invoke();
    }
 public override void OnServerDisconnect(NetworkConnection conn)
 {
     if (conn.identity != null)
     {
         //Haetaan poistuneen pelaajan RoomFuturace scripti
         var player = conn.identity.GetComponent <NetWorkRoomFuturace>();
         //Ja poistetaan pelaaja listasta (vain serveri)
         RoomPlayers.Remove(player);
         NotifyPlayersOfReadyState();
     }
     //Basessa tuhotaan oikeasti yhteys
     base.OnServerDisconnect(conn);
 }
Exemple #6
0
    public override void OnServerDisconnect(NetworkConnection conn)
    {
        if (conn.identity != null)
        {
            Debug.Log("A client was disconnected from the server");
            var player = conn.identity.GetComponent <RoomPlayer>();

            RoomPlayers.Remove(player);

            NotifyPlayersOfReadyState();
        }

        base.OnServerDisconnect(conn);
    }
Exemple #7
0
    public override void OnServerDisconnect(NetworkConnection conn)
    {
        //removes players when a disconnect occurs so they aren't affected by the world
        if (conn.identity != null)
        {
            NetworkRoomPlayer player = conn.identity.GetComponent <NetworkRoomPlayer>();

            RoomPlayers.Remove(player);

            NotifyPlayersOfReadyState();
        }

        base.OnServerDisconnect(conn);
    }
Exemple #8
0
    //Called on SERVER when a client disconnects from server, automatically
    public override void OnServerDisconnect(NetworkConnection conn)
    {
        //Get room player script and remove from the list

        if (conn.identity != null)                                   //if the object has a network identity
        {
            var player = conn.identity.GetComponent <NetworkRoom>(); //Get network room script of disconnected player

            RoomPlayers.Remove(player);                              //Remove the player conn from the list of room players

            NotifyPlayersOfReadyState();                             //Update everyone of ready status
        }

        base.OnServerDisconnect(conn); //Destroys player for connection, disconnects client properly
        //Debug.Log("Removed player");
    }
    public override void OnServerDisconnect(NetworkConnection conn)
    {
        Debug.Log("OnServerDisconnect");
        if (conn.identity != null)
        {
            var player = conn.identity.GetComponent <NetworkRoomPlayerLobby>();

            RoomPlayers.Remove(player);

            NotifyPlayersOfReadyState();
        }

        base.OnServerDisconnect(conn);
        ForceLeaveGame leave = new ForceLeaveGame();

        leave.GoBackToMenu(gameObject);
    }
Exemple #10
0
    //Method called on Quit, disconnects all players
    public override void OnServerDisconnect(NetworkConnection conn)
    {
        if (conn.identity != null)
        {
            var player = conn.identity.GetComponent <NetworkBehaviour>();

            if (player is NetworkRoomPlayerDND roomPlayer)
            {
                RoomPlayers.Remove(roomPlayer);

                NotifyPlayersOfReadyState();
            }
            else if (player is NetworkGamePlayerDND gamePlayer)
            {
                GamePlayers.Remove(gamePlayer);
                StopHost();
            }
        }

        base.OnServerDisconnect(conn);
    }
    public override void OnServerDisconnect(NetworkConnection conn)
    {
        if (conn.identity != null)
        {
            var player = conn.identity.GetComponent <NetworkBehaviour>(); //Refrence to the player who disconnected

            if (player is NetworkRoomPlayer roomPlayer)
            {
                RoomPlayers.Remove(roomPlayer); //Removes disconnected player from list of current players

                NotifyPlayersOfReadyState();
            }

            else if (player is NetworkGamePlayer gamePlayer)
            {
                GamePlayers.Remove(gamePlayer);
            }
        }

        base.OnServerDisconnect(conn);
    }