示例#1
0
		public TownCrierEntry AddEntry( string[] lines, TimeSpan duration )
		{
			if ( m_Entries == null )
				m_Entries = new List<TownCrierEntry>();

			TownCrierEntry tce = new TownCrierEntry( lines, duration );

			m_Entries.Add( tce );

			List<TownCrier> instances = TownCrier.Instances;

			for ( int i = 0; i < instances.Count; ++i )
				instances[i].ForceBeginAutoShout();

			return tce;
		}
示例#2
0
        private void ShoutNews_Callback(object state)
        {
            object[]       states = (object[])state;
            TownCrierEntry tce    = (TownCrierEntry)states[0];
            int            index  = (int)states[1];

            if (index < 0 || index >= tce.Lines.Length)
            {
                if (m_NewsTimer != null)
                {
                    m_NewsTimer.Stop();
                }

                m_NewsTimer = null;
            }
            else
            {
                PublicOverheadMessage(MessageType.Regular, 0x3B2, false, tce.Lines[index]);
                states[1] = index + 1;
            }
        }
示例#3
0
        private void AutoShout_Callback()
        {
            TownCrierEntry tce = GetRandomEntry();

            if (tce == null)
            {
                if (m_AutoShoutTimer != null)
                {
                    m_AutoShoutTimer.Stop();
                }

                m_AutoShoutTimer = null;
            }
            else if (m_NewsTimer == null)
            {
                m_NewsTimer = Timer.DelayCall(
                    TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(3.0), ShoutNews_Callback, new NewsInfo(tce));

                PublicOverheadMessage(MessageType.Regular, 0x3B2, 502976);                 // Hear ye! Hear ye!
            }
        }
示例#4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                m_From.SendMessage("Enter the duration for the new message. Format: <hours:minutes:seconds>");
                m_From.Prompt = new TownCrierDurationPrompt(m_Owner);
            }
            else if (info.ButtonID > 1)
            {
                ArrayList entries = new ArrayList();
                if (m_Owner.Entries != null)
                {
                    foreach (TownCrierEntry tce in m_Owner.Entries)
                    {
                        if (m_From.AccessLevel >= AccessLevel.GameMaster ||
                            m_From.Serial == tce.Poster)
                        {
                            entries.Add(tce);
                        }
                    }
                }

                int index = info.ButtonID - 2;

                if (entries != null && index < entries.Count)
                {
                    TownCrierEntry tce = (TownCrierEntry)entries[index];
                    TimeSpan       ts  = tce.ExpireTime - DateTime.Now;

                    if (ts < TimeSpan.Zero)
                    {
                        ts = TimeSpan.Zero;
                    }

                    m_From.SendMessage("Editing entry #{0}.", index + 1);
                    m_From.SendMessage("Enter the first line to shout:");
                    m_From.Prompt = new TownCrierLinesPrompt(m_Owner, tce, new ArrayList(), ts);
                }
            }
        }
示例#5
0
        private void AutoShout_Callback()
        {
            TownCrierEntry tce = GetRandomEntry();

            if (Utility.RandomDouble() > 0.5 || tce == null)              //only spout off about macroers 1/2 the time
            {
                ListEntry le = TCCS.GetRandomEntry();
                if (le != null)
                {
                    tce = new TownCrierEntry(le.Lines, TimeSpan.FromMinutes(1), Serial.MinusOne);
                }
            }

            if (tce == null)
            {
                if (m_AutoShoutTimer != null)
                {
                    m_AutoShoutTimer.Stop();
                }

                m_AutoShoutTimer = null;
            }
            else if (m_NewsTimer == null)
            {
                m_NewsTimer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(3.0), new TimerStateCallback(ShoutNews_Callback), new object[] { tce, 0 });

                // pla: 12/08/06
                // changed to show a different mesasge in a yellow hue for player messages
                Mobile m = World.FindMobile(tce.Poster);
                if (m != null && m.AccessLevel == AccessLevel.Player)
                {
                    PublicOverheadMessage(MessageType.Regular, 0x36, true, Utility.RandomBool() == true ? "A good citizen proclaims!" : "On behalf of a good citizen!");
                }
                else
                {
                    PublicOverheadMessage(MessageType.Regular, 0x3B2, 502976);                   // Hear ye! Hear ye!
                }
            }
        }
