Ejemplo n.º 1
0
        public static void Deserialize(GenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            //Version 0
            if (version >= 0)
            {
                m_Enabled = reader.ReadBool();
                m_Active  = reader.ReadBool();
                NextScheduledCaptureEventStartTime = reader.ReadDateTime();
                AnnouncementMade        = reader.ReadBool();
                TimeElapsed             = reader.ReadTimeSpan();
                CurrentSchedulePosition = reader.ReadInt();
                CurrentCyclePosition    = reader.ReadInt();
                CurrentEventPosition    = reader.ReadInt();

                int captureEventCount = reader.ReadInt();
                for (int a = 0; a < captureEventCount; a++)
                {
                    FactionCaptureEvent captureEvent = (FactionCaptureEvent)reader.ReadItem();
                    CaptureEvents.Add(captureEvent);
                }

                CurrentCaptureEvent = (FactionCaptureEvent)reader.ReadItem();
            }
        }
Ejemplo n.º 2
0
        public static void StartCaptureEvent()
        {
            if (Active)
            {
                return;
            }

            FactionCaptureEvent.CreateCaptureEvent();

            if (CurrentCaptureEvent == null)
            {
                return;
            }

            CurrentCaptureEvent.OnEventStart();

            Active = true;

            CurrentCaptureEvent.EventStart = DateTime.UtcNow;

            TimeElapsed = TimeSpan.FromSeconds(0);

            if (m_Timer != null)
            {
                m_Timer.Stop();
                m_Timer = null;
            }

            m_Timer = new FactionTimer();
            m_Timer.Start();
        }
Ejemplo n.º 3
0
        public static void EndCaptureEvent()
        {
            if (!Active)
            {
                return;
            }

            Active      = false;
            TimeElapsed = TimeSpan.FromSeconds(0);

            if (CurrentCaptureEvent != null)
            {
                CurrentCaptureEvent.OnEventCompletion();

                CurrentCaptureEvent.EventCompletion = DateTime.UtcNow;
                CurrentCaptureEvent.Completed       = true;

                CurrentCaptureEvent = null;
            }

            CurrentEventPosition++;

            //Cycle Completed
            if (CurrentEventPosition > EventsInCycle.Count)
            {
                CurrentCyclePosition++;
                CurrentEventPosition = 1;

                //Schedule Completed
                if (CurrentCyclePosition > CyclesPerSchedule)
                {
                    CurrentSchedulePosition++;
                    CurrentCyclePosition = 1;

                    ResolveScheduleCompletion();
                }
            }

            if (CurrentCyclePosition > EventsInCycle.Count)
            {
                CurrentCyclePosition = EventsInCycle.Count;
            }

            TimeSpan timeUntilNextEvent = EventsInCycle[CurrentCyclePosition - 1];

            if (CurrentCyclePosition == 1)
            {
                timeUntilNextEvent = timeUntilNextEvent + CycleDowntime;
            }

            FactionPersistance.NextScheduledCaptureEventStartTime = FactionPersistance.NextScheduledCaptureEventStartTime + timeUntilNextEvent;
        }
Ejemplo n.º 4
0
        public static void CreateCaptureEvent()
        {
            FactionCaptureEvent factionCaptureEvent = null;

            //TEST: Populate

            factionCaptureEvent.SchedulePosition = FactionPersistance.CurrentSchedulePosition;
            factionCaptureEvent.CyclePosition    = FactionPersistance.CurrentCyclePosition;
            factionCaptureEvent.EventPosition    = FactionPersistance.CurrentEventPosition;

            FactionPersistance.CurrentCaptureEvent = factionCaptureEvent;
            FactionPersistance.CaptureEvents.Add(factionCaptureEvent);
        }
Ejemplo n.º 5
0
        public static void ResolveScheduleCompletion()
        {
            if (DeletePreviousCycleRecords)
            {
                Queue m_Queue = new Queue();

                while (m_Queue.Count > 0)
                {
                    FactionCaptureEvent captureEvent = (FactionCaptureEvent)m_Queue.Dequeue();

                    captureEvent.Delete();
                }
            }
        }
Ejemplo n.º 6
0
        public static void FactionDeleteAllCaptureEvents(CommandEventArgs arg)
        {
            PlayerMobile pm_Mobile = arg.Mobile as PlayerMobile;

            if (pm_Mobile == null)
            {
                return;
            }

            CurrentSchedulePosition = 1;
            CurrentEventPosition    = 1;
            CurrentCyclePosition    = 1;

            if (Active)
            {
                EndCaptureEvent();
            }

            Queue m_Queue = new Queue();

            foreach (FactionCaptureEvent FactionCaptureEvent in CaptureEvents)
            {
                m_Queue.Enqueue(FactionCaptureEvent);
            }

            while (m_Queue.Count > 0)
            {
                FactionCaptureEvent factionCaptureEvent = (FactionCaptureEvent)m_Queue.Dequeue();
                factionCaptureEvent.Delete();
            }

            CurrentCaptureEvent = null;

            //Prevent New Event Immediately Occuring: Will Require Schedule Realignment
            if (DateTime.UtcNow >= FactionPersistance.NextScheduledCaptureEventStartTime)
            {
                FactionPersistance.NextScheduledCaptureEventStartTime = DateTime.UtcNow + TimeSpan.FromDays(365);
            }
        }