示例#1
0
        private void SpawnLobbyBall(MatchPlayer player)
        {
            // for multiplayer...

            LobbyBallSpawner spawner = LobbyReferences.Active.BallSpawner;

            if (player.ConnectionSelf != null)
            {
                replace = true;

                Debug.Log("We delete the gameobject and then proceed to make a replacement.");
                NetworkServer.Destroy(player.ConnectionSelf.playerControllers[0].gameObject);
            }

            if (isServer && !replace)
            {
                player.ConnectionSelf = NetworkServer.connections[0];
            }

            if (!replace)
            {
                Debug.Log("I create a new connection using singleton.client.connection");
                player.BallObject = spawner.SpawnBall(Data.PlayerType.Normal, player.CtrlType, player.CharacterId, player.Name, NetworkManager.singleton.client.connection);               // en cliente esto da nulo,, creo.
            }
            else
            {
                Debug.Log("The ball will be replaced using existing connection stored in ball.connectionSelf");

                player.BallObject = spawner.SpawnBall(Data.PlayerType.Normal, player.CtrlType, player.CharacterId, player.Name, player.ConnectionSelf);               // en cliente esto da nulo,, creo.
            }
        }
示例#2
0
        // aparece el lobbyBall
        private void SpawnLobbyBallFromRace(MatchPlayer player)
        {
            LobbyBallSpawner spawner = LobbyReferences.Active.BallSpawner;

            if (player.ConnectionSelf != null)
            {
                replace = true;

                Debug.Log("We delete the gameobject and then proceed to make a replacement.");
            }
            if (isServer && !replace)
            {
                player.ConnectionSelf = NetworkServer.connections[0];
            }

            if (!replace)
            {
                player.BallObject = spawner.SpawnBall(Data.PlayerType.Normal, player.CtrlType, player.CharacterId, "Player", NetworkManager.singleton.client.connection);               // en cliente esto da nulo,, creo.
            }
            else
            {
                player.BallObject = spawner.SpawnBall(Data.PlayerType.Normal, player.CtrlType, player.CharacterId, "Player", player.ConnectionSelf);               // en cliente esto da nulo,, creo.
            }
        }
示例#3
0
    /*
     *
     * public virtual void MatchJoined(JoinMatchResponse matchInfo)
     * {
     *      Debug.Log("DE BU GEDEBUUU DEBUGEANANDP");
     *      if (LogFilter.logDebug)
     *      {
     *              Debug.Log("NetworkManager OnMatchJoined ");
     *      }
     *      if (matchInfo.success)
     *      {
     *              try
     *              {
     * //				Utility.SetAccessTokenForNetwork(matchInfo.networkId, new UnityEngine.Networking.Types.NetworkAccessToken(matchInfo.accessTokenString));
     *              }
     *              catch(System.Exception ex)
     *              {
     *                      if (LogFilter.logError)
     *                      {
     *                              Debug.LogError(ex);
     *                      }
     *              }
     *              this.StartClient(new MatchInfo(matchInfo));
     *      }
     *      else if (LogFilter.logError)
     *      {
     *              infoPanel.Display("Right now, you cant join to a Match, please try later","close",null);
     *
     *              Debug.LogError(string.Concat("Join Failed:", matchInfo));
     *      }
     * }
     *
     */



    public override void OnClientSceneChanged(NetworkConnection conn)
    {
        base.OnClientSceneChanged(conn);

        if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name == "Lobby")
        {
            if (matchManager)
            {
                if (matchManager.Players.Count != 0)
                {
                    matchManager.replace = true;
                    matchManager.firstTimeLoadingLobby = true;
                    matchManager.LevelStartedFromRace();
                }

                if (matchManager.isServer)
                {
                    NetworkServer.SpawnObjects();

                    ballSpawner = GameObject.Find("BallSpawner").GetComponent <LobbyBallSpawner>();
                }
                else
                {
                }
                matchManager.inLobby = true;
            }
        }
        else
        {
            Debug.Log("Client Changed Scene");

            if (matchManager)
            {
                matchManager.inLobby = false;
                matchManager.firstTimeLoadingLobby = false;

                if (!matchManager.isServer)
                {
                    NetworkServer.SpawnObjects();

                    NetworkManager.singleton.GetComponent <SanicNetworkManager>().raceManager =
                        Instantiate(NetworkManager.singleton.GetComponent <SanicNetworkManager>().raceManagerPrefab);
                }
            }

            if (!matchManager)
            {
                //instantiating the racemanager when we are in a race and we are not the Server
                if (!GameObject.FindObjectOfType <MatchManager>().isServer)
                {
                    matchManager         = GameObject.FindObjectOfType <MatchManager>();
                    matchManager.inLobby = false;
                    matchManager.firstTimeLoadingLobby = false;


                    NetworkManager.singleton.GetComponent <SanicNetworkManager>().raceManager =
                        Instantiate(NetworkManager.singleton.GetComponent <SanicNetworkManager>().raceManagerPrefab);
                }
            }
        }
    }