コード例 #1
0
        public ESpawnerGump(ESpawner ESpawner)
            : base(50, 50)
        {
            m_EclSpawner = ESpawner;

            this.Closable = true;
            this.Disposable = true;
            this.Dragable = true;
            this.Resizable = false;
            this.AddPage(0);
            this.AddBackground(50, 0, 332, 450, 2620);
            this.AddBackground(50, 451, 332, 143, 2620);
            this.AddAlphaRegion(55, 6, 322, 437);
            this.AddLabel(155, 459, 955, string.Format("{0} V{1}", m_EclSpawner.Name, m_EclSpawner.Version.ToString()));
            this.AddButton(340, 559, 4017, 4018, (int)Buttons.Close, GumpButtonType.Reply, 0);
            this.AddLabel(75, 484, 955, @"Bring All Home");
            this.AddButton(170, 484, 4023, 4024, (int)Buttons.BringAllHome, GumpButtonType.Reply, 0);
            this.AddButton(170, 509, 4023, 4024, (int)Buttons.TotalRespawn, GumpButtonType.Reply, 0);
            this.AddLabel(76, 509, 955, @"Total Respawn");
            this.AddLabel(227, 484, 955, @"Clear Objects");
            this.AddButton(322, 484, 4023, 4024, (int)Buttons.ClearObjects, GumpButtonType.Reply, 0);
            this.AddLabel(75, 559, 955, @"Clear Spawner");
            this.AddButton(170, 559, 4023, 4024, (int)Buttons.ClearSpawner, GumpButtonType.Reply, 0);

            AddSpawnerList(55, 0);

            this.AddImage(350, 332, 10410);
            this.AddImage(0, 499, 10402);
        }
コード例 #2
0
        private static string CreateSpawnString(ESpawner spawner)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            for (int i = 0; i < spawner.SpawnEntries.Count; i++)
            {
                EclSpawnEntry entry = (EclSpawnEntry)spawner.SpawnEntries[i];

                if (sb.Length > 0)
                    sb.Append(':');

                sb.AppendFormat("{0}={1}", entry.SpawnObjectName, entry.Amount);
            }
            return sb.ToString();
        }
