Ejemplo n.º 1
0
        public static void DrawSpawn(MapSpawnValues spawn, ISpriteBatch spriteBatch, IDrawableMap map, Font font)
        {
            var spawnArea = spawn.SpawnArea;

            // Only draw if it does not cover the whole map
            if (!spawnArea.X.HasValue && !spawnArea.Y.HasValue && !spawnArea.Width.HasValue && !spawnArea.Height.HasValue)
                return;

            // Draw spawn area
            Vector2 cameraOffset = map.Camera.Min;
            Rectangle rect = spawnArea.ToRectangle(map);
            rect.X -= (int)cameraOffset.X;
            rect.Y -= (int)cameraOffset.Y;
            RenderRectangle.Draw(spriteBatch, rect, new Color(0, 255, 0, 75), new Color(0, 0, 0, 125), 2);

            // Draw name
            CharacterTemplate charTemp = CharacterTemplateManager.Instance[spawn.CharacterTemplateID];
            if (charTemp != null)
            {
                string text = string.Format("{0}x {1} [{2}]", spawn.SpawnAmount, charTemp.TemplateTable.Name, spawn.CharacterTemplateID);

                Vector2 textPos = new Vector2(rect.X, rect.Y);
                textPos -= new Vector2(0, font.MeasureString(text).Y);
                textPos = textPos.Round();

                spriteBatch.DrawStringShaded(font, text, textPos, Color.White, Color.Black);
            }
        }
Ejemplo n.º 2
0
        public void AddNewItem()
        {
            if (Map == null)
            {
                MessageBox.Show("The map must be set before a new spawn can be created!");
                return;
            }

            var charID = CharacterTemplateManager.Instance.First().TemplateTable.ID;
            var newSpawn = new MapSpawnValues(DbControllerBase.GetInstance(), Map.ID, charID);

            this.AddItemAndReselect(newSpawn);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads the NPCSpawners for a Map.
        /// </summary>
        /// <param name="map">Map to load the spawners for.</param>
        /// <returns>IEnumerable of the <see cref="NPCSpawner"/>s that were loaded.</returns>
        public static IEnumerable <NPCSpawner> LoadSpawners(Map map)
        {
            var queryValues = MapSpawnValues.Load(map.DbController, map.ID);
            var ret         = new List <NPCSpawner>();

            foreach (var queryValue in queryValues)
            {
                var spawner = new NPCSpawner(queryValue, map);
                ret.Add(spawner);
            }

            return(ret);
        }
Ejemplo n.º 4
0
        public bool DeleteItem(MapSpawnValues item)
        {
            if (item == null)
                return false;

            if (!Items.Contains(item))
                return false;

            var q = DbControllerBase.GetInstance().GetQuery<DeleteMapSpawnQuery>();
            q.Execute(item.ID);

            ReloadSpawns();

            return true;
        }
Ejemplo n.º 5
0
 static string GetDrawString(MapSpawnValues x)
 {
     return string.Format("Char ID: {0}  Count: {1}  Region: {2}", x.CharacterTemplateID, x.SpawnAmount, x.SpawnArea);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EditorMapSpawnValues"/> class.
 /// </summary>
 /// <param name="msv">The <see cref="MapSpawnValues"/>.</param>
 /// <param name="map">The map.</param>
 public EditorMapSpawnValues(MapSpawnValues msv, MapBase map)
 {
     _msv = msv;
     _map = map;
 }