当前位置: 首页>>代码示例>>C#>>正文


C# EnterRoomParams类代码示例

本文整理汇总了C#中EnterRoomParams的典型用法代码示例。如果您正苦于以下问题:C# EnterRoomParams类的具体用法?C# EnterRoomParams怎么用?C# EnterRoomParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EnterRoomParams类属于命名空间,在下文中一共展示了EnterRoomParams类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OpJoinRoom

        /// <summary>
        /// Joins a room by name or creates new room if room with given name not exists.
        /// The OperationResponse depends on the server the peer is connected to:
        /// Master will return a Game Server to connect to.
        /// Game Server will return the joined Room's data.
        /// This is an async request which triggers a OnOperationResponse() call.
        /// </summary>
        /// <remarks>
        /// If the room is not existing (anymore), the OperationResponse will have a returnCode of ErrorCode.GameDoesNotExist.
        /// Other possible ErrorCodes are: GameClosed, GameFull.
        /// </remarks>
        /// <returns>If the operation could be sent (requires connection).</returns>
        public virtual bool OpJoinRoom(EnterRoomParams opParams)
        {
            if (this.DebugOut >= DebugLevel.INFO)
            {
                this.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRoom()");
            }
            Dictionary<byte, object> op = new Dictionary<byte, object>();

            if (!string.IsNullOrEmpty(opParams.RoomName))
            {
                op[ParameterCode.RoomName] = opParams.RoomName;
            }

            if (opParams.CreateIfNotExists)
            {
                op[ParameterCode.JoinMode] = (byte)JoinMode.CreateIfNotExists;
                if (opParams.Lobby != null)
                {
                    op[ParameterCode.LobbyName] = opParams.Lobby.Name;
                    op[ParameterCode.LobbyType] = (byte)opParams.Lobby.Type;
                }
            }

            if (opParams.RejoinOnly)
            {
                op[ParameterCode.JoinMode] = (byte)JoinMode.RejoinOnly; // changed from JoinMode.JoinOrRejoin
            }

            if (opParams.ExpectedUsers != null && opParams.ExpectedUsers.Length > 0)
            {
                op[ParameterCode.Add] = opParams.ExpectedUsers;
            }

            if (opParams.OnGameServer)
            {
                if (opParams.PlayerProperties != null && opParams.PlayerProperties.Count > 0)
                {
                    op[ParameterCode.PlayerProperties] = opParams.PlayerProperties;
                    op[ParameterCode.Broadcast] = true; // broadcast actor properties
                }

                if (opParams.CreateIfNotExists)
                {
                    this.RoomOptionsToOpParameters(op, opParams.RoomOptions);
                }
            }

            // UnityEngine.Debug.Log("JoinGame: " + SupportClassPun.DictionaryToString(op));
            return this.OpCustom(OperationCode.JoinGame, op, true);
        }
开发者ID:Ckeds,项目名称:PortfolioWorks,代码行数:62,代码来源:LoadbalancingPeer.cs

示例2: OpCreateRoom

        /// <summary>
        /// Creates a room (on either Master or Game Server).
        /// The OperationResponse depends on the server the peer is connected to:
        /// Master will return a Game Server to connect to.
        /// Game Server will return the joined Room's data.
        /// This is an async request which triggers a OnOperationResponse() call.
        /// </summary>
        /// <remarks>
        /// If the room is already existing, the OperationResponse will have a returnCode of ErrorCode.GameAlreadyExists.
        /// </remarks>
        public virtual bool OpCreateRoom(EnterRoomParams opParams)
        {
            if (this.DebugOut >= DebugLevel.INFO)
            {
                this.Listener.DebugReturn(DebugLevel.INFO, "OpCreateRoom()");
            }

            Dictionary<byte, object> op = new Dictionary<byte, object>();

            if (!string.IsNullOrEmpty(opParams.RoomName))
            {
                op[ParameterCode.RoomName] = opParams.RoomName;
            }
            if (opParams.Lobby != null && !string.IsNullOrEmpty(opParams.Lobby.Name))
            {
                op[ParameterCode.LobbyName] = opParams.Lobby.Name;
                op[ParameterCode.LobbyType] = (byte) opParams.Lobby.Type;
            }

            if (opParams.ExpectedUsers != null && opParams.ExpectedUsers.Length > 0)
            {
                op[ParameterCode.Add] = opParams.ExpectedUsers;
            }
            if (opParams.OnGameServer)
            {
                if (opParams.PlayerProperties != null && opParams.PlayerProperties.Count > 0)
                {
                    op[ParameterCode.PlayerProperties] = opParams.PlayerProperties;
                    op[ParameterCode.Broadcast] = true; // TODO: check if this also makes sense when creating a room?! // broadcast actor properties
                }

                this.RoomOptionsToOpParameters(op, opParams.RoomOptions);
            }

            //UnityEngine.Debug.Log("CreateGame: " + SupportClassPun.DictionaryToString(op));
            return this.OpCustom(OperationCode.CreateGame, op, true);
        }
