예제 #1
0
        /// <summary>
        /// Broadcasts a message to all players in a room
        /// </summary>
        /// <param name="map">Map/Room to send to</param>
        /// <param name="gameMessage">IMessage to send</param>
        public void Broadcast(Map map, IMessage gameMessage)
        {
            NetOutgoingMessage message = EncodeMessage(gameMessage);

            //Search for recipients
            List<NetConnection> recipients = NetServer.Connections.Where(
                x => Server.PlayerFromRUI(x.RemoteUniqueIdentifier, true) != null &&
                    Server.PlayerFromRUI(x.RemoteUniqueIdentifier, true).Map == map)
                    .ToList<NetConnection>();

            if (recipients.Count > 0) //Send to recipients found
                NetServer.SendMessage(message,recipients, NetDeliveryMethod.ReliableOrdered,0);
        }
예제 #2
0
파일: Player.cs 프로젝트: Cyral/Bricklayer
        public EntityState SimulationState; //Current internal state (What the game sees)

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new base of a player
        /// </summary>
        public Player(Map map, Vector2 position, string name, int id)
        {
            Map = map;
            Smiley = SmileyType.Default;
            Mode = PlayerMode.Normal;
            Tint = Color.White;

            SimulationState = new EntityState();
            DisplayState = new EntityState();
            PreviousState = new EntityState();

            SimulationState.Position = PreviousState.Position = DisplayState.Position = position;

            if (id > byte.MaxValue)
                throw new ArgumentOutOfRangeException("id", id, "The player ID must be within range of a single byte.");
            ID = (byte)id;
            Username = name;

            Index = map.Players.Count;
        }
예제 #3
0
 public InitMessage(NetIncomingMessage im, Map map)
 {
     this.map = map;
     this.Decode(im);
 }
예제 #4
0
 public InitMessage(Map map)
 {
     this.map = map;
 }
예제 #5
0
파일: Player.cs 프로젝트: Cyral/Bricklayer
 public Player(Map map, Vector2 position, string name, long remoteUniqueIdentifier, int id)
     : base(map, position, name, id)
 {
     RemoteUniqueIdentifier = remoteUniqueIdentifier;
 }