Beispiel #1
0
 /// <summary>
 /// Creates the preview of a map.
 /// </summary>
 /// <param name="mapID">The ID of the map to create the preview of.</param>
 /// <param name="drawExtensions">The collection of <see cref="IMapDrawingExtension"/>s applied to the map.</param>
 public Image CreatePreview(MapID mapID, ICollection <IMapDrawingExtension> drawExtensions)
 {
     using (var map = CreateTempMap(mapID))
     {
         return(CreatePreview(map, drawExtensions));
     }
 }
Beispiel #2
0
        /// <summary>
        /// Saves a map as a new mini-map.
        /// </summary>
        /// <param name="mapID">The map ID to save.</param>
        /// <param name="folder">The name of the folder to save to.</param>
        public static void SaveMiniMap(MapID mapID, string folder)
        {
            var tb      = ToolBar.GetToolBar(ToolBarVisibility.Map);
            var tbItems = tb.Items;

            tbItems["Map Preview"].PerformClick();
        }
Beispiel #3
0
        public void SetCurrentRoom()
        {
            if (MapID.StartsWith("rd"))
            {
                CurrentRoom = GetTargetRoom();

                if (PlayerManager.MyPlayer.CurrentRoom.Width < 3)
                {
                    if (PlayerManager.MyPlayer.CurrentRoom.Height > 2)
                    {
                        CurrentRoom.Y      = Y - 1;
                        CurrentRoom.Height = 2;
                    }
                }
                if (PlayerManager.MyPlayer.CurrentRoom.Height < 3)
                {
                    if (PlayerManager.MyPlayer.CurrentRoom.Width > 2)
                    {
                        CurrentRoom.X     = X - 1;
                        CurrentRoom.Width = 2;
                    }
                }
            }
            else
            {
                if (PlayerManager.MyPlayer.CurrentRoom == null)
                {
                    CurrentRoom = new Maps.DungeonRoom(0, 0, 0, 0);
                }
                CurrentRoom.X      = 0;
                CurrentRoom.Y      = 0;
                CurrentRoom.Width  = Maps.MapHelper.ActiveMap.MaxX;
                CurrentRoom.Height = Maps.MapHelper.ActiveMap.MaxY;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="InputNewMapIDForm"/> class.
        /// </summary>
        /// <param name="defaultValue">The default value.</param>
        public InputNewMapIDForm(MapID? defaultValue)
        {
            InitializeComponent();

            if (defaultValue.HasValue)
                txtID.Text = defaultValue.Value.ToString();
        }
Beispiel #5
0
        public static Map GetMap(MapID m)
        {
            Map val;

            MapList.TryGetValue(m, out val);
            return(val);
        }
Beispiel #6
0
        public void Warp(MapID mapID)
        {
            // Check for a valid map
            if (!MapBase.MapIDExists(mapID))
            {
                UserChat("Invalid map ID `{0}`.", mapID);
                return;
            }

            var map = World.GetMap(mapID);

            if (map == null)
            {
                UserChat("No map with ID `{0}` exists.", mapID);
                return;
            }

            var pos = User.Position;

            if (pos.X < 0 || pos.Y < 0 || pos.X > map.Width || pos.Y > map.Height)
            {
                UserChat("The position of your current coordinates are out of the map's range. Map size: {0}", map.Size);
                return;
            }

            // Move the user
            User.Teleport(map, pos);
        }
Beispiel #7
0
        static void DeleteMiniMap(MapID mapId)
        {
            try
            {
                // Delete file
                string filePathDev = MapBase.GetMiniMapFilePath(ContentPaths.Dev, mapId);
                if (File.Exists(filePathDev))
                {
                    File.Delete(filePathDev);
                }

                try
                {
                    string filePathBuild = MapBase.GetMiniMapFilePath(ContentPaths.Build, mapId);
                    if (File.Exists(filePathBuild))
                    {
                        File.Delete(filePathBuild);
                    }
                }
                catch
                {
                }
            }
            catch (Exception ex)
            {
                const string errmsg = "Failed to delete the mini-map for mapId `{0}`. Exception: {1}";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, mapId, ex);
                }
                Debug.Fail(string.Format(errmsg, mapId, ex));

                throw;
            }
        }
Beispiel #8
0
 /// <summary>
 /// Creates the preview of a map.
 /// </summary>
 /// <param name="mapID">The ID of the map to create the preview of.</param>
 /// <param name="drawExtensions">The collection of <see cref="IMapDrawingExtension"/>s applied to the map.</param>
 /// <param name="filePath">The file path to save the created preview to.</param>
 public void CreatePreview(MapID mapID, ICollection <IMapDrawingExtension> drawExtensions, string filePath)
 {
     using (var map = CreateTempMap(mapID))
     {
         CreatePreview(map, drawExtensions, filePath);
     }
 }
Beispiel #9
0
        public void CreateMapInstance(MapID mapID)
        {
            // Check for a valid map
            if (!MapBase.MapIDExists(mapID))
            {
                UserChat("Invalid map ID: " + mapID);
                return;
            }

            // Try to create the map
            MapInstance instance;

            try
            {
                instance = new MapInstance(mapID, World);
            }
            catch (Exception ex)
            {
                UserChat("Failed to create instance: " + ex);
                return;
            }

            // Add the user to the map
            User.Teleport(instance, new Vector2(50, 50));
        }