示例#6
0
        private void AutoShout_Callback()
        {
            TownCrierEntry tce = GetRandomEntry();

            if (tce == null)
            {
                if (m_AutoShoutTimer != null)
                {
                    m_AutoShoutTimer.Stop();
                }

                m_AutoShoutTimer = null;
            }
            else if (m_NewsTimer == null)
            {
                m_NewsTimer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(3.0), new TimerStateCallback(ShoutNews_Callback), new object[] { tce, 0 });

                //PublicOverheadMessage( MessageType.Regular, 0x3B2, 502976 ); // Hear ye! Hear ye!
                int OldHue = SpeechHue;
                SpeechHue = 0;
                Say(true, "Hear ye! Hear ye!");
                SpeechHue = OldHue;
            }
        }
示例#7
0
        public TownCrierEntry GetRandomEntry()
        {
            if (m_Entries == null || m_Entries.Count == 0)
            {
                return(GlobalTownCrierEntryList.Instance.GetRandomEntry());
            }

            for (int i = m_Entries.Count - 1; m_Entries != null && i >= 0; --i)
            {
                if (i >= m_Entries.Count)
                {
                    continue;
                }

                TownCrierEntry tce = (TownCrierEntry)m_Entries[i];

                if (tce.Expired)
                {
                    RemoveEntry(tce);
                }
            }

            if (m_Entries == null || m_Entries.Count == 0)
            {
                return(GlobalTownCrierEntryList.Instance.GetRandomEntry());
            }

            TownCrierEntry entry = GlobalTownCrierEntryList.Instance.GetRandomEntry();

            if (entry == null || Utility.RandomBool())
            {
                entry = (TownCrierEntry)m_Entries[Utility.Random(m_Entries.Count)];
            }

            return(entry);
        }
示例#8
0
        public void AddTCEntry(string[] lines, int duration)
        {
            if (lines[0].Length > 0)
            {
                // first, clear any existing message and timers
                RemoveTCEntry();

                // Setup the Town Crier
                m_TownCrierMessage = new TownCrierEntry(lines, TimeSpan.FromMinutes(duration), Serial.MinusOne);
                GlobalTownCrierEntryList.Instance.AddEntry(m_TownCrierMessage);

                // Setup our timer
                LogicError(m_Timer != null, "m_Timer != null");
                if (m_Timer != null)
                {
                    m_Timer.Stop();
                    m_Timer = null;
                }

                m_MsgTime = DateTime.Now + TimeSpan.FromMinutes(duration);
                m_Timer   = new MsgTimer(this, m_MsgTime);
                m_Timer.Start();
            }
        }
示例#9
0
        public void RemoveEntry(TownCrierEntry tce)
        {
            if (m_Entries == null)
            {
                return;
            }

            m_Entries.Remove(tce);

            if (m_Entries.Count == 0)
            {
                m_Entries = null;
            }

            if (m_Entries == null && GlobalTownCrierEntryList.Instance.IsEmpty)
            {
                if (m_AutoShoutTimer != null)
                {
                    m_AutoShoutTimer.Stop();
                }

                m_AutoShoutTimer = null;
            }
        }
        public override void OnSpeech(SpeechEventArgs e)
        {
            Mobile    from = e.Mobile;
            Container bank = from.FindBankNoCreate();

            object command = RoomAttendantCommands.None;

            if (e.Speech.Length > "vendor ".Length && e.Speech.Substring(0, "vendor ".Length).ToLower() == "vendor ")
            {
                command = s_Keywords[e.Speech.Substring("vendor ".Length)];
            }
            else if (e.Speech.Length > Name.Length + 1 && e.Speech.Substring(0, Name.Length + 1).ToLower() == Name.ToLower() + ' ')
            {
                command = s_Keywords[e.Speech.Substring(Name.Length + 1)];
            }
            else if (e.Speech.Length > "attendant ".Length && e.Speech.Substring(0, "attendant ".Length).ToLower() == "attendant ")
            {
                command = s_Keywords[e.Speech.Substring("attendant ".Length)];
            }

            switch ((command == null ? (int)RoomAttendantCommands.None : (int)command))
            {
            case (int)RoomAttendantCommands.Room:
            {
                if ((from.Backpack == null || from.Backpack.GetAmount(typeof(Gold)) < 30) && (bank == null || Banker.Withdraw(from, 30))) //bank.GetAmount( typeof( Gold ) ) < 30 ) )
                {
                    SayTo(from, "Thou dost not have enough gold, not even in thy bank account.");                                         // Thou dost not have enough gold, not even in thy bank account.
                }
                else
                {
                    SayTo(from, "I need thirty gold for the carrier pigeon rental.");

                    from.Target = new RoomTarget(this);
                }
                break;
            }

            case (int)RoomAttendantCommands.Help:
            {
                SayTo(from, "For a fee I can rent a carrier pigeon for you to call your squire with from their room.");
                break;
            }

            default:
            {
                base.OnSpeech(e);

                if (!e.Handled && InRange(e.Mobile, 3))
                {
                    if (m_NewsTimer == null && e.HasKeyword(0x30))                                 // *news*
                    {
                        TownCrierEntry tce = GlobalTownCrierEntryList.Instance.GetRandomEntry();

                        if (tce == null)
                        {
                            PublicOverheadMessage(MessageType.Regular, 0x3B2, 1005643);                                       // I have no news at this time.
                        }
                        else
                        {
                            m_NewsTimer = Timer.DelayCall(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(3.0), new TimerStateCallback(ShoutNews_Callback), new object[] { tce, 0 });

                            PublicOverheadMessage(MessageType.Regular, 0x3B2, 502978);                                       // Some of the latest news!
                        }
                    }

                    for (int i = 0; i < m_Rumors.Length; ++i)
                    {
                        RoomAttendantRumor rumor = m_Rumors[i];

                        if (rumor == null)
                        {
                            continue;
                        }

                        string keyword = rumor.Keyword;

                        if (keyword == null || (keyword = keyword.Trim()).Length == 0)
                        {
                            continue;
                        }

                        if (Insensitive.Equals(keyword, e.Speech))
                        {
                            string message = rumor.Message;

                            if (message == null || (message = message.Trim()).Length == 0)
                            {
                                continue;
                            }

                            PublicOverheadMessage(MessageType.Regular, 0x3B2, false, message);
                        }
                    }
                }

                break;
            }
            }
        }
