Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Sets the spawn area for this <see cref="MapSpawnValues"/>.
        /// </summary>
        /// <param name="map">Instance of the Map with the <see cref="MapID"/> equal to the <see cref="MapID"/> handled by this
        /// <see cref="MapSpawnValues"/>. This is to ensure that the <paramref name="newSpawnArea"/> given is in a
        /// valid map range.</param>
        /// <param name="newSpawnArea">New MapSpawnRect values.</param>
        /// <exception cref="ArgumentOutOfRangeException">The <paramref name="newSpawnArea"/> contains one or more
        /// values that are not in range of the <paramref name="map"/>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="map"/>'s <see cref="MapID"/> does not match this
        /// MapSpawnValues's <see cref="MapID"/>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="map"/> is null.</exception>
        public void SetSpawnArea(MapBase map, MapSpawnRect newSpawnArea)
        {
            if (map == null)
            {
                throw new ArgumentNullException("map");
            }

            if (map.ID != MapID)
            {
                throw new ArgumentException("The ID of the specified map does not match this MapID", "map");
            }

            if (newSpawnArea == SpawnArea)
            {
                return;
            }

            var x = newSpawnArea.X.HasValue ? newSpawnArea.X.Value : (ushort)0;
            var y = newSpawnArea.Y.HasValue ? newSpawnArea.Y.Value : (ushort)0;

            const string errmsg = "One or more of the `newSpawnArea` parameter values are out of range of the map!";

            if (x < 0)
            {
                throw new ArgumentOutOfRangeException("newSpawnArea", errmsg);
            }

            if (y < 0)
            {
                throw new ArgumentOutOfRangeException("newSpawnArea", errmsg);
            }

            if (newSpawnArea.Width.HasValue && (x + newSpawnArea.Width.Value) > map.Width)
            {
                throw new ArgumentOutOfRangeException("newSpawnArea", errmsg);
            }

            if (newSpawnArea.Height.HasValue && (y + newSpawnArea.Height.Value) > map.Height)
            {
                throw new ArgumentOutOfRangeException("newSpawnArea", errmsg);
            }

            SpawnArea = newSpawnArea;
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 public bool Equals(MapSpawnRect other)
 {
     return other.X.Equals(X) && other.Y.Equals(Y) && other.Width.Equals(Width) && other.Height.Equals(Height);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Sets the spawn area for this <see cref="MapSpawnValues"/>.
        /// </summary>
        /// <param name="map">Instance of the Map with the <see cref="MapID"/> equal to the <see cref="MapID"/> handled by this
        /// <see cref="MapSpawnValues"/>. This is to ensure that the <paramref name="newSpawnArea"/> given is in a
        /// valid map range.</param>
        /// <param name="newSpawnArea">New MapSpawnRect values.</param>
        /// <exception cref="ArgumentOutOfRangeException">The <paramref name="newSpawnArea"/> contains one or more
        /// values that are not in range of the <paramref name="map"/>.</exception>
        /// <exception cref="ArgumentException">The <paramref name="map"/>'s <see cref="MapID"/> does not match this
        /// MapSpawnValues's <see cref="MapID"/>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="map"/> is null.</exception>
        public void SetSpawnArea(MapBase map, MapSpawnRect newSpawnArea)
        {
            if (map == null)
                throw new ArgumentNullException("map");

            if (map.ID != MapID)
                throw new ArgumentException("The ID of the specified map does not match this MapID", "map");

            if (newSpawnArea == SpawnArea)
                return;

            var x = newSpawnArea.X.HasValue ? newSpawnArea.X.Value : (ushort)0;
            var y = newSpawnArea.Y.HasValue ? newSpawnArea.Y.Value : (ushort)0;

            const string errmsg = "One or more of the `newSpawnArea` parameter values are out of range of the map!";

            if (x < 0)
                throw new ArgumentOutOfRangeException("newSpawnArea", errmsg);

            if (y < 0)
                throw new ArgumentOutOfRangeException("newSpawnArea", errmsg);

            if (newSpawnArea.Width.HasValue && (x + newSpawnArea.Width.Value) > map.Width)
                throw new ArgumentOutOfRangeException("newSpawnArea", errmsg);

            if (newSpawnArea.Height.HasValue && (y + newSpawnArea.Height.Value) > map.Height)
                throw new ArgumentOutOfRangeException("newSpawnArea", errmsg);

            SpawnArea = newSpawnArea;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 public bool Equals(MapSpawnRect other)
 {
     return(other.X.Equals(X) && other.Y.Equals(Y) && other.Width.Equals(Width) && other.Height.Equals(Height));
 }