コード例 #3
0
        public static void LoadSpawns(Mobile from, string fileName)
        {
            from.SendMessage(m_iNormalHue, "Loading spawners to the world... from the {0} file.", fileName);

            if (System.IO.File.Exists(fileName) == true)
            {
                FileStream fs = null;
                try { fs = File.Open(fileName, FileMode.Open); }
                catch { from.SendMessage(m_iErrorHue, "Error opening xml file."); return; }

                int TotalCount = 0;

                DataSet ds = new DataSet(SpawnDataSetName);

                try { ds.ReadXml(fs); }
                catch { from.SendMessage(m_iErrorHue, "Error reading xml file."); return; }

                if (ds.Tables != null && ds.Tables.Count > 0)
                {
                    if (ds.Tables[SpawnTablePointName] != null && ds.Tables[SpawnTablePointName].Rows.Count > 0)
                        foreach (DataRow dr in ds.Tables[SpawnTablePointName].Rows)
                        {
                            int iX = 0;
                            int iY = 0;
                            int iZ = 0;
                            Map SpawnMap = null;
                            int iMaxAmount = 0;
                            int iHomeRange = 0;
                            bool iRunning = false;
                            int iTeam = 0;
                            bool bGroup = false;
                            TimeSpan SpawnMinDelay = TimeSpan.FromMinutes(5);
                            TimeSpan SpawnMaxDelay = TimeSpan.FromMinutes(10);
                            int iContSerial = 0;
                            AccessLevel visibilityLevel = 0;
                            string sSpawn = "";
                            bool bIgnoreWorldSpawn;
                            bool bTryFlip = false;
                            int iWayPoint = 0;

                            try
                            {
                                iX = int.Parse((string)dr["X"]);
                                iY = int.Parse((string)dr["Y"]);
                                iZ = int.Parse((string)dr["Z"]);
                                SpawnMap = Map.Parse((string)dr["Map"]);
                                iMaxAmount = int.Parse((string)dr["MaxAmount"]);
                                iHomeRange = int.Parse((string)dr["HomeRange"]);
                                iRunning = bool.Parse((string)dr["Running"]);
                                iTeam = int.Parse((string)dr["Team"]);
                                bGroup = bool.Parse((string)dr["Group"]);
                                SpawnMinDelay = TimeSpan.FromSeconds(int.Parse((string)dr["MinDelay"]));
                                SpawnMaxDelay = TimeSpan.FromSeconds(int.Parse((string)dr["MaxDelay"]));
                                iContSerial = int.Parse((string)dr["ContSerial"]);
                                visibilityLevel = (AccessLevel)int.Parse((string)dr["VisibilityLevel"]);
                                sSpawn = (string)dr["Spawn"];
                                bIgnoreWorldSpawn = bool.Parse((string)dr["IgnoreWorldSpawn"]);
                                bTryFlip = bool.Parse((string)dr["TryFlip"]);
                                iWayPoint = int.Parse((string)dr["WayPoint"]);
                            }
                            catch { from.SendMessage(m_iErrorHue, "Error trying to load."); return; }

                            TotalCount++;

                            List<EclSpawnEntry> alSpawn = new List<EclSpawnEntry>();

                            if (sSpawn != null && sSpawn.Length > 0)
                            {
                                string[] SpawnsSpawn = sSpawn.Split(':');

                                for (int i = 0; i < SpawnsSpawn.Length; i++)
                                {
                                    string[] SpawnObjectDetails = SpawnsSpawn[i].Split('=');

                                    alSpawn.Add(new EclSpawnEntry(SpawnObjectDetails[0], new ArrayList(), int.Parse(SpawnObjectDetails[1])));
                                }
                            }

                            ESpawner spawner = new ESpawner(iMaxAmount, SpawnMinDelay, SpawnMaxDelay, iTeam, bGroup, iHomeRange, alSpawn, iMaxAmount > 0 ? true : false, visibilityLevel);
                            spawner.TryFlip = bTryFlip;
                            spawner.IgnoreWorldSpawn = bIgnoreWorldSpawn;

                            if (iWayPoint != 0)
                            {
                                bool bFound = false;
                                foreach (Item i in World.Items.Values)
                                {
                                    if (i is WayPoint && ((WayPoint)i).Serial.Value == iWayPoint)
                                    {
                                        spawner.WayPoint = (WayPoint)i;
                                        spawner.MoveToWorld(new Point3D(iX, iY, iZ), SpawnMap);
                                        bFound = true;
                                    }
                                }
                                if (!bFound) // Error... waypoint not found
                                {
                                    spawner.Delete();
                                    from.SendMessage(m_iErrorHue, "Could not find the WayPoint for the spawner... Spawner deleted.");
                                    continue;
                                }
                            }
                            else
                                spawner.MoveToWorld(new Point3D(iX, iY, iZ), SpawnMap);

                            if (iContSerial != 0)
                            {
                                bool bFound = false;
                                foreach (Item i in World.Items.Values)
                                {
                                    if (i is Container && ((Container)i).Serial.Value == iContSerial)
                                    {
                                        ((Container)i).DropItem(spawner);
                                        bFound = true;
                                    }
                                }
                                if (!bFound) // Error... container not found
                                {
                                    spawner.Delete();
                                    from.SendMessage(m_iErrorHue, "Could not find the parent container for the spawner... Spawner deleted.");
                                    continue;
                                }
                            }
                            else
                                spawner.MoveToWorld(new Point3D(iX, iY, iZ), SpawnMap);
                        }
                }
                fs.Close();
                from.SendMessage(m_iNormalHue, string.Format("Done... Loaded {0} spawners from {1}", TotalCount, fileName));
            }
            else
                from.SendMessage(m_iErrorHue, "Could not find file {0}.", fileName);
        }
コード例 #4
0
            public ESpawnerTimer(ESpawner spawner, TimeSpan delay)
                : base(delay)
            {
                if (spawner.IsFull(false))
                    Priority = TimerPriority.FiveSeconds;
                else
                    Priority = TimerPriority.OneSecond;

                m_Spawner = spawner;
            }