示例#11
0
        public TownCrierGump(Mobile from, ITownCrierEntryList owner)
            : base(50, 50)
        {
            m_From  = from;
            m_Owner = owner;

            from.CloseGump(typeof(TownCrierGump));

            AddPage(0);

            List <TownCrierEntry> entries = owner.Entries;

            owner.GetRandomEntry(); // force expiration checks

            int count = 0;

            if (entries != null)
            {
                count = entries.Count;
            }

            AddImageTiled(0, 0, 300, 38 + (count == 0 ? 20 : (count * 85)), 0xA40);
            AddAlphaRegion(1, 1, 298, 36 + (count == 0 ? 20 : (count * 85)));

            if (owner is GlobalTownCrierEntryList)
            {
                AddHtml(8, 8, 300 - 8 - 30, 20, "<basefont color=#FFFFFF><center>GLOBAL TOWN CRIER MESSAGES</center></basefont>", false, false);
            }
            else
            {
                AddHtml(8, 8, 300 - 8 - 30, 20, "<basefont color=#FFFFFF><center>TOWN CRIER MESSAGES</center></basefont>", false, false);
            }

            AddButton(300 - 8 - 30, 8, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0);
            AddTooltip(3000161); // New Message

            if (entries == null || count == 0)
            {
                AddHtml(8, 30, 284, 20, "<basefont color=#FFFFFF>The crier has no news.</basefont>", false, false);
            }
            else
            {
                for (int i = 0; i < entries.Count; ++i)
                {
                    TownCrierEntry tce = entries[i];

                    TimeSpan toExpire = tce.ExpireTime - DateTime.UtcNow;

                    if (toExpire < TimeSpan.Zero)
                    {
                        toExpire = TimeSpan.Zero;
                    }

                    StringBuilder sb = new StringBuilder();

                    sb.Append("[Expires: ");

                    if (toExpire.TotalHours >= 1)
                    {
                        sb.Append((int)toExpire.TotalHours);
                        sb.Append(':');
                        sb.Append(toExpire.Minutes.ToString("D2"));
                    }
                    else
                    {
                        sb.Append(toExpire.Minutes);
                    }

                    sb.Append(':');
                    sb.Append(toExpire.Seconds.ToString("D2"));

                    sb.Append("] ");

                    for (int j = 0; j < tce.Lines.Length; ++j)
                    {
                        if (j > 0)
                        {
                            sb.Append("<br>");
                        }

                        sb.Append(tce.Lines[j]);
                    }

                    AddHtml(8, 35 + (i * 85), 254, 80, sb.ToString(), true, true);

                    AddButton(300 - 8 - 26, 35 + (i * 85), 0x15E1, 0x15E5, 2 + i, GumpButtonType.Reply, 0);
                    AddTooltip(3005101); // Edit
                }
            }
        }