Beispiel #10
0
        public static PacketWriter SetMap(MapID mapID)
        {
            var pw = GetWriter();

            SetMap(pw, mapID);
            return(pw);
        }
        public void Warp(MapID mapID, int x, int y)
        {
            // Check for a valid map
            if (!MapBase.MapIDExists(mapID))
            {
                UserChat("Invalid map ID `{0}`.", mapID);
                return;
            }

            var map = World.GetMap(mapID);

            if (map == null)
            {
                UserChat("No map with ID `{0}` exists.", mapID);
                return;
            }

            var pos = new Vector2(x, y);

            if (pos.X < 0 || pos.Y < 0 || pos.X > map.Width || pos.Y > map.Height)
            {
                UserChat("The specified coordinates are out of the map's range. Map size: {0}", map.Size);
                return;
            }

            // Move the user
            User.Teleport(map, pos);
        }
Beispiel #12
0
        /// <summary>
        /// Creates a temporary <see cref="Map"/>.
        /// </summary>
        /// <param name="mapID">The <see cref="MapID"/> of the map.</param>
        /// <returns>The temporary <see cref="Map"/>.</returns>
        static Map CreateTempMap(MapID mapID)
        {
            var camera = new Camera2D(new Vector2(800, 600));
            var map    = new Map(mapID, camera, GetTimeDummy.Instance);

            map.Load(ContentPaths.Dev, false, EditorDynamicEntityFactory.Instance);
            return(map);
        }
Beispiel #13
0
        /// <summary>
        /// Gets the NPC spawns on a map.
        /// </summary>
        /// <param name="mapID">The ID of the map to get the spawns for.</param>
        /// <returns>The NPC spawns for the given <paramref name="mapID"/>.</returns>
        public static IEnumerable <IMapSpawnTable> GetSpawns(MapID mapID)
        {
            var dbController = DbControllerBase.GetInstance();
            var q            = dbController.GetQuery <SelectMapSpawnsOnMapQuery>();
            var spawns       = q.Execute(mapID);

            return(spawns);
        }
Beispiel #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Map"/> class.
 /// </summary>
 /// <param name="mapID">ID of the Map.</param>
 /// <param name="world">World that the Map will be inside of.</param>
 /// <exception cref="ArgumentException"><paramref name="mapID"/> returned false for <see cref="MapBase.MapIDExists"/>.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="world"/> is null.</exception>
 public Map(MapID mapID, World world) : base(mapID, world)
 {
     _world = world;
     if (log.IsInfoEnabled)
     {
         log.InfoFormat("Created Map `{0}`.", this);
     }
 }
Beispiel #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapInstance"/> class.
        /// </summary>
        /// <param name="mapID">ID of the Map to create the instance of.</param>
        /// <param name="world">World that the <see cref="MapInstance"/> will be inside of.</param>
        /// <exception cref="ArgumentException"><paramref name="mapID"/> returned false for <see cref="MapBase.MapIDExists"/>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="world"/> is null.</exception>
        public MapInstance(MapID mapID, World world) : base(mapID, world)
        {
            Load();

            world.AddMapInstance(this);

            _deleteTime = TickCount.Now + _initialDeleteTimeout;
        }
Beispiel #16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapInstance"/> class.
        /// </summary>
        /// <param name="mapID">ID of the Map to create the instance of.</param>
        /// <param name="world">World that the <see cref="MapInstance"/> will be inside of.</param>
        /// <exception cref="ArgumentException"><paramref name="mapID"/> returned false for <see cref="MapBase.MapIDExists"/>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="world"/> is null.</exception>
        public MapInstance(MapID mapID, World world) : base(mapID, world)
        {
            Load();

            world.AddMapInstance(this);

            _deleteTime = TickCount.Now + _initialDeleteTimeout;
        }
Beispiel #17
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="map">
 /// The map identity on which the location is represented.
 /// </param>
 /// <param name="x">
 /// The X coordinate of the map location.
 /// </param>
 /// <param name="y">
 /// The Y coordinate of the map location.
 /// </param>
 /// <param name="location">
 /// The location parent class.
 /// </param>
 /// <param name="requirement">
 /// The mode requirement for displaying this map location.
 /// </param>
 public MapLocation(
     MapID map, double x, double y, ILocation location, IRequirement requirement)
 {
     Map         = map;
     X           = x;
     Y           = y;
     Location    = location;
     Requirement = requirement;
 }
        /// <summary>
        /// Changes the current map being displayed.
        /// </summary>
        /// <param name="mapID">The <see cref="MapID"/> to change to.</param>
        public void ChangeMap(MapID mapID)
        {
            if (Map != null && Map.ID == mapID)
            {
                return;
            }

            Map = new EditorMap(mapID, Camera, this);
        }
Beispiel #19
0
        public int CompareTo(Map other)
        {
            if (other == null)
            {
                return(-1);
            }

            return(MapID.CompareTo(other.MapID));
        }
Beispiel #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapSpawnValues"/> class.
 /// </summary>
 /// <param name="dbController">The DbController used to synchronize changes to the values.</param>
 /// <param name="id">The unique ID of this MapSpawnValues.</param>
 /// <param name="mapID">The index of the Map that these values are for.</param>
 /// <param name="characterTemplateID">The CharacterTemplateID of the CharacterTemplate to spawn.</param>
 /// <param name="spawnAmount">The maximum number of Characters that will be spawned by this MapSpawnValues.</param>
 /// <param name="spawnRect">The area on the map the spawning will take place at.</param>
 MapSpawnValues(IDbController dbController, MapSpawnValuesID id, MapID mapID, CharacterTemplateID characterTemplateID,
                byte spawnAmount, MapSpawnRect spawnRect)
 {
     _dbController = dbController;
     _id = id;
     _mapID = mapID;
     _characterTemplateID = characterTemplateID;
     _spawnAmount = spawnAmount;
     _spawnArea = spawnRect;
 }
