public bool timer1(ref bool won) { foreach (var item in BossBullets) { item.Move(Width, Height); } hero.MoveBullets(Width, Height); if (hero.Kills >= 15) { hasBoss = true; } foreach (Bullet b in ZombieBullets) { b.Move(Width, Height); } foreach (Bullet b in hero.Bullets) { foreach (Zombie z in zombies) { if (b.isHit(z.Position)) { z.Alive = false; b.Alive = false; hero.Kills++; } } if (hasBoss) { if (b.isHit(boss.Position)) { boss.Health -= 20; b.Alive = false; } if (boss.Health <= 0) { hasBoss = false; won = true; return(false); } } } foreach (Bullet b in ZombieBullets) { if (b.isHit(hero.Position)) { hero.Health -= 10; if (hero.Health <= 0) { hero.Image = Properties.Resources.dead; return(true); } b.Alive = false; } } foreach (Bullet b in BossBullets) { if (b.isHit(hero.Position)) { hero.Health -= 20; if (hero.Health <= 0) { hero.Image = Properties.Resources.dead; return(true); } b.Alive = false; } } for (int i = ZombieBullets.Count - 1; i >= 0; i--) { if (!ZombieBullets[i].Alive) { ZombieBullets.RemoveAt(i); } } for (int i = BossBullets.Count - 1; i >= 0; i--) { if (!BossBullets[i].Alive) { BossBullets.RemoveAt(i); } } for (int i = zombies.Count - 1; i >= 0; i--) { if (!zombies[i].Alive) { zombies.RemoveAt(i); } } return(false); }
public bool timer2() { Count++; if (hero.Kills >= 15) { boss.Move(hero.Position); } foreach (Zombie2 z in zombies) { z.Move(hero.Position); if (z.isHit(hero.Position)) { hero.Health -= 2; if (hero.Health <= 0) { hero.Image = Properties.Resources.dead; return(true); } } } if (Count % 70 == 0) { int top = r.Next(0, 2); zombies.Add(new Zombie2(new Point(r.Next(0, Width - 30), top == 0 ? 50 : Height - 40), Properties.Resources.zw2right)); top = r.Next(0, 2); zombies.Add(new Zombie2(new Point(r.Next(0, Width - 30), top == 0 ? 50 : Height - 40), Properties.Resources.zw2right)); top = r.Next(0, 2); zombies.Add(new Zombie2(new Point(r.Next(0, Width - 30), top == 0 ? 50 : Height - 40), Properties.Resources.zw2right)); } if (Count % 50 == 0 || Count % 51 == 0 || Count % 52 == 0) { foreach (Zombie2 item in zombies) { ZombieBullets.Add(new Bullet(item.Position, item.Direction, Color.Black)); } } if (hasBoss) { if (boss.isHit(hero.Position)) { hero.Health -= 30; if (hero.Health <= 0) { hero.Image = Properties.Resources.dead; return(true); } } if (Count % 95 == 0 || Count % 96 == 0 || Count % 97 == 0) { BossBullets.Add(new Bullet(boss.Position, boss.Direction, Color.Black, 20, 20)); } } if (Count % 150 == 0) { gifts.Add(new AmmoGift(new Point(r.Next(0, Width - 50), r.Next(30, Height - 50)))); } foreach (AmmoGift g in gifts) { g.Count++; if (g.Count == 100) { g.Alive = false; } } return(false); }