示例#12
0
		public virtual void Refresh()
		{
			m_DecayMinutesStored = HouseDecayDelay.TotalMinutes;

			if (m_DecayMinutesStored > ONE_DAY_IN_MINUTES && m_IDOC_Broadcast_TCE != null)
			{
				GlobalTownCrierEntryList.Instance.RemoveEntry(m_IDOC_Broadcast_TCE);
				m_IDOC_Broadcast_TCE = null;
			}
		}
示例#13
0
		public TownCrierEntry AddEntry( string[] lines, TimeSpan duration )
		{
			if ( m_Entries == null )
				m_Entries = new List<TownCrierEntry>();

			TownCrierEntry tce = new TownCrierEntry( lines, duration );

			m_Entries.Add( tce );

			if ( m_AutoShoutTimer == null )
				m_AutoShoutTimer = Timer.DelayCall( TimeSpan.FromSeconds( 5.0 ), TimeSpan.FromMinutes( 1.0 ), new TimerCallback( AutoShout_Callback ) );

			return tce;
		}
示例#14
0
		public virtual void RefreshHouseOneDay()
		{
			if (TownshipRestrictedRefresh)
			{
				return;
			}

			if (m_DecayMinutesStored <= MaxHouseDecayTime.TotalMinutes)
			{
				if (m_DecayMinutesStored >= (MaxHouseDecayTime.TotalMinutes - ONE_DAY_IN_MINUTES))
				{
					m_DecayMinutesStored = MaxHouseDecayTime.TotalMinutes;
				}
				else
				{
					m_DecayMinutesStored += ONE_DAY_IN_MINUTES;
				}
			}

			if (m_DecayMinutesStored > ONE_DAY_IN_MINUTES && m_IDOC_Broadcast_TCE != null)
			{
				GlobalTownCrierEntryList.Instance.RemoveEntry(m_IDOC_Broadcast_TCE);
				m_IDOC_Broadcast_TCE = null;
			}

		}
示例#15
0
 public static void AddUnpaidEntry(Mobile poster, TownCrierEntry tce)
 {
     m_UnpaidEntries[poster] = tce;
 }
示例#16
0
        public TownCrierEntry AddEntry( TownCrierEntry tce )
        {
            if ( m_Entries == null )
            {
                m_Entries = new List<TownCrierEntry>();
            }

            m_Entries.Add( tce );

            if ( m_AutoShoutTimer == null )
            {
                m_AutoShoutTimer = Timer.DelayCall( TimeSpan.FromSeconds( 5.0 ), TimeSpan.FromMinutes( 1.0 ), new TimerCallback( AutoShout_Callback ) );
            }

            return tce;
        }
示例#17
0
		public void AddEntry( TownCrierEntry tce )
		{
			if ( m_Entries == null )
				m_Entries = new ArrayList();

			m_Entries.Add( tce );

			if ( m_AutoShoutTimer == null )
				m_AutoShoutTimer = Timer.DelayCall( TimeSpan.FromSeconds( 5.0 ), TimeSpan.FromMinutes( 1.0 ), new TimerCallback( AutoShout_Callback ) );
		}
示例#18
0
		public static void AddUnpaidEntry(Mobile poster, TownCrierEntry tce)
		{
			m_UnpaidEntries[poster] = tce;
		}
示例#19
0
		public override void OnCancel( Mobile from )
		{
			if ( m_Entry != null )
			{
				try 
				{
					if (from.AccessLevel < AccessLevel.GameMaster)
					{
						from.SendMessage("A partial refund was delivered to your bank account.");
						from.BankBox.DropItem(new Gold(m_Entry.CalculateCost()));
					}
				}
				catch
				{
					from.SendMessage("An error occurred while trying to put a refund in your bank account. Contact a Game Master immediately.");
				}

				m_Owner.RemoveEntry( m_Entry );
			}

			if ( m_Lines.Count > 0 )
			{
				if (from.AccessLevel < AccessLevel.GameMaster)
				{
					TownCrierEntry tce = new TownCrierEntry((string[])m_Lines.ToArray( typeof( string ) ), m_Duration, from.Serial );
					TownCrier.AddUnpaidEntry(from, tce);
					
					from.SendMessage("This message will cost {0}gp. Drag gold or a check onto a Town Crier to pay.", tce.CalculateCost());
				}
				else
				{
					m_Owner.AddEntry( new TownCrierEntry((string[])m_Lines.ToArray(typeof(string)), m_Duration, from.Serial) );
					from.SendMessage( "Message has been set." );                   
				}
			}
			else
			{
				if ( m_Entry != null )
					from.SendMessage( "Message deleted." );
				else
					from.SendLocalizedMessage( 502980 ); // Message entry cancelled.
			}

			from.SendGump( new TownCrierGump( from, m_Owner ) );
		}
