using System; using System.Timers; namespace Filter.Utilities { internal class RespawnTimer { private Timer BossTimer; public bool IsKilled; public int AnnouncementID; public string CheckName; public string BossName; public long RespawnSeconds; public DateTime RespawnDate; public RespawnTimer() { } private void BossTimer_Elapsed(object Sender, ElapsedEventArgs Args) { this.IsKilled = false; object[] bossName = new object[] { this.BossName }; Echo.SendWorldMessage(true, "{0} will be respawning in a few seconds.", bossName); this.BossTimer.Stop(); } public void Create() { this.BossTimer = new Timer() { AutoReset = true }; this.BossTimer.Elapsed += new ElapsedEventHandler(this.BossTimer_Elapsed); this.BossTimer.Interval = (double)(this.RespawnSeconds * (long)1000); } public string RespawnTime() { DateTime now = DateTime.Now; TimeSpan respawnDate = this.RespawnDate - now; TimeSpan timeSpan = TimeSpan.FromSeconds(respawnDate.TotalSeconds); object[] days = new object[] { timeSpan.Days, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds }; return string.Format("{0}Days {1}Hours {2}Minutes {3}Seconds", days); } public void StartTimer() { this.IsKilled = true; DateTime now = DateTime.Now; this.RespawnDate = now.AddSeconds((double)this.RespawnSeconds); this.BossTimer.Start(); object[] bossName = new object[] { this.BossName, this.RespawnTime() }; Echo.SendWorldMessage(true, "{0} has been laid to rest, they will respawn again in: {1}.", bossName); } } }