Beispiel #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapSpawnValues"/> class.
 /// </summary>
 /// <param name="dbController">The DbController used to synchronize changes to the values.</param>
 /// <param name="id">The unique ID of this MapSpawnValues.</param>
 /// <param name="mapID">The index of the Map that these values are for.</param>
 /// <param name="characterTemplateID">The CharacterTemplateID of the CharacterTemplate to spawn.</param>
 /// <param name="spawnAmount">The maximum number of Characters that will be spawned by this MapSpawnValues.</param>
 /// <param name="spawnRect">The area on the map the spawning will take place at.</param>
 MapSpawnValues(IDbController dbController, MapSpawnValuesID id, MapID mapID, CharacterTemplateID characterTemplateID,
                byte spawnAmount, MapSpawnRect spawnRect)
 {
     _dbController        = dbController;
     _id                  = id;
     _mapID               = mapID;
     _characterTemplateID = characterTemplateID;
     _spawnAmount         = spawnAmount;
     _spawnArea           = spawnRect;
 }
Beispiel #22
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="location">
        /// The location parent class.
        /// </param>
        /// <param name="map">
        /// The map identity on which the location is represented.
        /// </param>
        /// <param name="x">
        /// The X coordinate of the map location.
        /// </param>
        /// <param name="y">
        /// The Y coordinate of the map location.
        /// </param>
        /// <param name="requirement">
        /// The mode requirement for displaying this map location.
        /// </param>
        public MapLocation(
            LocationID locationID, MapID map, double x, double y, IRequirement requirement = null)
        {
            _locationID = locationID;
            Map         = map;
            X           = x;
            Y           = y;
            Requirement = requirement ?? RequirementDictionary.Instance[RequirementType.NoRequirement];

            LocationDictionary.Instance.LocationCreated += OnLocationCreated;
        }
Beispiel #23
0
 public override int GetHashCode() {
   int hash = 1;
   if (Success != false) hash ^= Success.GetHashCode();
   if (MapID != 0) hash ^= MapID.GetHashCode();
   if (role_ != null) hash ^= Role.GetHashCode();
   if (WorldID != 0) hash ^= WorldID.GetHashCode();
   if (_unknownFields != null) {
     hash ^= _unknownFields.GetHashCode();
   }
   return hash;
 }
Beispiel #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapSpawnValues"/> class.
 /// </summary>
 /// <param name="dbController">The DbController used to synchronize changes to the values.</param>
 /// <param name="id">The unique ID of this MapSpawnValues.</param>
 /// <param name="mapID">The index of the Map that these values are for.</param>
 /// <param name="characterTemplateID">The CharacterTemplateID of the CharacterTemplate to spawn.</param>
 /// <param name="spawnAmount">The maximum number of Characters that will be spawned by this MapSpawnValues.</param>
 /// <param name="spawnRect">The area on the map the spawning will take place at.</param>
 /// <param name="spawnDirection">The direction on this map to spawn the NPCs.</param>
 /// <param name="spawnRespawn">The time it takes for an NPC to spawn.</param>
 MapSpawnValues(IDbController dbController, MapSpawnValuesID id, MapID mapID, CharacterTemplateID characterTemplateID,
                byte spawnAmount, MapSpawnRect spawnRect, Direction spawnDirection, ushort spawnRespawn)
 {
     _dbController = dbController;
     _id = id;
     _mapID = mapID;
     _characterTemplateID = characterTemplateID;
     _spawnAmount = spawnAmount;
     _spawnArea = spawnRect;
     _spawnDirection = spawnDirection;
     _spawnRespawn = spawnRespawn;
 }
Beispiel #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapSpawnTable"/> class.
 /// </summary>
 /// <param name="amount">The initial value for the corresponding property.</param>
 /// <param name="characterTemplateID">The initial value for the corresponding property.</param>
 /// <param name="height">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="mapID">The initial value for the corresponding property.</param>
 /// <param name="width">The initial value for the corresponding property.</param>
 /// <param name="x">The initial value for the corresponding property.</param>
 /// <param name="y">The initial value for the corresponding property.</param>
 public MapSpawnTable(Byte @amount, CharacterTemplateID @characterTemplateID, ushort? @height, MapSpawnValuesID @iD,
                      MapID @mapID, ushort? @width, ushort? @x, ushort? @y)
 {
     Amount = @amount;
     CharacterTemplateID = @characterTemplateID;
     Height = @height;
     ID     = @iD;
     MapID  = @mapID;
     Width  = @width;
     X      = @x;
     Y      = @y;
 }
Beispiel #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapSpawnValues"/> class.
 /// </summary>
 /// <param name="dbController">The DbController used to synchronize changes to the values.</param>
 /// <param name="id">The unique ID of this MapSpawnValues.</param>
 /// <param name="mapID">The index of the Map that these values are for.</param>
 /// <param name="characterTemplateID">The CharacterTemplateID of the CharacterTemplate to spawn.</param>
 /// <param name="spawnAmount">The maximum number of Characters that will be spawned by this MapSpawnValues.</param>
 /// <param name="spawnRect">The area on the map the spawning will take place at.</param>
 /// <param name="spawnDirection">The direction on this map to spawn the NPCs.</param>
 /// <param name="spawnRespawn">The time it takes for an NPC to spawn.</param>
 MapSpawnValues(IDbController dbController, MapSpawnValuesID id, MapID mapID, CharacterTemplateID characterTemplateID,
                byte spawnAmount, MapSpawnRect spawnRect, Direction spawnDirection, ushort spawnRespawn)
 {
     _dbController        = dbController;
     _id                  = id;
     _mapID               = mapID;
     _characterTemplateID = characterTemplateID;
     _spawnAmount         = spawnAmount;
     _spawnArea           = spawnRect;
     _spawnDirection      = spawnDirection;
     _spawnRespawn        = spawnRespawn;
 }
