Ejemplo n.º 1
0
        /// <summary>
        /// Converts a BoxSpawn to an actual spawner object. This function is used to generate
        /// spawn groups created in Pandora's Box
        /// </summary>
        /// <param name="spawn">The BoxSpawn object describing the spawn that should be created</param>
        /// <returns>A Spawner object - null if not valid</returns>
        public static Item CreateBoxSpawn(BoxSpawn spawn)
        {
            if (spawn == null || spawn.Entries.Count == 0)
            {
                return(null);
            }

            XmlSpawner spawner = new XmlSpawner();

            spawner.Amount    = spawn.Count;
            spawner.MaxCount  = spawn.Count;
            spawner.MinDelay  = TimeSpan.FromSeconds(spawn.MinDelay);
            spawner.MaxDelay  = TimeSpan.FromSeconds(spawn.MaxDelay);
            spawner.Team      = spawn.Team;
            spawner.HomeRange = spawn.HomeRange;

            spawner.Running = false;

            spawner.Group = spawn.Group;

            XmlSpawner.SpawnObject[] spawnObjects = new Server.Mobiles.XmlSpawner.SpawnObject[spawn.Entries.Count];

            for (int i = 0; i < spawnObjects.Length; i++)
            {
                BoxSpawnEntry entry = spawn.Entries[i] as BoxSpawnEntry;

                spawnObjects[i] = new Server.Mobiles.XmlSpawner.SpawnObject(entry.Type, entry.MaxCount);
            }

            spawner.SpawnObjects = spawnObjects;

            return(spawner);
        }
Ejemplo n.º 2
0
        private void dGrid_DragDrop(object sender, DragEventArgs e)
        {
            var type = e.Data.GetData(DataFormats.Text).ToString();

            var entry = new BoxSpawnEntry();

            entry.Type = type;

            Spawn.Entries.Add(entry);

            dGrid.DataSource = null;
            dGrid.DataSource = Spawn.Entries;
            dGrid.Refresh();
        }
Ejemplo n.º 3
0
        private void bAddType_Click(object sender, EventArgs e)
        {
            if (txType.Text.Length > 0)
            {
                var type   = txType.Text;
                var exists = false;

                foreach (var entry in Spawn.Entries)
                {
                    if (entry.Type.ToLower() == type.ToLower())
                    {
                        exists = true;
                        return;
                    }
                }

                if (exists)
                {
                    MessageBox.Show(Pandora.Localization.TextProvider["Spawns.Exists"]);
                }
                else
                {
                    // Actually add
                    var entry = new BoxSpawnEntry();
                    entry.Type = type;

                    Spawn.Entries.Add(entry);

                    dGrid.DataSource = null;
                    dGrid.DataSource = Spawn.Entries;
                    dGrid.Refresh();
                }

                txType.Text = "";
            }
        }