Inheritance: Bricklayer.Common.World.Map
Example #1
0
 /// <summary>
 /// Finds an empty slot to use as a player's ID
 /// </summary>
 public static byte FindEmptyID(Map map)
 {
     for (int i = 0; i < Config.MaxPlayers; i++)
         if (!map.Players.Any(x => x.ID == i))
             return (byte)i;
     Program.WriteLine("Could not find empty ID!", ConsoleColor.Red);
     return 0;
 }
Example #2
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);
        }
Example #3
0
        private float tagAlpha = 0; //Alpha color value for nametags

        #endregion Fields

        #region Constructors

        public Player(Map map, Vector2 position, string name, long RUI, int ID)
        {
            this.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;

            this.RUI = RUI;
            this.ID = (byte)ID;
            this.Username = name;
            Index = map.Players.Count;
        }
Example #4
0
 /// <summary>
 /// Creates a new map and adds it to the room list
 /// </summary>
 public static Map CreateMap(string name, string description)
 {
     Map map = new Map(name, description, 200, 100, Maps.Count) { Rating = 5 };
     Maps.Add(map);
     return map;
 }
Example #5
0
 /// <summary>
 /// Rebuilds the indexes of all players, by changing their index property to the correct index in the map's player list
 /// </summary>
 private static void RebuildIndexes(Map map)
 {
     for (int i = 0; i < map.Players.Count; i++)
         map.Players[i].Index = i;
 }
Example #6
0
        private float tagAlpha = 0; //Alpha color value for nametags

        public Player(Map map, Vector2 position, string name, int id)
            : base(map, position, name, id)
        {
        }
Example #7
0
        private float tagAlpha = 0; //Alpha color value for nametags

        #endregion Fields

        #region Constructors

        public Player(Map map, Vector2 position, string name, int id)
            : base(map, position, name, id)
        {
        }
Example #8
0
 public InitMessage(NetIncomingMessage im, Map map)
 {
     this.map = map;
     this.Decode(im);
 }
Example #9
0
 public InitMessage(Map map)
 {
     this.map = map;
 }
Example #10
0
        private Color[,] twoArray; //Array for holding raw 2D tile colors

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new minimap
        /// </summary>
        /// <param name="map">Map to base the preview off of</param>
        /// <param name="maxWidth">Maximum width of the minimap</param>
        /// <param name="maxHeight">Maximum height of the minimap</param>
        public Minimap(Map map, int maxWidth, int maxHeight)
        {
            this.map = map;
            Width = Math.Min(maxWidth, map.Width);
            Height = Math.Min(maxHeight, map.Height);
        }