示例#20
0
		public void AddEntry( TownCrierEntry tce )
		{
			if ( m_Entries == null )
				m_Entries = new ArrayList();

			m_Entries.Add( tce );

			ArrayList instances = TownCrier.Instances;

			for ( int i = 0; i < instances.Count; ++i )
				((TownCrier)instances[i]).ForceBeginAutoShout();
		}
示例#21
0
        // plasma : Load global town crier entry list
		public static void OnLoad( ) 
		{
			System.Console.WriteLine("TCGL Loading..."); 
			
			string filePath = Path.Combine( "Saves/AngelIsland", "TCGL.xml" );

			if ( !File.Exists( filePath ) )
			{
				return;
			}

			try
			{
                if (Instance.m_Entries == null)
                    Instance.m_Entries = new ArrayList();

                XmlDocument doc = new XmlDocument();
				doc.Load( filePath );

				XmlElement root = doc["TCGL"];
				foreach ( XmlElement entry in root.GetElementsByTagName( "TCEntry" ) )
				{
					try
					{						
                        // load in entry!
						TownCrierEntry tce = new TownCrierEntry( entry );
						
						// system messages cannot be loaded in this way as the system needs to maintain a handle to the message so that
						//	it can be removed ondemand. This Load TCE system is designed for player 'paid for' messages.
						if (tce.Poster != Serial.MinusOne)
							// and add to the global TC list
							Instance.AddEntry( tce );
					}
					catch
					{
						Console.WriteLine( "Warning: A TCGL entry load failed" );
					}
				}
			}
			catch( Exception e )
			{
				LogHelper.LogException(e);
                Console.WriteLine("Exception caught loading TCGL.xml");
                Console.WriteLine(e.StackTrace);
                
			}
		}
示例#22
0
		public void AddTCEntry(string[] lines, int duration)
		{
			if (lines[0].Length > 0)
			{
				// first, clear any existing message and timers
				RemoveTCEntry();

				// Setup the Town Crier
				m_TownCrierMessage = new TownCrierEntry(lines, TimeSpan.FromMinutes(duration), Serial.MinusOne);
				GlobalTownCrierEntryList.Instance.AddEntry(m_TownCrierMessage);

				// Setup our timer
				LogicError(m_Timer != null, "m_Timer != null");
				if ( m_Timer != null )
				{
					m_Timer.Stop();
					m_Timer = null;
				}

				m_MsgTime = DateTime.Now + TimeSpan.FromMinutes( duration );
				m_Timer = new MsgTimer( this, m_MsgTime );
				m_Timer.Start();
				
			}
		}
示例#23
0
		private void RemoveTCEntry()
		{
			if (m_TownCrierMessage != null)
			{
				GlobalTownCrierEntryList.Instance.RemoveEntry(m_TownCrierMessage);
				m_TownCrierMessage = null;
			}

			if ( m_Timer != null )
			{
				m_Timer.Stop();
				m_Timer = null;
			}
		}
示例#24
0
        public TownCrierEntry AddEntry(string[] lines, TimeSpan duration)
        {
            if (m_Entries == null)
                m_Entries = new List<TownCrierEntry>();

            TownCrierEntry tce = new TownCrierEntry(lines, duration);

            m_Entries.Add(tce);

            return tce;
        }
示例#25
0
 public NewsInfo(TownCrierEntry entry)
 {
     Entry = entry;
 }
示例#26
0
		private void AutoShout_Callback()
		{
			TownCrierEntry tce = GetRandomEntry();

			if( Utility.RandomDouble() > 0.5 || tce == null ) //only spout off about macroers 1/2 the time
			{
				ListEntry le = TCCS.GetRandomEntry();
				if( le != null )
				{
					tce = new TownCrierEntry(le.Lines, TimeSpan.FromMinutes(1), Serial.MinusOne);
				}
			}

			if ( tce == null )
			{
				if ( m_AutoShoutTimer != null )
					m_AutoShoutTimer.Stop();

				m_AutoShoutTimer = null;
			}
			else if ( m_NewsTimer == null )
			{
				m_NewsTimer = Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 3.0 ), new TimerStateCallback( ShoutNews_Callback ), new object[]{ tce, 0 } );

                // pla: 12/08/06
                // changed to show a different mesasge in a yellow hue for player messages
                Mobile m = World.FindMobile(tce.Poster);
                if( m != null && m.AccessLevel == AccessLevel.Player )
                    PublicOverheadMessage(MessageType.Regular, 0x36, true, Utility.RandomBool() == true ? "A good citizen proclaims!" : "On behalf of a good citizen!" ); 
                else
				    PublicOverheadMessage( MessageType.Regular, 0x3B2, 502976 ); // Hear ye! Hear ye!
			}
		}