开发者ID:Ckeds,项目名称:PortfolioWorks,代码行数:47,代码来源:LoadbalancingPeer.cs

示例3: OpJoinRandomRoom

    /// <summary>NetworkingPeer.OpJoinRandomRoom</summary>
    /// <remarks>this override just makes sure we have a mRoomToGetInto, even if it's blank (the properties provided in this method are filters. they are not set when we join the game)</remarks>
    public override bool OpJoinRandomRoom(OpJoinRandomRoomParams opJoinRandomRoomParams)
    {
        enterRoomParamsCache = new EnterRoomParams();   // this is used when the client arrives on the GS and joins the room
        enterRoomParamsCache.Lobby = opJoinRandomRoomParams.TypedLobby;

        this.mLastJoinType = JoinType.JoinRandomGame;
        return base.OpJoinRandomRoom(opJoinRandomRoomParams);
    }
开发者ID:houseofkohina,项目名称:ProjectDoge,代码行数:10,代码来源:NetworkingPeer.cs

示例4: OpJoinRoom

    /// <summary>NetworkingPeer.OpJoinRoom</summary>
    public override bool OpJoinRoom(EnterRoomParams opParams)
    {
        bool onGameServer = this.server == ServerConnection.GameServer;
        opParams.OnGameServer = onGameServer;
        if (!onGameServer)
        {
            enterRoomParamsCache = opParams;
        }

        this.mLastJoinType = (opParams.CreateIfNotExists) ? JoinType.JoinOrCreateOnDemand : JoinType.JoinGame;
        return base.OpJoinRoom(opParams);
    }
开发者ID:houseofkohina,项目名称:ProjectDoge,代码行数:13,代码来源:NetworkingPeer.cs

示例5: OpCreateGame

    /// <summary>NetworkingPeer.OpCreateGame</summary>
    public bool OpCreateGame(EnterRoomParams enterRoomParams)
    {
        bool onGameServer = this.server == ServerConnection.GameServer;
        enterRoomParams.OnGameServer = onGameServer;
        enterRoomParams.PlayerProperties = GetLocalActorProperties();
        if (!onGameServer)
        {
            enterRoomParamsCache = enterRoomParams;
        }

        this.mLastJoinType = JoinType.CreateGame;
        return base.OpCreateRoom(enterRoomParams);
    }
开发者ID:houseofkohina,项目名称:ProjectDoge,代码行数:14,代码来源:NetworkingPeer.cs

