예제 #1
0
            public static MongbatMeadDrunkard Find(Mobile from)
            {
                foreach (MongbatMeadDrunkard drunk in Drunks)
                {
                    if (from == drunk.Mobile)
                    {
                        return(drunk);
                    }
                }

                var newDrunk = new MongbatMeadDrunkard(from, DateTime.UtcNow);

                Drunks.Add(newDrunk);

                if (Drunks.Count == 1)
                {
                    if (m_Timer != null)
                    {
                        m_Timer.Stop();
                    }
                    else
                    {
                        m_Timer = new InternalTimer();
                        m_Timer.Start();
                    }
                }

                return(newDrunk);
            }
예제 #2
0
            public static void Remove(MongbatMeadDrunkard drunk)
            {
                if (Drunks.Contains(drunk))
                {
                    Drunks.Remove(drunk);

                    if (Drunks.Count == 0)
                    {
                        if (m_Timer != null)
                        {
                            m_Timer.Stop();
                            m_Timer = null;
                        }
                    }
                }
            }
예제 #3
0
            protected override void OnTick()
            {
                DateTime now = DateTime.UtcNow;

                for (int i = 0; i < Drunks.Count; i++)
                {
                    var drunk = Drunks[i];
                    if (drunk.End < now)
                    {
                        MongbatMeadDrunkard.Remove(drunk);
                        --i; continue;
                    }
                    else if (Utility.RandomBool())
                    {
                        drunk.SendMongbat();
                    }
                }
            }
예제 #4
0
        public override void OnDrink(Mobile from)
        {
            var state = MongbatMeadDrunkard.Find(from);

            state.End += TimeSpan.FromMinutes(2);
        }