示例#27
0
        public TownCrierGump(Mobile from, ITownCrierEntryList owner) : base(50, 50)
        {
            m_From  = from;
            m_Owner = owner;

            from.CloseGump(typeof(TownCrierGump));

            AddPage(0);

            ArrayList entries = new ArrayList();

            if (owner.Entries != null)
            {
                foreach (TownCrierEntry tce in owner.Entries)
                {
                    if (m_From.AccessLevel >= AccessLevel.GameMaster ||
                        m_From.Serial == tce.Poster)
                    {
                        entries.Add(tce);
                    }
                }
            }

            owner.GetRandomEntry();             // force expiration checks

            int count = 0;

            if (entries != null)
            {
                count = entries.Count;
            }

            AddImageTiled(0, 0, 300, 38 + (count == 0 ? 20 : (count * 85)), 0xA40);
            AddAlphaRegion(1, 1, 298, 36 + (count == 0 ? 20 : (count * 85)));

            AddHtml(8, 8, 300 - 8 - 30, 20, "<basefont color=#FFFFFF><center>TOWN CRIER MESSAGES</center></basefont>", false, false);

            AddButton(300 - 8 - 30, 8, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0);

            if (count == 0)
            {
                AddHtml(8, 30, 284, 20, "<basefont color=#FFFFFF>The crier has no news.</basefont>", false, false);
            }
            else
            {
                for (int i = 0; i < entries.Count; ++i)
                {
                    TownCrierEntry tce = (TownCrierEntry)entries[i];

                    TimeSpan toExpire = tce.ExpireTime - DateTime.Now;

                    if (toExpire < TimeSpan.Zero)
                    {
                        toExpire = TimeSpan.Zero;
                    }

                    StringBuilder sb = new StringBuilder();

                    sb.Append("[Expires: ");

                    if (toExpire.TotalHours >= 1)
                    {
                        sb.Append((int)toExpire.TotalHours);
                        sb.Append(':');
                        sb.Append(toExpire.Minutes.ToString("D2"));
                    }
                    else
                    {
                        sb.Append(toExpire.Minutes);
                    }

                    sb.Append(':');
                    sb.Append(toExpire.Seconds.ToString("D2"));

                    sb.Append("] ");

                    for (int j = 0; j < tce.Lines.Length; ++j)
                    {
                        if (j > 0)
                        {
                            sb.Append("<br>");
                        }

                        sb.Append(tce.Lines[j]);
                    }

                    sb.Append("<br>Poster: ");
                    sb.Append(tce.Poster.ToString());

                    AddHtml(8, 35 + (i * 85), 254, 80, sb.ToString(), true, true);

                    AddButton(300 - 8 - 26, 35 + (i * 85), 0x15E1, 0x15E5, 2 + i, GumpButtonType.Reply, 0);
                }
            }
        }
示例#28
0
		public void RemoveEntry( TownCrierEntry tce )
		{
			if ( m_Entries == null )
				return;

			m_Entries.Remove( tce );

			if ( m_Entries.Count == 0 )
				m_Entries = null;
		}
		public void AddTCEntry(string[] lines, TimeSpan span)
		{
			try 
			{
				if (lines[0].Length > 0)
				{
					// first, clear any existing message and timers
					RemoveTCEntry();

					// Setup the Town Crier
					m_TownCrierMessage = new TownCrierEntry(lines, span, Serial.MinusOne);
					GlobalTownCrierEntryList.Instance.AddEntry(m_TownCrierMessage);
				}
			}
			catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
		}
示例#30
0
		private void LogDecay()
		{
			LogHelper Logger = new LogHelper("houseDecay.log", false);
			bool announced = false;
			if (this is Tent || this is SiegeTent)
			{
				//never announce tents
			}
			else if (Utility.RandomDouble() < CoreAI.IDOCBroadcastChance)
			{
				string[] lines = new string[1];
				lines[0] = String.Format("Lord British has condemned the estate of {0} near {1}.", this.Owner.Name, DescribeLocation());
				m_IDOC_Broadcast_TCE = new TownCrierEntry(lines, TimeSpan.FromMinutes(m_DecayMinutesStored), Serial.MinusOne);
				GlobalTownCrierEntryList.Instance.AddEntry(m_IDOC_Broadcast_TCE);
				announced = true;
			}

			try
			{
				// log it
				string temp = string.Format(
					"Owner:{0}, Account:{1}, Name:{2}, Serial:{3}, Location:{4}, BuiltOn:{5}, StructureDecayTime:{6}, Type:{7}, Announced:{8}",
					this.m_Owner,
					this.m_Owner.Account,
					((this.m_Sign != null) ? this.m_Sign.Name : "NO SIGN"),
					this.Serial,
					this.Location,
					this.BuiltOn,
					this.StructureDecayTime,
					this.GetType(),
					announced.ToString()
					);
				Logger.Log(LogType.Text, temp);
			}
			catch (Exception ex)
			{
				LogHelper.LogException(ex);
			}
			finally
			{
				Logger.Finish();
			}
		}
