Beispiel #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);
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
 public InitMessage(NetIncomingMessage im, Map map)
 {
     this.map = map;
     this.Decode(im);
 }
Beispiel #4
0
 public InitMessage(Map map)
 {
     this.map = map;
 }
Beispiel #5
0
 public Player(Map map, Vector2 position, string name, long remoteUniqueIdentifier, int id)
     : base(map, position, name, id)
 {
     RemoteUniqueIdentifier = remoteUniqueIdentifier;
 }