예제 #1
0
        /// <summary>
        /// Provides notifications of approaching events and starts them
        /// </summary>
        protected override void OnTick()
        {
            if (!m_EventsEnabled || AutoRestart.Restarting)
            {
                Stop();
            }

            // Checks the next scheduled tournament and gives out notifications for the tournament
            if (XMLDates.Events.ContainsKey("tournament"))
            {
                if (XMLDates.Events["tournament"].Count > 0 && ArenaControl.Arenas.Count > 0)
                {
                    t = (Tournament)XMLDates.Events["tournament"][0];
                    TimeSpan date = t.Date - DateTime.Now;
                    // Give 15 minute warning for the tournament
                    if (date.Days == 0 && date.Hours == 0 && date.Minutes == 15 && date.Seconds < 10)
                    {
                        World.Broadcast(0, false, String.Format("The {0} tournament will commence in approximately 15 minutes.", t.TeamSize));
                        World.Broadcast(0, false, "If you have not registered, please do so at this time with [tournaments");
                    }
                    // Give 5 minute warning for the tournament
                    else if (date.Days == 0 && date.Hours == 0 && date.Minutes == 5 && date.Seconds < 10)
                    {
                        World.Broadcast(0, false, String.Format("The {0} tournament will commence in approximately 5 minutes.", t.TeamSize));
                        World.Broadcast(0, false, "If you have registered, please make your way to a safe location.");
                    }
                    // Give 2 minute warning for the tournament
                    else if (date.Days == 0 && date.Hours == 0 && date.Minutes == 2 && date.Seconds < 10)
                    {
                        World.Broadcast(0, false, String.Format("Two minute warning for the {0} tournament.", t.TeamSize));
                    }
                    // Begin the tournament
                    else if (date.Days == 0 && date.Hours == 0 && date.Minutes == 0 && date.Seconds < 10)
                    {
                        World.Broadcast(0, false, String.Format("The {0} tournament will begin shortly.", t.TeamSize));
                        TournamentTimer timer = new TournamentTimer(t);
                        timer.Prepare();
                        XMLDates.RemoveTournament(t);
                    }
                }
            }
        }