Пример #1
0
        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);
        }