Пример #1
0
        /// <summary>
        /// change the player to the specified room
        /// </summary>
        /// <param name="room"></param>
        public void ChangeRoom(Room room)
        {
            newRoom = room;

            if (CurrentRoom != null)
            {
                CurrentRoom.RemovePlayer(this);
            }
            CurrentRoom = null;

            var message = PNetServer.peer.CreateMessage();

            message.Write(RPCUtils.ChangeRoom);
            message.Write(room.Name);

            connection.SendMessage(message, NetDeliveryMethod.ReliableOrdered, Channels.STATIC_UTILS);
        }
Пример #2
0
        /// <summary>
        /// change the player to the specified room
        /// </summary>
        /// <exception cref="ThreadStateException">if GameState.InvokeRequired</exception>
        /// <param name="room"></param>
        public void ChangeRoom(Room room)
        {
            if (GameState.InvokeRequired)
            {
                throw new ThreadStateException("Cannot change rooms on unless on gamestate's update thread");
            }

            newRoom = room;

            if (CurrentRoom != null)
            {
                CurrentRoom.RemovePlayer(this);
            }
            CurrentRoom = null;

            var message = PNetServer.peer.CreateMessage();

            message.Write(RPCUtils.ChangeRoom);
            message.Write(room.Name);

            connection.SendMessage(message, NetDeliveryMethod.ReliableOrdered, Channels.STATIC_UTILS);
        }