コード例 #1
0
ファイル: SherryTheMouseStatue.cs プロジェクト: pallop/Servuo
        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;
            }
        }
コード例 #2
0
        public override void OnSpeech(SpeechEventArgs e)
        {
            if (m_TurnedOn && IsLockedDown)
            {
                if (m_NewsTimer == null && e.HasKeyword(0x30) && e.Mobile.Alive && e.Mobile.InRange(this, 12)) // *news*
                {
                    TownCrierEntry tce = 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!
                    }
                }
            }
        }
コード例 #3
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 = 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 = m_Entries[Utility.Random(m_Entries.Count)];
            }

            return(entry);
        }