示例6: ReJoinRoom

    /// <summary>Can be used to return to a room after a disconnect and reconnect.</summary>
    /// <remarks>
    /// After losing connection, you might be able to return to a room and continue playing,
    /// if the client is reconnecting fast enough. Use Reconnect() and this method.
    /// Cache the room name you're in and use ReJoin(roomname) to return to a game.
    ///
    /// Note: To be able to ReJoin any room, you need to use UserIDs!
    /// You also need to set RoomOptions.PlayerTtl.
    ///
    /// <b>Important: Instantiate() and use of RPCs is not yet supported.</b>
    /// The ownership rules of PhotonViews prevent a seamless return to a game.
    /// Use Custom Properties and RaiseEvent with event caching instead.
    ///
    /// Common use case: Press the Lock Button on a iOS device and you get disconnected immediately.
    /// </remarks>
    public static bool ReJoinRoom(string roomName)
    {
        if (offlineMode)
        {
            Debug.LogError("ReJoinRoom failed due to offline mode.");
            return false;
        }
        if (networkingPeer.Server != ServerConnection.MasterServer || !connectedAndReady)
        {
            Debug.LogError("ReJoinRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
            return false;
        }
        if (string.IsNullOrEmpty(roomName))
        {
            Debug.LogError("ReJoinRoom failed. A roomname is required. If you don't know one, how will you join?");
            return false;
        }

        EnterRoomParams opParams = new EnterRoomParams();
        opParams.RoomName = roomName;
        opParams.RejoinOnly = true;
        opParams.PlayerProperties = player.customProperties;

        return networkingPeer.OpJoinRoom(opParams);
    }
开发者ID:yuvadius,项目名称:need4bit,代码行数:40,代码来源:PhotonNetwork.cs

示例7: JoinRoom

    /// <summary>Join room by roomname and on success calls OnJoinedRoom(). This is not affected by lobbies.</summary>
    /// <remarks>
    /// On success, the method OnJoinedRoom() is called on any script. You can implement it to react to joining a room.
    ///
    /// JoinRoom fails if the room is either full or no longer available (it might become empty while you attempt to join).
    /// Implement OnPhotonJoinRoomFailed() to get a callback in error case.
    ///
    /// To join a room from the lobby's listing, use RoomInfo.name as roomName here.
    /// Despite using multiple lobbies, a roomName is always "global" for your application and so you don't
    /// have to specify which lobby it's in. The Master Server will find the room.
    /// In the Photon Cloud, an application is defined by AppId, Game- and PUN-version.
    ///
    /// You can define an array of expectedUsers, to block player slots in the room for these users.
    /// The corresponding feature in Photon is called "Slot Reservation" and can be found in the doc pages.
    /// </remarks>
    /// <see cref="PhotonNetworkingMessage.OnPhotonJoinRoomFailed"/>
    /// <see cref="PhotonNetworkingMessage.OnJoinedRoom"/>
    /// <param name="roomName">Unique name of the room to join.</param>
    /// <param name="expectedUsers">Optional list of users (by UserId) who are expected to join this game and who you want to block a slot for.</param>
    /// <returns>If the operation got queued and will be sent.</returns>
    public static bool JoinRoom(string roomName, string[] expectedUsers)
    {
        if (offlineMode)
        {
            if (offlineModeRoom != null)
            {
                Debug.LogError("JoinRoom failed. In offline mode you still have to leave a room to enter another.");
                return false;
            }
            EnterOfflineRoom(roomName, null, true);
            return true;
        }
        if (networkingPeer.Server != ServerConnection.MasterServer || !connectedAndReady)
        {
            Debug.LogError("JoinRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
            return false;
        }
        if (string.IsNullOrEmpty(roomName))
        {
            Debug.LogError("JoinRoom failed. A roomname is required. If you don't know one, how will you join?");
            return false;
        }

        EnterRoomParams opParams = new EnterRoomParams();
        opParams.RoomName = roomName;
        opParams.ExpectedUsers = expectedUsers;

        return networkingPeer.OpJoinRoom(opParams);
    }
开发者ID:yuvadius,项目名称:need4bit,代码行数:49,代码来源:PhotonNetwork.cs

示例8: JoinOrCreateRoom

    /// <summary>Lets you either join a named room or create it on the fly - you don't have to know if someone created the room already.</summary>
    /// <remarks>
    /// This makes it easier for groups of players to get into the same room. Once the group
    /// exchanged a roomName, any player can call JoinOrCreateRoom and it doesn't matter who
    /// actually joins or creates the room.
    ///
    /// The parameters roomOptions and typedLobby are only used when the room actually gets created by this client.
    /// You know if this client created a room, if you get a callback OnCreatedRoom (before OnJoinedRoom gets called as well).
    ///
    /// You can define an array of expectedUsers, to block player slots in the room for these users.
    /// The corresponding feature in Photon is called "Slot Reservation" and can be found in the doc pages.
    /// </remarks>
    /// <param name="roomName">Name of the room to join. Must be non null.</param>
    /// <param name="roomOptions">Options for the room, in case it does not exist yet. Else these values are ignored.</param>
    /// <param name="typedLobby">Lobby you want a new room to be listed in. Ignored if the room was existing and got joined.</param>
    /// <param name="expectedUsers">Optional list of users (by UserId) who are expected to join this game and who you want to block a slot for.</param>
    /// <returns>If the operation got queued and will be sent.</returns>
    public static bool JoinOrCreateRoom(string roomName, RoomOptions roomOptions, TypedLobby typedLobby, string[] expectedUsers)
    {
        if (offlineMode)
        {
            if (offlineModeRoom != null)
            {
                Debug.LogError("JoinOrCreateRoom failed. In offline mode you still have to leave a room to enter another.");
                return false;
            }
            EnterOfflineRoom(roomName, roomOptions, true);  // in offline mode, JoinOrCreateRoom assumes you create the room
            return true;
        }
        if (networkingPeer.Server != ServerConnection.MasterServer || !connectedAndReady)
        {
            Debug.LogError("JoinOrCreateRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
            return false;
        }
        if (string.IsNullOrEmpty(roomName))
        {
            Debug.LogError("JoinOrCreateRoom failed. A roomname is required. If you don't know one, how will you join?");
            return false;
        }

        typedLobby = typedLobby ?? ((networkingPeer.insideLobby) ? networkingPeer.lobby : null);  // use given lobby, or active lobby (if any active) or none

        EnterRoomParams opParams = new EnterRoomParams();
        opParams.RoomName = roomName;
        opParams.RoomOptions = roomOptions;
        opParams.Lobby = typedLobby;
        opParams.CreateIfNotExists = true;
        opParams.PlayerProperties = player.customProperties;
        opParams.ExpectedUsers = expectedUsers;

        return networkingPeer.OpJoinRoom(opParams);
    }
开发者ID:yuvadius,项目名称:need4bit,代码行数:52,代码来源:PhotonNetwork.cs

示例9: CreateRoom

    /// <summary>
    /// Creates a room but fails if this room is existing already. Can only be called on Master Server.
    /// </summary>
    /// <remarks>
    /// When successful, this calls the callbacks OnCreatedRoom and OnJoinedRoom (the latter, cause you join as first player).
    /// If the room can't be created (because it exists already), OnPhotonCreateRoomFailed gets called.
    ///
    /// If you don't want to create a unique room-name, pass null or "" as name and the server will assign a roomName (a GUID as string).
    ///
    /// Rooms can be created in any number of lobbies. Those don't have to exist before you create a room in them (they get
    /// auto-created on demand). Lobbies can be useful to split room lists on the server-side already. That can help keep the room
    /// lists short and manageable.
    /// If you set a typedLobby parameter, the room will be created in that lobby (no matter if you are active in any).
    /// If you don't set a typedLobby, the room is automatically placed in the currently active lobby (if any) or the
    /// default-lobby.
    ///
    /// Call this only on the master server.
    /// Internally, the master will respond with a server-address (and roomName, if needed). Both are used internally
    /// to switch to the assigned game server and roomName.
    ///
    /// PhotonNetwork.autoCleanUpPlayerObjects will become this room's autoCleanUp property and that's used by all clients that join this room.
    ///
    /// You can define an array of expectedUsers, to block player slots in the room for these users.
    /// The corresponding feature in Photon is called "Slot Reservation" and can be found in the doc pages.
    /// </remarks>
    /// <param name="roomName">Unique name of the room to create. Pass null or "" to make the server generate a name.</param>
    /// <param name="roomOptions">Common options for the room like MaxPlayers, initial custom room properties and similar. See RoomOptions type..</param>
    /// <param name="typedLobby">If null, the room is automatically created in the currently used lobby (which is "default" when you didn't join one explicitly).</param>
    /// <param name="expectedUsers">Optional list of users (by UserId) who are expected to join this game and who you want to block a slot for.</param>
    /// <returns>If the operation got queued and will be sent.</returns>
    public static bool CreateRoom(string roomName, RoomOptions roomOptions, TypedLobby typedLobby, string[] expectedUsers)
    {
        if (offlineMode)
        {
            if (offlineModeRoom != null)
            {
                Debug.LogError("CreateRoom failed. In offline mode you still have to leave a room to enter another.");
                return false;
            }
            EnterOfflineRoom(roomName, roomOptions, true);
            return true;
        }
        if (networkingPeer.Server != ServerConnection.MasterServer || !connectedAndReady)
        {
            Debug.LogError("CreateRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
            return false;
        }

        typedLobby = typedLobby ?? ((networkingPeer.insideLobby) ? networkingPeer.lobby : null);  // use given lobby, or active lobby (if any active) or none

        EnterRoomParams opParams = new EnterRoomParams();
        opParams.RoomName = roomName;
        opParams.RoomOptions = roomOptions;
        opParams.Lobby = typedLobby;
        opParams.ExpectedUsers = expectedUsers;

        return networkingPeer.OpCreateGame(opParams);
    }
开发者ID:yuvadius,项目名称:need4bit,代码行数:58,代码来源:PhotonNetwork.cs


注:本文中的EnterRoomParams类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。