示例#31
0
		public static void SetMessage(string[] lines, int index)
		{
			int duration = 5;							// 5 minutes
			if (index < 0 || index >= m_MaxMessages)	// range check
				return;

			if (lines[0].Length > 0)
			{
				ClearMessage(index);
				m_TownCrierMessages[index] = new TownCrierEntry(lines, TimeSpan.FromMinutes(duration), Serial.MinusOne);
				GlobalTownCrierEntryList.Instance.AddEntry(m_TownCrierMessages[index]);
			}
		}
示例#32
0
			public NewsInfo( TownCrierEntry entry )
			{
				Entry = entry;
			}
示例#33
0
		public TownCrierLinesPrompt( ITownCrierEntryList owner, TownCrierEntry entry, List<String> lines, TimeSpan duration )
		{
			m_Owner = owner;
			m_Entry = entry;
			m_Lines = lines;
			m_Duration = duration;
		}
示例#34
0
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();
			int count;
			bool idocannc = false;

			m_Region = new HouseRegion(this);

			switch (version)
			{
				case 20:
					{
						m_NPCData = reader.ReadUInt32();
						goto case 19;
					}
				case 19:
					{
						m_RestartDecay = reader.ReadTimeSpan();
						goto case 18;
					}
				case 18:
					{
						m_Flags = (ImplFlags)reader.ReadUInt32();
						goto case 17;
					}
				case 17:
					{
						m_UpgradeCosts = reader.ReadUInt32();
						goto case 16;
					}
				case 16:
					{
						m_LockBoxData = reader.ReadUInt32();
						goto case 15;
					}
				case 15:
					{
						m_SecurePremises = reader.ReadBool();
						goto case 14;
					}
				case 14:
					{
						idocannc = reader.ReadBool();
						goto case 13;
					}
				case 13:
					{
						m_DecayMinutesStored = reader.ReadDouble();
						m_NeverDecay = reader.ReadBool();
						goto case 11; //note, this isn't a mistake - we want to skip 12
					}
				case 12:
					{
						DateTime tempDT = reader.ReadDeltaTime();
						//StructureDecayTime = reader.ReadDeltaTime();
						m_DecayMinutesStored = (tempDT - DateTime.Now).TotalMinutes;

						m_NeverDecay = reader.ReadBool();
						goto case 11;
					}
				case 11:
					{
						m_MaxLockBoxes = reader.ReadInt();
						m_LockBoxCount = reader.ReadInt();

						goto case 9;
					}
				case 10: // just a signal for updates
				case 9:
					{
						m_Visits = reader.ReadInt();
						goto case 8;
					}
				case 8:
					{
						m_Price = reader.ReadInt();
						goto case 7;
					}
				case 7:
					{
						m_Access = reader.ReadMobileList();
						goto case 6;
					}
				case 6:
					{
						m_BuiltOn = reader.ReadDateTime();
						m_LastTraded = reader.ReadDateTime();
						goto case 5;
					}
				case 5: // just removed fields
				case 4:
					{
						m_Addons = reader.ReadItemList();
						goto case 3;
					}
				case 3:
					{
						count = reader.ReadInt();
						m_Secures = new ArrayList(count);

						for (int i = 0; i < count; ++i)
						{
							SecureInfo info = new SecureInfo(reader);

							if (info.Item != null)
							{
								info.Item.IsSecure = true;
								info.Item.CancelFreezeTimer();        // don't initiate for Deserialize
								m_Secures.Add(info);
							}
						}

						goto case 2;
					}
				case 2:
					{
						m_Public = reader.ReadBool();
						goto case 1;
					}
				case 1:
					{
						m_Region.GoLocation = reader.ReadPoint3D();
						goto case 0;
					}
				case 0:
					{

						if (version < 16)
						{
							LockBoxCeling = (uint)m_MaxLockBoxes * 2;   // high limit
							LockBoxFloor = (uint)m_MaxLockBoxes;        // low limit
						}

						if (version < 12)
						{
							Refresh();
							m_NeverDecay = false;
						}

						if (version < 4)
							m_Addons = new ArrayList();

						if (version < 7)
							m_Access = new ArrayList();

						if (version < 8)
							m_Price = DefaultPrice;

						m_Owner = reader.ReadMobile();

						if (version < 5)
						{
							count = reader.ReadInt();

							for (int i = 0; i < count; i++)
								reader.ReadRect2D();
						}

						UpdateRegionArea();

						Region.AddRegion(m_Region);

						m_CoOwners = reader.ReadMobileList();
						m_Friends = reader.ReadMobileList();
						m_Bans = reader.ReadMobileList();

						m_Sign = reader.ReadItem() as HouseSign;
						m_Trash = reader.ReadItem() as TrashBarrel;

						m_Doors = reader.ReadItemList();
						m_LockDowns = reader.ReadItemList();

						for (int i = 0; i < m_LockDowns.Count; ++i)
						{
							Item item = m_LockDowns[i] as Item;
							if (item != null)
							{
								item.IsLockedDown = true;
								item.CancelFreezeTimer();        // don't initiate for Deserialize
							}
						}

						if (version < 3)
						{
							ArrayList items = reader.ReadItemList();
							m_Secures = new ArrayList(items.Count);

							for (int i = 0; i < items.Count; ++i)
							{
								Container c = items[i] as Container;

								if (c != null)
								{
									c.IsSecure = true;
									m_Secures.Add(new SecureInfo(c, SecureLevel.CoOwners));
								}
							}
						}

						m_MaxLockDowns = reader.ReadInt();
						m_MaxSecures = reader.ReadInt();

						if ((Map == null || Map == Map.Internal) && Location == Point3D.Zero)
							Delete();

						if (m_Owner != null)
						{
							ArrayList list = (ArrayList)m_Table[m_Owner];

							if (list == null)
								m_Table[m_Owner] = list = new ArrayList();

							list.Add(this);
						}
						break;
					}
			}

			// patch m_NPCData to hold the default barkeep count
			if (version < 20)
				MaximumBarkeepCount = 2;		

			if (version <= 1)
				ChangeSignType(0xBD2);//private house, plain brass sign

			if (version < 10)
			{
				/* NOTE: This can exceed the house lockdown limit. It must be this way, because
				 * we do not want players' items to decay without them knowing. Or not even
				 * having a chance to fix it themselves.
				 */

				Timer.DelayCall(TimeSpan.Zero, new TimerCallback(FixLockdowns_Sandbox));
			}

			if (idocannc) // idoc announcement was running when we saved, re-create it
			{
				string[] lines = new string[1];
				lines[0] = String.Format("Lord British has condemned the estate of {0} near {1}.", this.Owner.Name, DescribeLocation());
				m_IDOC_Broadcast_TCE = new TownCrierEntry(lines, TimeSpan.FromMinutes(m_DecayMinutesStored), Serial.MinusOne);
				GlobalTownCrierEntryList.Instance.AddEntry(m_IDOC_Broadcast_TCE);
			}
		}
