Esempio n. 1
0
    public void OnServerAddPlayer(NetworkConnection conn, short playerControllerId, NetworkReader extraMessageReader)
    {
        LoginMessage login = new LoginMessage();

        login.Deserialize(extraMessageReader);

        Debug.Log("playerControllerId = " + login.username + " with player id " + playerControllerId + " logged in!");
        GameObject player = (GameObject)GameObject.Instantiate(playerPrefab);

        playerInfoManager.userLogin(login.username, player);

        NetworkWriter writer = new NetworkWriter();

        serverMap.mapData.Serialize(writer);
        NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
        serverMap.TargetSetAndApplyMap(conn, writer.AsArray());
    }