public RespawnTimer(TimeSpan delay, PlayerContextData pcd, TimeSpan tick)
     : base(delay, tick)
 {
     Priority = TimerPriority.TwoFiftyMS;
     m_pcd    = pcd;
     m_round  = m_pcd.CTFControl.Round;                                          // if it changes, we know the round is over
 }
        // passed up from the region. Return true if handled, false otherwise
        public bool OnRegionSpeech(SpeechEventArgs e)
        {                                     // the CTF region supports DOT commands, i.e., .stats or .help
            string text = e.Speech.ToLower(); // lowercase

            string[] tokens = text.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            switch (tokens[0])
            {
            case ".help":
                if (tokens.Length == 1)
                {
                    e.Mobile.SendMessage(e.Mobile.SpeechHue, ".help commands: list commands.");
                    e.Mobile.SendMessage(e.Mobile.SpeechHue, ".help game: get game help and tips.");
                    return(true);
                }
                else
                {
                    switch (tokens[1])
                    {
                    case "commands":
                    case "command":
                    {
                        e.Mobile.SendMessage(e.Mobile.SpeechHue, ".help: lists kinds of help.");
                        e.Mobile.SendMessage(e.Mobile.SpeechHue, ".help commands: list commands.");
                        e.Mobile.SendMessage(e.Mobile.SpeechHue, ".help game: get game help and tips.");
                        e.Mobile.SendMessage(e.Mobile.SpeechHue, ".stats: Game score and player kills.");
                        e.Mobile.SendMessage(e.Mobile.SpeechHue, ".time: Time left in the game/round.");
                        e.Mobile.SendMessage(e.Mobile.SpeechHue, ".kick <name>: Kick a team member for betrayal.");
                        e.Mobile.SendMessage(e.Mobile.SpeechHue, ".exit: Exit the game and go home (pussy-cake).");
                    }
                        return(true);

                    case "game":
                    {
                        if (GetTeam(e.Mobile) == Offense)
                        {
                            e.Mobile.SendMessage(e.Mobile.SpeechHue, "You are on offense. Objective:");
                            e.Mobile.SendMessage(e.Mobile.SpeechHue, "Go to the enemy base and capture the flag and bring it back to your home base.");
                            e.Mobile.SendMessage(e.Mobile.SpeechHue, "The flag is a bright red staff. Just walk over it to pick it up.");
                        }
                        else if (GetTeam(e.Mobile) == Defense)
                        {
                            e.Mobile.SendMessage(e.Mobile.SpeechHue, "You are on defense. Objective:");
                            e.Mobile.SendMessage(e.Mobile.SpeechHue, "Prevent the enemy from taking your flag!");
                            e.Mobile.SendMessage(e.Mobile.SpeechHue, "The flag is the bright red staff.");
                            e.Mobile.SendMessage(e.Mobile.SpeechHue, "If the enemy takes your flag, you must kill them before they can take it back to their base.");
                        }
                    }
                        return(true);

                    default:
                        break;
                    }
                }
                break;

            case ".stats":
            {
                if (CurrentState == States.PlayRound)
                {
                    e.Mobile.SendMessage(e.Mobile.SpeechHue, "The score is {0}-{1}. ({2})",
                                         Math.Max(OffenseScore, DefenseScore), Math.Min(OffenseScore, DefenseScore),
                                         (OffenseScore > DefenseScore && GetTeam(e.Mobile) == Offense) ? "You're winning" :
                                         (DefenseScore > OffenseScore && GetTeam(e.Mobile) == Defense) ? "You're winning" :
                                         (DefenseScore == OffenseScore) ? "Tied" : "You're loosing");
                }
                else
                {
                    e.Mobile.SendMessage(e.Mobile.SpeechHue, "No score data is available.");
                }

                if (CurrentState == States.PlayRound)
                {
                    Dictionary <PlayerMobile, PlayerContextData> team = GetTeam((GetTeam(e.Mobile)));
                    if (team != null)
                    {
                        e.Mobile.SendMessage(e.Mobile.SpeechHue, "You have {0} kill{1}.", team[e.Mobile as PlayerMobile].Points, team[e.Mobile as PlayerMobile].Points == 1 ? "" : "s");
                    }
                    else
                    {                                           // you are not on a team
                        e.Mobile.SendMessage(e.Mobile.SpeechHue, "No kills data is available.");
                    }
                }
                else
                {
                    e.Mobile.SendMessage(e.Mobile.SpeechHue, "No kills data is available.");
                }

                if (CurrentState == States.PlayRound)
                {
                    if (IsFlagHome() == false)
                    {
                        if (GetTeam(e.Mobile) == Defense && Flag.RootParent == null)
                        {
                            e.Mobile.SendMessage(e.Mobile.SpeechHue, "Your flag is away.");                                                                     // flag is on the ground somewhere
                        }
                        else if (GetTeam(e.Mobile) == Defense && Flag.RootParent != null)
                        {
                            e.Mobile.SendMessage(e.Mobile.SpeechHue, "Your flag has been taken.");                                                      // enemy has your flag
                        }
                        if (GetTeam(e.Mobile) == Offense && Flag.RootParent != null)
                        {
                            e.Mobile.SendMessage(e.Mobile.SpeechHue, "Your team has the enemy flag.");                                                  // your team has the enmy flag.
                        }
                    }
                }
            }
                return(true);

            case ".time":
            {
                e.Mobile.SendMessage(e.Mobile.SpeechHue, "There are {0:0.##} minutes left in the round with {1:0.##} minutes left in the game.",
                                     GetRoundRemainingTime().TotalMinutes, GetGameRemainingTime().TotalMinutes);
            }
                return(true);

            case ".kick":
            {
                if (tokens.Length == 1)
                {
                    e.Mobile.SendMessage(e.Mobile.SpeechHue, "use .kick Player Name");
                }
                else
                {                                       // get the name of the player to kick
                    string name = e.Speech.Substring(".kick".Length).Trim();

                    // you may only kick someone your own team
                    if (GetTeam(GetTeam(e.Mobile)) != null)
                    {
                        PlayerMobile pm = null;
                        foreach (KeyValuePair <PlayerMobile, PlayerContextData> kvp in GetTeam(GetTeam(e.Mobile)))
                        {
                            if (kvp.Key.Name.ToLower() == name)
                            {
                                pm = kvp.Key;
                                KickPlayer(kvp.Key, kvp.Value, "You have been kicked!", KickReason.Kicked);
                                break;
                            }
                        }

                        // now remove the player from the team list
                        if (pm != null)
                        {
                            if (GetTeam(GetTeam(e.Mobile)).ContainsKey(pm))
                            {
                                GetTeam(GetTeam(e.Mobile)).Remove(pm);
                            }
                        }
                    }
                }
            }
                return(true);

            case ".exit":
            {                                   // if I'm on a team, select the team and delete me from it
                if (GetTeam(GetTeam(e.Mobile)) != null)
                {
                    PlayerContextData pcd = GetTeam(GetTeam(e.Mobile))[e.Mobile as PlayerMobile];
                    KickPlayer(e.Mobile, pcd, "You have left the game.", KickReason.Exited);
                    GetTeam(GetTeam(e.Mobile)).Remove(e.Mobile as PlayerMobile);
                }
            }
                return(true);
            }

            return(false);
        }