示例#35
0
		public void RemoveEntry( TownCrierEntry tce )
		{
			if ( m_Entries == null )
				return;

			m_Entries.Remove( tce );

			if ( m_Entries.Count == 0 )
				m_Entries = null;

			if ( m_Entries == null && GlobalTownCrierEntryList.Instance.IsEmpty )
			{
				if ( m_AutoShoutTimer != null )
					m_AutoShoutTimer.Stop();

				m_AutoShoutTimer = null;
			}
		}
示例#36
0
		public override void OnDelete()
		{
			//Township cleanup
			Mobile tsNPC = this.FindTownshipNPC();
			int tscount = 0; //just a safety measure - there should be only one Township NPC anyways
			while (tsNPC != null && tscount < 10)
			{
				tsNPC.Delete();
				tsNPC = this.FindTownshipNPC();
				tscount++;
			}

//Pix: 7/13/2008 - Removing the requirement of a townshipstone to be in a house.
//			TownshipStone tstone = this.FindTownshipStone();
//			if (tstone != null)
//			{
//				tstone.Delete();
//			}
			//END Township cleanup


			// stop announcing this house!!
			if (m_IDOC_Broadcast_TCE != null)
			{
				GlobalTownCrierEntryList.Instance.RemoveEntry(m_IDOC_Broadcast_TCE);
				m_IDOC_Broadcast_TCE = null;
			}

			new FixColumnTimer(this).Start();

			if (m_Region != null)
				Region.RemoveRegion(m_Region);

			base.OnDelete();
		}