Beispiel #27
0
        /// <summary>
        /// Loads all of the MapSpawnValues for the given <paramref name="mapID"/> from the database.
        /// </summary>
        /// <param name="dbController">DbController used to communicate with the database.</param>
        /// <param name="mapID">Index of the map to load the MapSpawnValues for.</param>
        /// <returns>An IEnumerable of all of the MapSpawnValues for the given <paramref name="mapID"/>.</returns>
        public static IEnumerable <MapSpawnValues> Load(IDbController dbController, MapID mapID)
        {
            var ret         = new List <MapSpawnValues>();
            var queryValues = dbController.GetQuery <SelectMapSpawnsOnMapQuery>().Execute(mapID);

            foreach (var v in queryValues)
            {
                Debug.Assert(v.MapID == mapID);
                ret.Add(new MapSpawnValues(dbController, v));
            }

            return(ret);
        }
Beispiel #28
0
        public LobbyBuilder(string lobbyName, string gamemode, GameType gametype, MapID mapId, int teamSize)
        {
            JSON = new JObject();
            JSON.customGameLobby = new JObject();
            JSON.customGameLobby.configuration = new JObject();
            JSON.customGameLobby.configuration.gameTypeConfig = new JObject();

            JSON.isCustom = true;
            JSON.customGameLobby.lobbyName = lobbyName;
            JSON.customGameLobby.configuration.gameMode          = gamemode;
            JSON.customGameLobby.configuration.mapId             = mapId;
            JSON.customGameLobby.configuration.teamSize          = teamSize;
            JSON.customGameLobby.configuration.gameTypeConfig.id = gametype;
        }
        void CheckLegalMapPos(List<string> errs, Server server, string settingName, MapID mapID, Vector2 pos)
        {
            var map = server.World.GetMap(mapID);
            if (map == null)
            {
                Add(errs, "`{0}` is invalid: map `{1}` does not exist", settingName, mapID);
                return;
            }

            if (pos.X < 0 || pos.Y < 0 || pos.X > map.Width || pos.Y > map.Height)
            {
                Add(errs, "`{0}` is invalid: position `{1}` is outside of the bounds of map `{2}` (size: {3})", settingName, pos,
                    map, map.Size);
                return;
            }
        }
        public void OnMain()
        {
            mapNum = MapID.MainMenu;

            if (world != null)
            {
                world.UnloadContent();
            }

            world = new GameWorld(this, "MainMenuMap.map");
            world.Initialize();
            world.LoadContent();
            (world.tileEngine as RPGGame).bossAlive = true;
            BlobBehavior.fork = false;

            curState = GameState.MAIN;
        }
Beispiel #31
0
        void CheckLegalMapPos(List <string> errs, Server server, string settingName, MapID mapID, Vector2 pos)
        {
            var map = server.World.GetMap(mapID);

            if (map == null)
            {
                Add(errs, "`{0}` is invalid: map `{1}` does not exist", settingName, mapID);
                return;
            }

            if (pos.X < 0 || pos.Y < 0 || pos.X > map.Width || pos.Y > map.Height)
            {
                Add(errs, "`{0}` is invalid: position `{1}` is outside of the bounds of map `{2}` (size: {3})", settingName, pos,
                    map, map.Size);
                return;
            }
        }
Beispiel #32
0
        /// <summary>
        /// Returns a map by its <see cref="MapID"/>.
        /// </summary>
        /// <param name="mapID">The ID of the map.</param>
        /// <returns>Map for the given index, or null if invalid.</returns>
        public Map GetMap(MapID mapID)
        {
            Map map = null;

            if (mapID < _maps.Length && mapID >= 0)
            {
                map = _maps[(int)mapID];
            }

            if (map == null)
            {
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat("GetMap() on ID `{0}` returned null because map does not exist.", mapID);
                }
            }

            return(map);
        }
Beispiel #33
0
        /// <summary>
        /// Gets the map and position to spawn a <see cref="User"/> after they have been killed.
        /// </summary>
        /// <param name="user">The <see cref="User"/> to respawn.</param>
        /// <param name="mapID">The ID of the map to spawn the <paramref name="user"/> on.</param>
        /// <param name="position">The position to spawn the <paramref name="user"/> at.</param>
        public static void GetUserRespawnPosition(User user, out MapID mapID, out Vector2 position)
        {
            // Grab the position/map from the user's properties
            if (user.RespawnMapID.HasValue)
            {
                var map    = user.World.GetMap(user.RespawnMapID.Value);
                var mapPos = user.RespawnPosition;
                if (map != null && map.Size.X > mapPos.X && map.Size.Y > mapPos.Y && mapPos.X >= 0 && mapPos.Y >= 0)
                {
                    mapID    = user.RespawnMapID.Value;
                    position = user.RespawnPosition;
                    return;
                }
            }

            // Failed to grab valid value from user's properties. Use fallback values.
            mapID    = ServerSettings.Default.InvalidUserLoadMap;
            position = ServerSettings.Default.InvalidUserLoadPosition;
        }
