private void DamageTimer_Tick(object sender, EventArgs e) { if (gameover == true) { DamageTimer.Stop(); DamageTimer.Enabled = false; return; } foreach (Control x in this.Controls) { if (boss1.Hp > 0) { if (x is PictureBox && x.Tag == "bullet") { if (((PictureBox)x).Bounds.IntersectsWith(this.boss1.boss.Bounds) && this.boss1.Hp > 0) { this.Bhit.Text = "-10"; this.Bhit.Location = new Point(this.boss1.boss.Location.X - 30, this.boss1.boss.Location.Y - 50); this.Controls.Add(Bhit); this.Bhit.Visible = true; this.Bhit.BringToFront(); this.boss1.Hp -= 10; this.Controls.Remove(x); x.Dispose(); } } } if (boss1.Hp == 0) { boss1.boss.Image = bossdeath; gameover = true; } } VillainHPbar.Value = this.boss1.Hp; }
public static void Unregister(DamageTimer timer) { var master = timer.Master; if (m_Table.ContainsKey(master)) { var list = m_Table[master]; if (timer.Running) { timer.Stop(); } list.Remove(timer); if (list.Count == 0) { m_Table.Remove(master); } } }