Beispiel #34
0
        /// <summary>
        /// Gets the map and position to spawn a <see cref="User"/> after they have been killed.
        /// </summary>
        /// <param name="user">The <see cref="User"/> to respawn.</param>
        /// <param name="mapID">The ID of the map to spawn the <paramref name="user"/> on.</param>
        /// <param name="position">The position to spawn the <paramref name="user"/> at.</param>
        public static void GetUserRespawnPosition(User user, out MapID mapID, out Vector2 position)
        {
            // Grab the position/map from the user's properties
            if (user.RespawnMapID.HasValue)
            {
                var map = user.World.GetMap(user.RespawnMapID.Value);
                var mapPos = user.RespawnPosition;
                if (map != null && map.Size.X < mapPos.X && map.Size.Y < mapPos.Y && mapPos.X >= 0 && mapPos.Y >= 0)
                {
                    mapID = user.RespawnMapID.Value;
                    position = user.RespawnPosition;
                    return;
                }
            }

            // Failed to grab valid value from user's properties. Use fallback values.
            mapID = ServerSettings.Default.InvalidUserLoadMap;
            position = ServerSettings.Default.InvalidUserLoadPosition;
        }
Beispiel #35
0
        /// <summary>
        /// Returns a map by its <see cref="MapID"/>.
        /// </summary>
        /// <param name="mapID">The ID of the map.</param>
        /// <returns>Map for the given index, or null if invalid.</returns>
        public Map GetMap(MapID mapID)
        {
            // If the map can be grabbed from the index, grab it
            if (_maps.CanGet((int)mapID))
            {
                // Check that the map is valid
                Debug.Assert(_maps[(int)mapID] != null, "Tried to get a null map.");

                // Return the map at the index
                return(_maps[(int)mapID]);
            }

            // Could not grab by index
            if (log.IsWarnEnabled)
            {
                log.WarnFormat("GetMap() on ID `{0}` returned null because map does not exist.", mapID);
            }

            return(null);
        }
Beispiel #36
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (opts_ != null)
            {
                hash ^= Opts.GetHashCode();
            }
            if (MapID != 0)
            {
                hash ^= MapID.GetHashCode();
            }
            if (ConnTimeout != 0)
            {
                hash ^= ConnTimeout.GetHashCode();
            }
            hash ^= teamInfos_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public void CreateMapInstance(MapID mapID)
        {
            // Check for a valid map
            if (!MapBase.MapIDExists(mapID))
            {
                UserChat("Invalid map ID: " + mapID);
                return;
            }

            // Try to create the map
            MapInstance instance;
            try
            {
                instance = new MapInstance(mapID, World);
            }
            catch (Exception ex)
            {
                UserChat("Failed to create instance: " + ex);
                return;
            }

            // Add the user to the map
            User.Teleport(instance, new Vector2(50, 50));
        }
Beispiel #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapSpawnTable"/> class.
 /// </summary>
 /// <param name="amount">The initial value for the corresponding property.</param>
 /// <param name="characterTemplateID">The initial value for the corresponding property.</param>
 /// <param name="height">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="mapID">The initial value for the corresponding property.</param>
 /// <param name="width">The initial value for the corresponding property.</param>
 /// <param name="x">The initial value for the corresponding property.</param>
 /// <param name="y">The initial value for the corresponding property.</param>
 public MapSpawnTable(Byte @amount, CharacterTemplateID @characterTemplateID, ushort? @height, MapSpawnValuesID @iD,
                      MapID @mapID, ushort? @width, ushort? @x, ushort? @y)
 {
     Amount = @amount;
     CharacterTemplateID = @characterTemplateID;
     Height = @height;
     ID = @iD;
     MapID = @mapID;
     Width = @width;
     X = @x;
     Y = @y;
 }
Beispiel #39
0
 /// <summary>
 /// Saves a map as a new mini-map.
 /// </summary>
 /// <param name="mapID">The map ID to save.</param>
 /// <param name="folder">The name of the folder to save to.</param>
 public static void SaveMiniMap(MapID mapID, string folder)
 {
     var tb = ToolBar.GetToolBar(ToolBarVisibility.Map);
     var tbItems = tb.Items;
     tbItems["Map Preview"].PerformClick();
 }
Beispiel #40
0
        /// <summary>
        /// Loads all of the MapSpawnValues for the given <paramref name="mapID"/> from the database.
        /// </summary>
        /// <param name="dbController">DbController used to communicate with the database.</param>
        /// <param name="mapID">Index of the map to load the MapSpawnValues for.</param>
        /// <returns>An IEnumerable of all of the MapSpawnValues for the given <paramref name="mapID"/>.</returns>
        public static IEnumerable<MapSpawnValues> Load(IDbController dbController, MapID mapID)
        {
            var ret = new List<MapSpawnValues>();
            var queryValues = dbController.GetQuery<SelectMapSpawnsOnMapQuery>().Execute(mapID);

            foreach (var v in queryValues)
            {
                Debug.Assert(v.MapID == mapID);
                ret.Add(new MapSpawnValues(dbController, v));
            }

            return ret;
        }
Beispiel #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EditorMap"/> class.
 /// </summary>
 /// <param name="mapID">The ID of the map.</param>
 /// <param name="camera">The camera used to view the map.</param>
 /// <param name="getTime">The object used to get the current time.</param>
 public EditorMap(MapID mapID, ICamera2D camera, IGetTime getTime) : base(mapID, camera, getTime)
 {
     _undoManager = new MapUndoManager(this, GlobalState.Instance.DynamicEntityFactory);
 }
Beispiel #42
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Map"/> class.
        /// </summary>
        /// <param name="mapID">The ID of the map.</param>
        /// <param name="camera">The camera used to view the map.</param>
        /// <param name="getTime">The object used to get the current time.</param>
        public Map(MapID mapID, ICamera2D camera, IGetTime getTime) : base(mapID, getTime)
        {
            _camera = camera;

            DrawParticles = true;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WorldStatsQuestCancelTable"/> class.
 /// </summary>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="mapID">The initial value for the corresponding property.</param>
 /// <param name="questID">The initial value for the corresponding property.</param>
 /// <param name="userID">The initial value for the corresponding property.</param>
 /// <param name="when">The initial value for the corresponding property.</param>
 /// <param name="x">The initial value for the corresponding property.</param>
 /// <param name="y">The initial value for the corresponding property.</param>
 public WorldStatsQuestCancelTable(UInt32 @iD, MapID? @mapID, QuestID @questID, CharacterID @userID, DateTime @when,
                                   UInt16 @x, UInt16 @y)
 {
     ID = @iD;
     MapID = @mapID;
     QuestID = @questID;
     UserID = @userID;
     When = @when;
     X = @x;
     Y = @y;
 }
Beispiel #44
0
 /// <summary>
 /// Gets the NPC spawns on a map.
 /// </summary>
 /// <param name="mapID">The ID of the map to get the spawns for.</param>
 /// <returns>The NPC spawns for the given <paramref name="mapID"/>.</returns>
 public static IEnumerable<IMapSpawnTable> GetSpawns(MapID mapID)
 {
     var dbController = DbControllerBase.GetInstance();
     var q = dbController.GetQuery<SelectMapSpawnsOnMapQuery>();
     var spawns = q.Execute(mapID);
     return spawns;
 }
Beispiel #45
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CharacterTable"/> class.
 /// </summary>
 /// <param name="aIID">The initial value for the corresponding property.</param>
 /// <param name="bodyID">The initial value for the corresponding property.</param>
 /// <param name="cash">The initial value for the corresponding property.</param>
 /// <param name="characterTemplateID">The initial value for the corresponding property.</param>
 /// <param name="chatDialog">The initial value for the corresponding property.</param>
 /// <param name="exp">The initial value for the corresponding property.</param>
 /// <param name="hP">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="level">The initial value for the corresponding property.</param>
 /// <param name="loadMapID">The initial value for the corresponding property.</param>
 /// <param name="loadX">The initial value for the corresponding property.</param>
 /// <param name="loadY">The initial value for the corresponding property.</param>
 /// <param name="moveSpeed">The initial value for the corresponding property.</param>
 /// <param name="mP">The initial value for the corresponding property.</param>
 /// <param name="name">The initial value for the corresponding property.</param>
 /// <param name="respawnMapID">The initial value for the corresponding property.</param>
 /// <param name="respawnX">The initial value for the corresponding property.</param>
 /// <param name="respawnY">The initial value for the corresponding property.</param>
 /// <param name="shopID">The initial value for the corresponding property.</param>
 /// <param name="statPoints">The initial value for the corresponding property.</param>
 /// <param name="statAgi">The initial value for the corresponding property.</param>
 /// <param name="statDefence">The initial value for the corresponding property.</param>
 /// <param name="statInt">The initial value for the corresponding property.</param>
 /// <param name="statMaxhit">The initial value for the corresponding property.</param>
 /// <param name="statMaxhp">The initial value for the corresponding property.</param>
 /// <param name="statMaxmp">The initial value for the corresponding property.</param>
 /// <param name="statMinhit">The initial value for the corresponding property.</param>
 /// <param name="statStr">The initial value for the corresponding property.</param>
 public CharacterTable(AIID? @aIID, BodyID @bodyID, Int32 @cash, CharacterTemplateID? @characterTemplateID,
                       NPCChatDialogID? @chatDialog, Int32 @exp, SPValueType @hP, CharacterID @iD, Byte @level,
                       MapID @loadMapID, UInt16 @loadX, UInt16 @loadY, UInt16 @moveSpeed, SPValueType @mP, String @name,
                       MapID? @respawnMapID, Single @respawnX, Single @respawnY, ShopID? @shopID, Int32 @statPoints,
                       Int16 @statAgi, Int16 @statDefence, Int16 @statInt, Int16 @statMaxhit, Int16 @statMaxhp,
                       Int16 @statMaxmp, Int16 @statMinhit, Int16 @statStr)
 {
     AIID = @aIID;
     BodyID = @bodyID;
     Cash = @cash;
     CharacterTemplateID = @characterTemplateID;
     ChatDialog = @chatDialog;
     Exp = @exp;
     HP = @hP;
     ID = @iD;
     Level = @level;
     LoadMapID = @loadMapID;
     LoadX = @loadX;
     LoadY = @loadY;
     MoveSpeed = @moveSpeed;
     MP = @mP;
     Name = @name;
     RespawnMapID = @respawnMapID;
     RespawnX = @respawnX;
     RespawnY = @respawnY;
     ShopID = @shopID;
     StatPoints = @statPoints;
     SetStat(StatType.Agi, @statAgi);
     SetStat(StatType.Defence, @statDefence);
     SetStat(StatType.Int, @statInt);
     SetStat(StatType.MaxHit, @statMaxhit);
     SetStat(StatType.MaxHP, @statMaxhp);
     SetStat(StatType.MaxMP, @statMaxmp);
     SetStat(StatType.MinHit, @statMinhit);
     SetStat(StatType.Str, @statStr);
 }
Beispiel #46
0
        /// <summary>
        /// Changes the current map being displayed.
        /// </summary>
        /// <param name="mapID">The <see cref="MapID"/> to change to.</param>
        public void ChangeMap(MapID mapID)
        {
            if (Map != null && Map.ID == mapID)
                return;

            Map = new EditorMap(mapID, Camera, this);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WorldStatsUserShoppingTable"/> class.
 /// </summary>
 /// <param name="amount">The initial value for the corresponding property.</param>
 /// <param name="characterID">The initial value for the corresponding property.</param>
 /// <param name="cost">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="itemTemplateID">The initial value for the corresponding property.</param>
 /// <param name="mapID">The initial value for the corresponding property.</param>
 /// <param name="saleType">The initial value for the corresponding property.</param>
 /// <param name="shopID">The initial value for the corresponding property.</param>
 /// <param name="when">The initial value for the corresponding property.</param>
 /// <param name="x">The initial value for the corresponding property.</param>
 /// <param name="y">The initial value for the corresponding property.</param>
 public WorldStatsUserShoppingTable(Byte @amount, CharacterID @characterID, Int32 @cost, UInt32 @iD,
                                    ItemTemplateID? @itemTemplateID, MapID? @mapID, SByte @saleType, ShopID @shopID,
                                    DateTime @when, UInt16 @x, UInt16 @y)
 {
     Amount = @amount;
     CharacterID = @characterID;
     Cost = @cost;
     ID = @iD;
     ItemTemplateID = @itemTemplateID;
     MapID = @mapID;
     SaleType = @saleType;
     ShopID = @shopID;
     When = @when;
     X = @x;
     Y = @y;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewNpcCharacterTable"/> class.
 /// </summary>
 /// <param name="aIID">The initial value for the corresponding property.</param>
 /// <param name="bodyID">The initial value for the corresponding property.</param>
 /// <param name="cash">The initial value for the corresponding property.</param>
 /// <param name="characterTemplateID">The initial value for the corresponding property.</param>
 /// <param name="chatDialog">The initial value for the corresponding property.</param>
 /// <param name="exp">The initial value for the corresponding property.</param>
 /// <param name="hP">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="level">The initial value for the corresponding property.</param>
 /// <param name="loadMapID">The initial value for the corresponding property.</param>
 /// <param name="loadX">The initial value for the corresponding property.</param>
 /// <param name="loadY">The initial value for the corresponding property.</param>
 /// <param name="moveSpeed">The initial value for the corresponding property.</param>
 /// <param name="mP">The initial value for the corresponding property.</param>
 /// <param name="name">The initial value for the corresponding property.</param>
 /// <param name="respawnMapID">The initial value for the corresponding property.</param>
 /// <param name="respawnX">The initial value for the corresponding property.</param>
 /// <param name="respawnY">The initial value for the corresponding property.</param>
 /// <param name="shopID">The initial value for the corresponding property.</param>
 /// <param name="statPoints">The initial value for the corresponding property.</param>
 /// <param name="statAgi">The initial value for the corresponding property.</param>
 /// <param name="statDefence">The initial value for the corresponding property.</param>
 /// <param name="statInt">The initial value for the corresponding property.</param>
 /// <param name="statMaxhit">The initial value for the corresponding property.</param>
 /// <param name="statMaxhp">The initial value for the corresponding property.</param>
 /// <param name="statMaxmp">The initial value for the corresponding property.</param>
 /// <param name="statMinhit">The initial value for the corresponding property.</param>
 /// <param name="statStr">The initial value for the corresponding property.</param>
 public ViewNpcCharacterTable(AIID? @aIID, BodyID @bodyID, Int32 @cash, CharacterTemplateID? @characterTemplateID,
                              NPCChatDialogID? @chatDialog, Int32 @exp, SPValueType @hP, Int32 @iD, Byte @level,
                              MapID @loadMapID, UInt16 @loadX, UInt16 @loadY, UInt16 @moveSpeed, SPValueType @mP,
                              String @name, MapID? @respawnMapID, Single @respawnX, Single @respawnY, ShopID? @shopID,
                              Int32 @statPoints, Int16 @statAgi, Int16 @statDefence, Int16 @statInt, Int16 @statMaxhit,
                              Int16 @statMaxhp, Int16 @statMaxmp, Int16 @statMinhit, Int16 @statStr)
 {
     AIID = @aIID;
     BodyID = @bodyID;
     Cash = @cash;
     CharacterTemplateID = @characterTemplateID;
     ChatDialog = @chatDialog;
     Exp = @exp;
     HP = @hP;
     ID = @iD;
     Level = @level;
     LoadMapID = @loadMapID;
     LoadX = @loadX;
     LoadY = @loadY;
     MoveSpeed = @moveSpeed;
     MP = @mP;
     Name = @name;
     RespawnMapID = @respawnMapID;
     RespawnX = @respawnX;
     RespawnY = @respawnY;
     ShopID = @shopID;
     StatPoints = @statPoints;
     StatAgi = @statAgi;
     StatDefence = @statDefence;
     StatInt = @statInt;
     StatMaxhit = @statMaxhit;
     StatMaxhp = @statMaxhp;
     StatMaxmp = @statMaxmp;
     StatMinhit = @statMinhit;
     StatStr = @statStr;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WorldStatsUserConsumeItemTable"/> class.
 /// </summary>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="itemTemplateID">The initial value for the corresponding property.</param>
 /// <param name="mapID">The initial value for the corresponding property.</param>
 /// <param name="userID">The initial value for the corresponding property.</param>
 /// <param name="when">The initial value for the corresponding property.</param>
 /// <param name="x">The initial value for the corresponding property.</param>
 /// <param name="y">The initial value for the corresponding property.</param>
 public WorldStatsUserConsumeItemTable(UInt32 @iD, ItemTemplateID @itemTemplateID, MapID? @mapID, CharacterID @userID,
                                       DateTime @when, UInt16 @x, UInt16 @y)
 {
     ID = @iD;
     ItemTemplateID = @itemTemplateID;
     MapID = @mapID;
     UserID = @userID;
     When = @when;
     X = @x;
     Y = @y;
 }
        public void Warp(MapID mapID, int x, int y)
        {
            // Check for a valid map
            if (!MapBase.MapIDExists(mapID))
            {
                UserChat("Invalid map ID `{0}`.", mapID);
                return;
            }

            var map = World.GetMap(mapID);
            if (map == null)
            {
                UserChat("No map with ID `{0}` exists.", mapID);
                return;
            }

            var pos = new Vector2(x, y);

            if (pos.X < 0 || pos.Y < 0 || pos.X > map.Width || pos.Y > map.Height)
            {
                UserChat("The specified coordinates are out of the map's range. Map size: {0}", map.Size);
                return;
            }

            // Move the user
            User.Teleport(map, pos);
        }
Beispiel #51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Map"/> class.
 /// </summary>
 /// <param name="mapID">ID of the Map.</param>
 /// <param name="world">World that the Map will be inside of.</param>
 /// <exception cref="ArgumentException"><paramref name="mapID"/> returned false for <see cref="MapBase.MapIDExists"/>.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="world"/> is null.</exception>
 public Map(MapID mapID, World world) : base(mapID, world)
 {
     _world = world;
     if (log.IsInfoEnabled)
         log.InfoFormat("Created Map `{0}`.", this);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="WorldStatsUserLevelTable"/> class.
 /// </summary>
 /// <param name="characterID">The initial value for the corresponding property.</param>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="level">The initial value for the corresponding property.</param>
 /// <param name="mapID">The initial value for the corresponding property.</param>
 /// <param name="when">The initial value for the corresponding property.</param>
 /// <param name="x">The initial value for the corresponding property.</param>
 /// <param name="y">The initial value for the corresponding property.</param>
 public WorldStatsUserLevelTable(CharacterID @characterID, UInt32 @iD, Byte @level, MapID? @mapID, DateTime @when,
                                 UInt16 @x, UInt16 @y)
 {
     CharacterID = @characterID;
     ID = @iD;
     Level = @level;
     MapID = @mapID;
     When = @when;
     X = @x;
     Y = @y;
 }
Beispiel #53
0
        static void DeleteMiniMap(MapID mapId)
        {
            try
            {
                // Delete file
                string filePathDev = MapBase.GetMiniMapFilePath(ContentPaths.Dev, mapId);
                if (File.Exists(filePathDev))
                    File.Delete(filePathDev);

                try
                {
                    string filePathBuild = MapBase.GetMiniMapFilePath(ContentPaths.Build, mapId);
                    if (File.Exists(filePathBuild))
                        File.Delete(filePathBuild);
                }
                catch
                {
                }
            }
            catch (Exception ex)
            {
                const string errmsg = "Failed to delete the mini-map for mapId `{0}`. Exception: {1}";
                if (log.IsErrorEnabled)
                    log.ErrorFormat(errmsg, mapId, ex);
                Debug.Fail(string.Format(errmsg, mapId, ex));

                throw;
            }
        }
Beispiel #54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapTable"/> class.
 /// </summary>
 /// <param name="iD">The initial value for the corresponding property.</param>
 /// <param name="name">The initial value for the corresponding property.</param>
 public MapTable(MapID @iD, String @name)
 {
     ID = @iD;
     Name = @name;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventCountersMapTable"/> class.
 /// </summary>
 /// <param name="counter">The initial value for the corresponding property.</param>
 /// <param name="mapEventCounterId">The initial value for the corresponding property.</param>
 /// <param name="mapID">The initial value for the corresponding property.</param>
 public EventCountersMapTable(Int64 @counter, Byte @mapEventCounterId, MapID @mapID)
 {
     Counter = @counter;
     MapEventCounterId = @mapEventCounterId;
     MapID = @mapID;
 }
Beispiel #56
0
 public static void SetMap(PacketWriter pw, MapID mapID)
 {
     pw.Write(ServerPacketID.SetMap);
     pw.Write(mapID);
 }
Beispiel #57
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EditorMap"/> class.
 /// </summary>
 /// <param name="mapID">The ID of the map.</param>
 /// <param name="camera">The camera used to view the map.</param>
 /// <param name="getTime">The object used to get the current time.</param>
 public EditorMap(MapID mapID, ICamera2D camera, IGetTime getTime) : base(mapID, camera, getTime)
 {
 }
Beispiel #58
0
 public static PacketWriter SetMap(MapID mapID)
 {
     var pw = GetWriter();
     SetMap(pw, mapID);
     return pw;
 }
Beispiel #59
0
 public static void Write(this BitStream bitStream, MapID mapID)
 {
     bitStream.Write(null, mapID);
 }
Beispiel #60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapSpawnValues"/> class.
 /// </summary>
 /// <param name="dbController">The IDbController used to synchronize changes to the values.</param>
 /// <param name="mapID">The index of the Map that these values are for.</param>
 /// <param name="characterTemplateID">The CharacterTemplateID of the CharacterTemplate to spawn.</param>
 public MapSpawnValues(IDbController dbController, MapID mapID, CharacterTemplateID characterTemplateID)
     : this(dbController, GetFreeID(dbController), mapID, characterTemplateID, 1, new MapSpawnRect(null, null, null, null))
 {
     DbController.GetQuery<InsertMapSpawnQuery>().Execute(this);
 }